mirror of
https://github.com/lampame/lampac-ukraine.git
synced 2026-04-16 09:22:21 +00:00
fix(makhno): redirect to valid season when requested season is unavailable
When a user requests a season that doesn't exist for a selected voice, the system now redirects to the first available season for that voice instead of silently using the first season. This ensures users are always directed to valid content and prevents confusion when season data is inconsistent across different voice options.
This commit is contained in:
parent
e3aa03089c
commit
097b42023c
@ -235,10 +235,12 @@ namespace Makhno
|
||||
var voice_tpl = new VoiceTpl();
|
||||
var episode_tpl = new EpisodeTpl();
|
||||
|
||||
int requestedSeason = seasonNumbers.Contains(season) ? season : seasonNumbers.First();
|
||||
|
||||
string selectedVoice = t;
|
||||
if (string.IsNullOrEmpty(selectedVoice) || !int.TryParse(selectedVoice, out _))
|
||||
{
|
||||
var voiceWithSeason = voiceSeasons.FirstOrDefault(v => v.Seasons.Any(s => s.Number == season));
|
||||
var voiceWithSeason = voiceSeasons.FirstOrDefault(v => v.Seasons.Any(s => s.Number == requestedSeason));
|
||||
selectedVoice = voiceWithSeason != null ? voiceWithSeason.Index.ToString() : voiceSeasons.First().Index.ToString();
|
||||
}
|
||||
|
||||
@ -250,8 +252,8 @@ namespace Makhno
|
||||
if (seasonsForVoice.Count == 0)
|
||||
continue;
|
||||
|
||||
int seasonNumber = seasonsForVoice.Any(s => s.Number == season)
|
||||
? season
|
||||
int seasonNumber = seasonsForVoice.Any(s => s.Number == requestedSeason)
|
||||
? requestedSeason
|
||||
: seasonsForVoice.Min(s => s.Number);
|
||||
|
||||
string voiceLink = $"{host}/makhno?imdb_id={imdb_id}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&year={year}&serial=1&season={seasonNumber}&t={i}";
|
||||
@ -265,10 +267,16 @@ namespace Makhno
|
||||
var seasonsForVoice = GetSeasonsWithNumbers(selectedVoiceData);
|
||||
if (seasonsForVoice.Count > 0)
|
||||
{
|
||||
int effectiveSeasonNumber = seasonsForVoice.Any(s => s.Number == season)
|
||||
? season
|
||||
int effectiveSeasonNumber = seasonsForVoice.Any(s => s.Number == requestedSeason)
|
||||
? requestedSeason
|
||||
: 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}";
|
||||
return UpdateService.Validate(Redirect(redirectUrl));
|
||||
}
|
||||
|
||||
var selectedSeason = seasonsForVoice.First(s => s.Number == effectiveSeasonNumber).Season;
|
||||
var sortedEpisodes = selectedSeason.Episodes.OrderBy(e => ExtractEpisodeNumber(e.Title)).ToList();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user