From 5ce15860bbf62bb8ff75a3edfd3e380fecdf0f70 Mon Sep 17 00:00:00 2001 From: v0lt Date: Mon, 30 Dec 2024 09:37:06 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD=20?= =?UTF-8?q?=D0=B2=D1=8B=D0=B1=D0=BE=D1=80=20=D1=8F=D0=B7=D1=8B=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=D0=BE=D0=B9=20=D0=B4=D0=BE=D1=80=D0=BE=D0=B6=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D1=8F=D0=B7=D1=8B=D0=BA=D0=BE=D0=B2=20?= =?UTF-8?q?=D1=81=20=D1=83=D1=82=D0=BE=D1=87=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=D0=BC=20=D1=80=D0=B5=D0=B3=D0=B8=D0=BE=D0=BD=D0=B0,=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BA=D0=BE=D1=82=D0=BE=D1=80=D1=8B=D1=85=20?= =?UTF-8?q?=D0=BD=D0=B5=D1=82=20=D0=BE=D1=82=D0=B4=D0=B5=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA?= =?UTF-8?q?=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apps/mplayerc/PlayerYouTube.cpp | 33 +++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/apps/mplayerc/PlayerYouTube.cpp b/src/apps/mplayerc/PlayerYouTube.cpp index 34fd967789..85abab93d3 100644 --- a/src/apps/mplayerc/PlayerYouTube.cpp +++ b/src/apps/mplayerc/PlayerYouTube.cpp @@ -788,7 +788,7 @@ namespace Youtube } } - if (!streamingDataFormatListAudioWithLanguages.empty()) { + if (streamingDataFormatListAudioWithLanguages.size()) { // Removing existing audio formats without "language" tag. for (auto it = streamingDataFormatList.begin(); it != streamingDataFormatList.end();) { auto itag = std::get<0>(*it); @@ -799,16 +799,31 @@ namespace Youtube } } - auto it = streamingDataFormatListAudioWithLanguages.find("en"); - if (!s.strYoutubeAudioLang.IsEmpty()) { - it = streamingDataFormatListAudioWithLanguages.find(WStrToUTF8(s.strYoutubeAudioLang.GetString())); - if (it == streamingDataFormatListAudioWithLanguages.end()) { - it = streamingDataFormatListAudioWithLanguages.find("en"); + auto& audioLangs = streamingDataFormatListAudioWithLanguages; + + auto it = audioLangs.begin(); + + if (s.strYoutubeAudioLang.GetLength()) { + CStringA lang = WStrToUTF8(s.strYoutubeAudioLang.GetString()); + auto it2 = audioLangs.find(lang); + if (it2 == audioLangs.end()) { + if (lang == "en") { + it2 = audioLangs.find("en-US"); + } + else if (lang = "de") { + it2 = audioLangs.find("de-DE"); + } + else if (lang = "fr") { + it2 = audioLangs.find("fr-FR"); + } + else if (lang = "es") { + it2 = audioLangs.find("es-US"); + } } - } - if (it == streamingDataFormatListAudioWithLanguages.end()) { - it = streamingDataFormatListAudioWithLanguages.begin(); + if (it2 != audioLangs.end()) { + it = it2; + } } streamingDataFormatList.splice(streamingDataFormatList.end(), it->second);