From 90574ad919cd9194275fc35fcef8f846ac3ff285 Mon Sep 17 00:00:00 2001 From: baliasnyifeliks Date: Wed, 4 Feb 2026 21:38:57 +0200 Subject: [PATCH] feat(makhno): add season set validation for voice selection consistency Add logic to validate that the current voice's available seasons match the selected voice season set before generating voice links. This ensures consistent behavior when switching between voices with different season availability. --- Makhno/Controller.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Makhno/Controller.cs b/Makhno/Controller.cs index 1bff06a..810e86e 100644 --- a/Makhno/Controller.cs +++ b/Makhno/Controller.cs @@ -279,6 +279,18 @@ namespace Makhno seasonVoiceIndexForTpl = selectedVoiceIndex; } + HashSet selectedVoiceSeasonSet = null; + if (seasonVoiceIndexForTpl.HasValue) + { + selectedVoiceSeasonSet = GetSeasonsWithNumbers(playerData.Voices[seasonVoiceIndexForTpl.Value]) + .Select(s => s.Number) + .ToHashSet(); + } + else + { + selectedVoiceSeasonSet = seasonNumbers.ToHashSet(); + } + // Build season template for selected voice (if valid) to keep season list in sync when switching voices. var seasonTplForVoice = new SeasonTpl(); List seasonNumbersForTpl = seasonNumbers; @@ -327,7 +339,8 @@ namespace Makhno string voiceLink; bool hasRequestedSeason = seasonsForVoice.Any(s => s.Number == requestedSeason); - if (hasRequestedSeason) + bool sameSeasonSet = seasonsForVoice.Select(s => s.Number).ToHashSet().SetEquals(selectedVoiceSeasonSet); + if (hasRequestedSeason && sameSeasonSet) { 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}"; }