mirror of
https://github.com/lampame/lampac-ukraine.git
synced 2026-04-16 09:22:21 +00:00
fix(makhno): handle null season items when filtering by season number
The code now properly handles cases where the requested season is not found in the voice seasons list by checking if the match has a valid Season before accessing its properties. This prevents potential null reference exceptions when generating season links.
This commit is contained in:
parent
55ee3b644d
commit
ac9242308f
@ -242,17 +242,19 @@ namespace Makhno
|
||||
if (seasonVoiceIndex.HasValue)
|
||||
{
|
||||
var voiceSeasonsForT = GetSeasonsWithNumbers(playerData.Voices[seasonVoiceIndex.Value]);
|
||||
seasonItem = voiceSeasonsForT.FirstOrDefault(s => s.Number == seasonNumber);
|
||||
var match = voiceSeasonsForT.FirstOrDefault(s => s.Number == seasonNumber);
|
||||
seasonItem = match.Season != null ? match : ((Season Season, int Number)?)null;
|
||||
}
|
||||
else
|
||||
{
|
||||
seasonItem = voiceSeasons
|
||||
var match = voiceSeasons
|
||||
.SelectMany(v => v.Seasons)
|
||||
.FirstOrDefault(s => s.Number == seasonNumber);
|
||||
seasonItem = match.Season != null ? match : ((Season Season, int Number)?)null;
|
||||
}
|
||||
|
||||
string voiceParam = seasonVoiceIndex.HasValue ? $"&t={seasonVoiceIndex.Value}" : string.Empty;
|
||||
string seasonName = seasonItem.Season?.Title ?? $"Сезон {seasonNumber}";
|
||||
string seasonName = seasonItem.HasValue ? seasonItem.Value.Season?.Title ?? $"Сезон {seasonNumber}" : $"Сезон {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}";
|
||||
season_tpl.Append(seasonName, link, seasonNumber.ToString());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user