mirror of
https://github.com/lampame/lampac-ukraine.git
synced 2026-04-16 09:22:21 +00:00
fix(makhno): add error logging and improve file array detection
Add diagnostic logging when parsing fails to help identify issues with voice and file data extraction. Enhance file array detection to handle Playerjs-based content by implementing range-based search strategy.
This commit is contained in:
parent
e0d9bfac92
commit
5c22c91421
@ -89,7 +89,10 @@ namespace Makhno
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (playerData?.Voices == null || !playerData.Voices.Any())
|
if (playerData?.Voices == null || !playerData.Voices.Any())
|
||||||
|
{
|
||||||
|
OnLog("Makhno Play: no voices parsed");
|
||||||
return OnError();
|
return OnError();
|
||||||
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(t) || !int.TryParse(t, out int voiceIndex) || voiceIndex >= playerData.Voices.Count)
|
if (string.IsNullOrEmpty(t) || !int.TryParse(t, out int voiceIndex) || voiceIndex >= playerData.Voices.Count)
|
||||||
return OnError();
|
return OnError();
|
||||||
@ -143,7 +146,10 @@ namespace Makhno
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (playerData?.File == null)
|
if (playerData?.File == null)
|
||||||
|
{
|
||||||
|
OnLog("Makhno PlayMovie: no file parsed");
|
||||||
return OnError();
|
return OnError();
|
||||||
|
}
|
||||||
|
|
||||||
string streamUrl = BuildStreamUrl(init, playerData.File);
|
string streamUrl = BuildStreamUrl(init, playerData.File);
|
||||||
|
|
||||||
@ -162,7 +168,10 @@ namespace Makhno
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (playerData?.File == null)
|
if (playerData?.File == null)
|
||||||
|
{
|
||||||
|
OnLog("Makhno HandleMovie: no file parsed");
|
||||||
return OnError();
|
return OnError();
|
||||||
|
}
|
||||||
|
|
||||||
string movieLink = $"{host}/makhno/play/movie?imdb_id={HttpUtility.UrlEncode(imdb_id)}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&year={year}&play=true";
|
string movieLink = $"{host}/makhno/play/movie?imdb_id={HttpUtility.UrlEncode(imdb_id)}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&year={year}&play=true";
|
||||||
var tpl = new MovieTpl(title ?? original_title, original_title, 1);
|
var tpl = new MovieTpl(title ?? original_title, original_title, 1);
|
||||||
@ -181,7 +190,10 @@ namespace Makhno
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (playerData?.Voices == null || !playerData.Voices.Any())
|
if (playerData?.Voices == null || !playerData.Voices.Any())
|
||||||
|
{
|
||||||
|
OnLog("Makhno HandleSerial: no voices parsed");
|
||||||
return OnError();
|
return OnError();
|
||||||
|
}
|
||||||
|
|
||||||
if (season == -1)
|
if (season == -1)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -387,6 +387,14 @@ namespace Makhno
|
|||||||
|
|
||||||
private int FindFileArrayStart(string html)
|
private int FindFileArrayStart(string html)
|
||||||
{
|
{
|
||||||
|
int playerStart = html.IndexOf("Playerjs", StringComparison.OrdinalIgnoreCase);
|
||||||
|
if (playerStart >= 0)
|
||||||
|
{
|
||||||
|
int playerIndex = FindFileArrayStartInRange(html, playerStart);
|
||||||
|
if (playerIndex >= 0)
|
||||||
|
return playerIndex;
|
||||||
|
}
|
||||||
|
|
||||||
int index = FindFileArrayIndex(html, "file:'[");
|
int index = FindFileArrayIndex(html, "file:'[");
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
return index;
|
return index;
|
||||||
@ -402,6 +410,39 @@ namespace Makhno
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int FindFileArrayStartInRange(string html, int startIndex)
|
||||||
|
{
|
||||||
|
int searchStart = startIndex;
|
||||||
|
int searchEnd = Math.Min(html.Length, startIndex + 200000);
|
||||||
|
|
||||||
|
int tokenIndex = IndexOfIgnoreCase(html, "file:'[", searchStart, searchEnd);
|
||||||
|
if (tokenIndex >= 0)
|
||||||
|
return html.IndexOf('[', tokenIndex);
|
||||||
|
|
||||||
|
tokenIndex = IndexOfIgnoreCase(html, "file:\"[", searchStart, searchEnd);
|
||||||
|
if (tokenIndex >= 0)
|
||||||
|
return html.IndexOf('[', tokenIndex);
|
||||||
|
|
||||||
|
tokenIndex = IndexOfIgnoreCase(html, "file", searchStart, searchEnd);
|
||||||
|
if (tokenIndex >= 0)
|
||||||
|
{
|
||||||
|
int bracketIndex = html.IndexOf('[', tokenIndex);
|
||||||
|
if (bracketIndex >= 0 && bracketIndex < searchEnd)
|
||||||
|
return bracketIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int IndexOfIgnoreCase(string text, string value, int startIndex, int endIndex)
|
||||||
|
{
|
||||||
|
int index = text.IndexOf(value, startIndex, StringComparison.OrdinalIgnoreCase);
|
||||||
|
if (index >= 0 && index < endIndex)
|
||||||
|
return index;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
private int FindFileArrayIndex(string html, string token)
|
private int FindFileArrayIndex(string html, string token)
|
||||||
{
|
{
|
||||||
int tokenIndex = html.IndexOf(token, StringComparison.OrdinalIgnoreCase);
|
int tokenIndex = html.IndexOf(token, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user