]> jfr.im git - yt-dlp.git/commitdiff
[extractor/youtube] Parse translated subtitles only when requested
authorpukkandan <redacted>
Sun, 17 Jul 2022 22:49:43 +0000 (04:19 +0530)
committerpukkandan <redacted>
Sat, 30 Jul 2022 20:50:11 +0000 (02:20 +0530)
Closes #4274

yt_dlp/extractor/youtube.py

index c60e5ca53385de153d950bf33b34a7c23505e7a5..2a9d113a5c1b6cbfb39781b01d7fe8ea1e8aff55 100644 (file)
@@ -3621,6 +3621,9 @@ def process_language(container, base_url, lang_code, sub_name, query):
                         'name': sub_name,
                     })
 
+            # NB: Constructing the full subtitle dictionary is slow
+            get_translated_subs = 'translated_subs' not in self._configuration_arg('skip') and (
+                self.get_param('writeautomaticsub', False) or self.get_param('listsubtitles'))
             subtitles, automatic_captions = {}, {}
             for lang_code, caption_track in captions.items():
                 base_url = caption_track.get('baseUrl')
@@ -3640,7 +3643,7 @@ def process_language(container, base_url, lang_code, sub_name, query):
                         continue
                     orig_trans_code = trans_code
                     if caption_track.get('kind') != 'asr':
-                        if 'translated_subs' in self._configuration_arg('skip'):
+                        if not get_translated_subs:
                             continue
                         trans_code += f'-{lang_code}'
                         trans_name += format_field(lang_name, None, ' from %s')