mirror of
https://github.com/lampame/lampac-ukraine.git
synced 2026-04-16 09:22:21 +00:00
feat: Add checksearch parameter to Controller.Index and refactor player JSON extraction in MakhnoInvoke into a new helper method for broader pattern matching.
This commit is contained in:
parent
dff15694cc
commit
ed7bfa67de
@ -24,8 +24,11 @@ namespace Makhno
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> Index(long id, string imdb_id, long kinopoisk_id, string title, string original_title, string original_language, int year, string source, int serial, string account_email, string t, int s = -1, int season = -1, bool rjson = false)
|
||||
public async Task<ActionResult> Index(long id, string imdb_id, long kinopoisk_id, string title, string original_title, string original_language, int year, string source, int serial, string account_email, string t, int s = -1, int season = -1, bool rjson = false, bool checksearch = false)
|
||||
{
|
||||
if (checksearch)
|
||||
return Content("data-json=");
|
||||
|
||||
await UpdateService.ConnectAsync(host);
|
||||
|
||||
var init = await loadKit(ModInit.Makhno);
|
||||
|
||||
@ -274,13 +274,9 @@ namespace Makhno
|
||||
};
|
||||
}
|
||||
|
||||
var jsonMatch = Regex.Match(html, @"file:'(\[.*?\])'", RegexOptions.Singleline);
|
||||
if (jsonMatch.Success)
|
||||
string jsonData = ExtractPlayerJson(html);
|
||||
if (!string.IsNullOrEmpty(jsonData))
|
||||
{
|
||||
string jsonData = jsonMatch.Groups[1].Value
|
||||
.Replace("\\'", "'")
|
||||
.Replace("\\\"", "\"");
|
||||
|
||||
return new PlayerData
|
||||
{
|
||||
File = null,
|
||||
@ -365,6 +361,31 @@ namespace Makhno
|
||||
}
|
||||
}
|
||||
|
||||
private string ExtractPlayerJson(string html)
|
||||
{
|
||||
if (string.IsNullOrEmpty(html))
|
||||
return null;
|
||||
|
||||
var matches = new[]
|
||||
{
|
||||
Regex.Match(html, @"file\s*:\s*'(\[.*\])'", RegexOptions.Singleline),
|
||||
Regex.Match(html, @"file\s*:\s*""(\[.*\])""", RegexOptions.Singleline),
|
||||
Regex.Match(html, @"file\s*:\s*(\[[\s\S]*?\])", RegexOptions.Singleline)
|
||||
};
|
||||
|
||||
foreach (var match in matches)
|
||||
{
|
||||
if (match.Success)
|
||||
{
|
||||
return match.Groups[1].Value
|
||||
.Replace("\\'", "'")
|
||||
.Replace("\\\"", "\"");
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private int? ExtractEpisodeNumber(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user