aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-07-18 04:19:43 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-07-31 02:20:11 +0530
commit07b47084ba1f041ce5eee005c7a6eea676e3728c (patch)
tree9bed6edc34d5221073abd8ba685eaa91874e0794
parent4f547d6d2cdedc80e65a0a16532f98145c7244df (diff)
downloadhypervideo-pre-07b47084ba1f041ce5eee005c7a6eea676e3728c.tar.lz
hypervideo-pre-07b47084ba1f041ce5eee005c7a6eea676e3728c.tar.xz
hypervideo-pre-07b47084ba1f041ce5eee005c7a6eea676e3728c.zip
[extractor/youtube] Parse translated subtitles only when requested
Closes #4274
-rw-r--r--yt_dlp/extractor/youtube.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py
index c60e5ca53..2a9d113a5 100644
--- a/yt_dlp/extractor/youtube.py
+++ b/yt_dlp/extractor/youtube.py
@@ -3621,6 +3621,9 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'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 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
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')