Skip to content

Commit

Permalink
Улучшен выбор языковой дорожки для языков с уточнением региона, для к…
Browse files Browse the repository at this point in the history
…оторых нет отдельной настройки.
  • Loading branch information
v0lt committed Dec 30, 2024
1 parent 0f1d645 commit 5ce1586
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions src/apps/mplayerc/PlayerYouTube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 5ce1586

Please sign in to comment.