aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbashonly <88596187+bashonly@users.noreply.github.com>2024-12-13 10:21:48 +0000
committerGitHub <noreply@github.com>2024-12-13 10:21:48 +0000
commitdc3c4fddcc653989dae71fc563d82a308fc898cc (patch)
tree6c109b0266873b7b15d4eeedf0842e23d7d2778d
parent5460cd91891bf613a2065e2fc278d9903c37a127 (diff)
[ie/youtube] Prioritize original language over auto-dubbed audio (#11803)
Closes #11753 Authored by: bashonly
-rw-r--r--yt_dlp/extractor/youtube.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py
index e4904965d..fd9c7107c 100644
--- a/yt_dlp/extractor/youtube.py
+++ b/yt_dlp/extractor/youtube.py
@@ -4067,10 +4067,12 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
if height:
res_qualities[height] = quality
+ display_name = audio_track.get('displayName') or ''
+ is_original = 'original' in display_name.lower()
+ is_descriptive = 'descriptive' in display_name.lower()
is_default = audio_track.get('audioIsDefault')
- is_descriptive = 'descriptive' in (audio_track.get('displayName') or '').lower()
language_code = audio_track.get('id', '').split('.')[0]
- if language_code and is_default:
+ if language_code and (is_original or (is_default and not original_language)):
original_language = language_code
# FORMAT_STREAM_TYPE_OTF(otf=1) requires downloading the init fragment
@@ -4151,7 +4153,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'filesize': int_or_none(fmt.get('contentLength')),
'format_id': f'{itag}{"-drc" if fmt.get("isDrc") else ""}',
'format_note': join_nonempty(
- join_nonempty(audio_track.get('displayName'), is_default and ' (default)', delim=''),
+ join_nonempty(display_name, is_default and ' (default)', delim=''),
name, fmt.get('isDrc') and 'DRC',
try_get(fmt, lambda x: x['projectionType'].replace('RECTANGULAR', '').lower()),
try_get(fmt, lambda x: x['spatialAudioType'].replace('SPATIAL_AUDIO_TYPE_', '').lower()),
@@ -4170,7 +4172,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'url': fmt_url,
'width': int_or_none(fmt.get('width')),
'language': join_nonempty(language_code, 'desc' if is_descriptive else '') or None,
- 'language_preference': PREFERRED_LANG_VALUE if is_default else -10 if is_descriptive else -1,
+ 'language_preference': PREFERRED_LANG_VALUE if is_original else 5 if is_default else -10 if is_descriptive else -1,
# Strictly de-prioritize broken, damaged and 3gp formats
'preference': -20 if is_broken else -10 if is_damaged else -2 if itag == '17' else None,
}