A feature-rich command-line audio/video downloader
[extractor/youtube] Determine audio language using automatic captions
pukkandanff9b0e071ffa
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.pyindex 47ad1da76c..606f24d04d 100644--- a/yt_dlp/extractor/youtube.py+++ b/yt_dlp/extractor/youtube.py@@ -4312,9 +4312,13 @@ class YoutubeIE(YoutubeBaseInfoExtractor):continuetrans_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 compatibilityif 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 compatibilityprocess_language(automatic_captions, base_url, f'{trans_code}-orig', f'{trans_name} (Original)', {})# Setting tlang=lang returns damaged subtitles.