From 60d7b15dc1bb50201f8988f3265bd7e62985f9f0 Mon Sep 17 00:00:00 2001 From: baliasnyifeliks Date: Wed, 14 Jan 2026 09:18:51 +0200 Subject: [PATCH] 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. --- Uaflix/UaflixInvoke.cs | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/Uaflix/UaflixInvoke.cs b/Uaflix/UaflixInvoke.cs index cd65b65..03c16bd 100644 --- a/Uaflix/UaflixInvoke.cs +++ b/Uaflix/UaflixInvoke.cs @@ -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> ParseAllZetvideoSources(string iframeUrl) { var result = new List<(string link, string quality)>(); @@ -985,4 +1019,4 @@ namespace Uaflix return TimeSpan.FromMinutes(ctime); } } -} \ No newline at end of file +}