mirror of
https://github.com/lampame/lampac-ukraine.git
synced 2026-04-16 09:22:21 +00:00
refactor(makhno): prioritize json data extraction in player parsing
Reorder parsing logic to attempt JSON extraction first before falling back to regex-based m3u8 and source tag matching. This ensures structured data is preferred when available, with fallbacks for legacy formats.
This commit is contained in:
parent
5c22c91421
commit
a2e018c1be
@ -252,28 +252,6 @@ namespace Makhno
|
||||
};
|
||||
}
|
||||
|
||||
var m3u8Match = Regex.Match(html, @"(https?://[^""'\s>]+\.m3u8[^""'\s>]*)", RegexOptions.IgnoreCase);
|
||||
if (m3u8Match.Success)
|
||||
{
|
||||
return new PlayerData
|
||||
{
|
||||
File = m3u8Match.Groups[1].Value,
|
||||
Poster = null,
|
||||
Voices = new List<Voice>()
|
||||
};
|
||||
}
|
||||
|
||||
var sourceMatch = Regex.Match(html, @"<source[^>]*src=[""']([^""']+)[""']", RegexOptions.IgnoreCase);
|
||||
if (sourceMatch.Success)
|
||||
{
|
||||
return new PlayerData
|
||||
{
|
||||
File = sourceMatch.Groups[1].Value,
|
||||
Poster = null,
|
||||
Voices = new List<Voice>()
|
||||
};
|
||||
}
|
||||
|
||||
string jsonData = ExtractPlayerJson(html);
|
||||
if (jsonData == null)
|
||||
_onLog("Makhno ParsePlayerData: file array not found");
|
||||
@ -291,6 +269,30 @@ namespace Makhno
|
||||
};
|
||||
}
|
||||
|
||||
var m3u8Match = Regex.Match(html, @"(https?://[^""'\s>]+\.m3u8[^""'\s>]*)", RegexOptions.IgnoreCase);
|
||||
if (m3u8Match.Success)
|
||||
{
|
||||
_onLog("Makhno ParsePlayerData: fallback m3u8 match");
|
||||
return new PlayerData
|
||||
{
|
||||
File = m3u8Match.Groups[1].Value,
|
||||
Poster = null,
|
||||
Voices = new List<Voice>()
|
||||
};
|
||||
}
|
||||
|
||||
var sourceMatch = Regex.Match(html, @"<source[^>]*src=[""']([^""']+)[""']", RegexOptions.IgnoreCase);
|
||||
if (sourceMatch.Success)
|
||||
{
|
||||
_onLog("Makhno ParsePlayerData: fallback source match");
|
||||
return new PlayerData
|
||||
{
|
||||
File = sourceMatch.Groups[1].Value,
|
||||
Poster = null,
|
||||
Voices = new List<Voice>()
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user