diff --git a/Makhno/Controller.cs b/Makhno/Controller.cs index 4b93362..0e24b41 100644 --- a/Makhno/Controller.cs +++ b/Makhno/Controller.cs @@ -24,8 +24,11 @@ namespace Makhno } [HttpGet] - public async Task 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 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); diff --git a/Makhno/MakhnoInvoke.cs b/Makhno/MakhnoInvoke.cs index 7f75b28..260024c 100644 --- a/Makhno/MakhnoInvoke.cs +++ b/Makhno/MakhnoInvoke.cs @@ -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))