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:
baliasnyifeliks 2026-02-03 19:54:43 +02:00
parent dff15694cc
commit ed7bfa67de
2 changed files with 31 additions and 7 deletions

View File

@ -24,8 +24,11 @@ namespace Makhno
} }
[HttpGet] [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); await UpdateService.ConnectAsync(host);
var init = await loadKit(ModInit.Makhno); var init = await loadKit(ModInit.Makhno);

View File

@ -274,13 +274,9 @@ namespace Makhno
}; };
} }
var jsonMatch = Regex.Match(html, @"file:'(\[.*?\])'", RegexOptions.Singleline); string jsonData = ExtractPlayerJson(html);
if (jsonMatch.Success) if (!string.IsNullOrEmpty(jsonData))
{ {
string jsonData = jsonMatch.Groups[1].Value
.Replace("\\'", "'")
.Replace("\\\"", "\"");
return new PlayerData return new PlayerData
{ {
File = null, 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) private int? ExtractEpisodeNumber(string value)
{ {
if (string.IsNullOrEmpty(value)) if (string.IsNullOrEmpty(value))