mirror of
https://github.com/lampame/lampac-ukraine.git
synced 2026-04-16 17:32:20 +00:00
fix(makhno): remove debug logging and improve season filtering logic
- Removed debug logging statements that were causing noisy output in production - Simplified season filtering logic by using nullable int for seasonVoiceIndex - Improved season link generation to handle requested season availability more efficiently - Refactored season item selection logic to be more maintainable and readable
This commit is contained in:
parent
f189357447
commit
55ee3b644d
@ -206,12 +206,7 @@ namespace Makhno
|
|||||||
.Where(v => v.Seasons.Count > 0)
|
.Where(v => v.Seasons.Count > 0)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
OnLog($"Makhno SeasonDebug: voices={playerData.Voices.Count}, withSeasons={voiceSeasons.Count}, t={t}, season={season}");
|
// Debug logging disabled to avoid noisy output in production.
|
||||||
foreach (var v in voiceSeasons)
|
|
||||||
{
|
|
||||||
var seasonList = string.Join(", ", v.Seasons.Select(s => $"{s.Number}:{s.Season?.Title}"));
|
|
||||||
OnLog($"Makhno SeasonDebug: voice[{v.Index}]='{v.Voice?.Name}', seasons=[{seasonList}]");
|
|
||||||
}
|
|
||||||
|
|
||||||
var seasonNumbers = voiceSeasons
|
var seasonNumbers = voiceSeasons
|
||||||
.SelectMany(v => v.Seasons.Select(s => s.Number))
|
.SelectMany(v => v.Seasons.Select(s => s.Number))
|
||||||
@ -224,9 +219,13 @@ namespace Makhno
|
|||||||
|
|
||||||
if (season == -1)
|
if (season == -1)
|
||||||
{
|
{
|
||||||
if (int.TryParse(t, out int seasonVoiceIndex) && seasonVoiceIndex >= 0 && seasonVoiceIndex < playerData.Voices.Count)
|
int? seasonVoiceIndex = null;
|
||||||
|
if (int.TryParse(t, out int tIndex) && tIndex >= 0 && tIndex < playerData.Voices.Count)
|
||||||
|
seasonVoiceIndex = tIndex;
|
||||||
|
|
||||||
|
if (seasonVoiceIndex.HasValue)
|
||||||
{
|
{
|
||||||
var seasonsForVoice = GetSeasonsWithNumbers(playerData.Voices[seasonVoiceIndex])
|
var seasonsForVoice = GetSeasonsWithNumbers(playerData.Voices[seasonVoiceIndex.Value])
|
||||||
.Select(s => s.Number)
|
.Select(s => s.Number)
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.OrderBy(n => n)
|
.OrderBy(n => n)
|
||||||
@ -239,12 +238,20 @@ namespace Makhno
|
|||||||
var season_tpl = new SeasonTpl();
|
var season_tpl = new SeasonTpl();
|
||||||
foreach (var seasonNumber in seasonNumbers)
|
foreach (var seasonNumber in seasonNumbers)
|
||||||
{
|
{
|
||||||
var seasonItem = voiceSeasons
|
(Season Season, int Number)? seasonItem = null;
|
||||||
|
if (seasonVoiceIndex.HasValue)
|
||||||
|
{
|
||||||
|
var voiceSeasonsForT = GetSeasonsWithNumbers(playerData.Voices[seasonVoiceIndex.Value]);
|
||||||
|
seasonItem = voiceSeasonsForT.FirstOrDefault(s => s.Number == seasonNumber);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
seasonItem = voiceSeasons
|
||||||
.SelectMany(v => v.Seasons)
|
.SelectMany(v => v.Seasons)
|
||||||
.FirstOrDefault(s => s.Number == seasonNumber);
|
.FirstOrDefault(s => s.Number == seasonNumber);
|
||||||
|
}
|
||||||
|
|
||||||
var preferredVoice = voiceSeasons.FirstOrDefault(v => v.Seasons.Any(s => s.Number == seasonNumber));
|
string voiceParam = seasonVoiceIndex.HasValue ? $"&t={seasonVoiceIndex.Value}" : string.Empty;
|
||||||
string voiceParam = preferredVoice != null ? $"&t={preferredVoice.Index}" : string.Empty;
|
|
||||||
string seasonName = seasonItem.Season?.Title ?? $"Сезон {seasonNumber}";
|
string seasonName = seasonItem.Season?.Title ?? $"Сезон {seasonNumber}";
|
||||||
string link = $"{host}/makhno?imdb_id={imdb_id}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&year={year}&serial=1&season={seasonNumber}{voiceParam}";
|
string link = $"{host}/makhno?imdb_id={imdb_id}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&year={year}&serial=1&season={seasonNumber}{voiceParam}";
|
||||||
season_tpl.Append(seasonName, link, seasonNumber.ToString());
|
season_tpl.Append(seasonName, link, seasonNumber.ToString());
|
||||||
@ -274,16 +281,16 @@ namespace Makhno
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
string voiceLink;
|
string voiceLink;
|
||||||
if (seasonsForVoice.Count > 1)
|
bool hasRequestedSeason = seasonsForVoice.Any(s => s.Number == requestedSeason);
|
||||||
|
if (hasRequestedSeason)
|
||||||
{
|
{
|
||||||
// Always show season list for multi-season voices to keep filter correct
|
voiceLink = $"{host}/makhno?imdb_id={imdb_id}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&year={year}&serial=1&season={requestedSeason}&t={i}";
|
||||||
voiceLink = $"{host}/makhno?imdb_id={imdb_id}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&year={year}&serial=1&season=-1&t={i}";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int onlySeason = seasonsForVoice[0].Number;
|
voiceLink = $"{host}/makhno?imdb_id={imdb_id}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&year={year}&serial=1&season=-1&t={i}";
|
||||||
voiceLink = $"{host}/makhno?imdb_id={imdb_id}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&year={year}&serial=1&season={onlySeason}&t={i}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isActive = selectedVoice == i.ToString();
|
bool isActive = selectedVoice == i.ToString();
|
||||||
voice_tpl.Append(voiceName, isActive, voiceLink);
|
voice_tpl.Append(voiceName, isActive, voiceLink);
|
||||||
}
|
}
|
||||||
@ -294,17 +301,14 @@ namespace Makhno
|
|||||||
var seasonsForVoice = GetSeasonsWithNumbers(selectedVoiceData);
|
var seasonsForVoice = GetSeasonsWithNumbers(selectedVoiceData);
|
||||||
if (seasonsForVoice.Count > 0)
|
if (seasonsForVoice.Count > 0)
|
||||||
{
|
{
|
||||||
int effectiveSeasonNumber = seasonsForVoice.Any(s => s.Number == requestedSeason)
|
bool hasRequestedSeason = seasonsForVoice.Any(s => s.Number == requestedSeason);
|
||||||
? requestedSeason
|
if (!hasRequestedSeason)
|
||||||
: seasonsForVoice.Min(s => s.Number);
|
|
||||||
|
|
||||||
if (effectiveSeasonNumber != season)
|
|
||||||
{
|
{
|
||||||
string redirectUrl = $"{host}/makhno?imdb_id={imdb_id}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&year={year}&serial=1&season={effectiveSeasonNumber}&t={voiceIndex}";
|
string redirectUrl = $"{host}/makhno?imdb_id={imdb_id}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&year={year}&serial=1&season=-1&t={voiceIndex}";
|
||||||
return UpdateService.Validate(Redirect(redirectUrl));
|
return UpdateService.Validate(Redirect(redirectUrl));
|
||||||
}
|
}
|
||||||
|
|
||||||
var selectedSeason = seasonsForVoice.First(s => s.Number == effectiveSeasonNumber).Season;
|
var selectedSeason = seasonsForVoice.First(s => s.Number == requestedSeason).Season;
|
||||||
var sortedEpisodes = selectedSeason.Episodes.OrderBy(e => ExtractEpisodeNumber(e.Title)).ToList();
|
var sortedEpisodes = selectedSeason.Episodes.OrderBy(e => ExtractEpisodeNumber(e.Title)).ToList();
|
||||||
|
|
||||||
for (int i = 0; i < sortedEpisodes.Count; i++)
|
for (int i = 0; i < sortedEpisodes.Count; i++)
|
||||||
@ -316,7 +320,7 @@ namespace Makhno
|
|||||||
episode_tpl.Append(
|
episode_tpl.Append(
|
||||||
episode.Title,
|
episode.Title,
|
||||||
title ?? original_title,
|
title ?? original_title,
|
||||||
effectiveSeasonNumber.ToString(),
|
requestedSeason.ToString(),
|
||||||
(i + 1).ToString("D2"),
|
(i + 1).ToString("D2"),
|
||||||
streamUrl
|
streamUrl
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user