aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2023-06-14 19:08:46 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2023-06-17 01:43:03 +0530
commitff9b0e071ffae5543cc309e6f9e647ac51e5846e (patch)
treee8716b6458108c5deab8727c224a95ca49ddec10
parent0a5d7c39e17bb9bd50c9db42bcad40eb82d7f784 (diff)
downloadhypervideo-pre-ff9b0e071ffae5543cc309e6f9e647ac51e5846e.tar.lz
hypervideo-pre-ff9b0e071ffae5543cc309e6f9e647ac51e5846e.tar.xz
hypervideo-pre-ff9b0e071ffae5543cc309e6f9e647ac51e5846e.zip
[extractor/youtube] Determine audio language using automatic captions
-rw-r--r--yt_dlp/extractor/youtube.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py
index 47ad1da76..606f24d04 100644
--- a/yt_dlp/extractor/youtube.py
+++ b/yt_dlp/extractor/youtube.py
@@ -4312,9 +4312,13 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
continue
trans_code += f'-{lang_code}'
trans_name += format_field(lang_name, None, ' from %s')
- # Add an "-orig" label to the original language so that it can be distinguished.
- # The subs are returned without "-orig" as well for compatibility
if lang_code == f'a-{orig_trans_code}':
+ # Set audio language based on original subtitles
+ for f in formats:
+ if f.get('acodec') != 'none' and not f.get('language'):
+ f['language'] = orig_trans_code
+ # Add an "-orig" label to the original language so that it can be distinguished.
+ # The subs are returned without "-orig" as well for compatibility
process_language(
automatic_captions, base_url, f'{trans_code}-orig', f'{trans_name} (Original)', {})
# Setting tlang=lang returns damaged subtitles.