feat(uaflix): normalize voice names in aggregated structure

Add NormalizeUaflixVoiceNames method to standardize voice naming
by converting "Uaflix #2" or "Uaflix #3" to "Uaflix" when base name
is missing. This ensures consistent voice naming across the system.

The method checks for existing voice keys and renames them
appropriately to maintain a single canonical voice name.
This commit is contained in:
baliasnyifeliks 2026-01-14 09:18:51 +02:00
parent 768c916b1d
commit 60d7b15dc1

View File

@ -500,6 +500,8 @@ namespace Uaflix
return null;
}
NormalizeUaflixVoiceNames(structure);
// Edge Case 9: Перевірка наявності епізодів у озвучках
bool hasEpisodes = structure.Voices.Values.Any(v => v.Seasons.Values.Any(s => s.Any()));
if (!hasEpisodes)
@ -888,6 +890,38 @@ namespace Uaflix
return result;
}
private void NormalizeUaflixVoiceNames(SerialAggregatedStructure structure)
{
const string baseName = "Uaflix";
const string zetName = "Uaflix #2";
const string ashdiName = "Uaflix #3";
if (structure == null || structure.Voices == null || structure.Voices.Count == 0)
return;
bool hasBase = structure.Voices.ContainsKey(baseName);
bool hasZet = structure.Voices.ContainsKey(zetName);
bool hasAshdi = structure.Voices.ContainsKey(ashdiName);
if (hasBase)
return;
if (hasZet && !hasAshdi)
{
var voice = structure.Voices[zetName];
voice.DisplayName = baseName;
structure.Voices.Remove(zetName);
structure.Voices[baseName] = voice;
}
else if (hasAshdi && !hasZet)
{
var voice = structure.Voices[ashdiName];
voice.DisplayName = baseName;
structure.Voices.Remove(ashdiName);
structure.Voices[baseName] = voice;
}
}
async Task<List<(string link, string quality)>> ParseAllZetvideoSources(string iframeUrl)
{
var result = new List<(string link, string quality)>();