From d8a58ddce7a4aaf0d525041ab3b01eb2ab2d0a41 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Fri, 8 Apr 2022 13:47:48 +0530 Subject: [PATCH] De-prioritize automatic-subtitles when no `--sub-lang` is given Closes #3314 --- yt_dlp/YoutubeDL.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index f5ea5a0b5..7af7a9fb9 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -2671,9 +2671,10 @@ class YoutubeDL(object): def process_subtitles(self, video_id, normal_subtitles, automatic_captions): """Select the requested subtitles and their format""" - available_subs = {} + available_subs, normal_sub_langs = {}, [] if normal_subtitles and self.params.get('writesubtitles'): available_subs.update(normal_subtitles) + normal_sub_langs = tuple(normal_subtitles.keys()) if automatic_captions and self.params.get('writeautomaticsub'): for lang, cap_info in automatic_captions.items(): if lang not in available_subs: @@ -2684,7 +2685,7 @@ class YoutubeDL(object): available_subs): return None - all_sub_langs = available_subs.keys() + all_sub_langs = tuple(available_subs.keys()) if self.params.get('allsubtitles', False): requested_langs = all_sub_langs elif self.params.get('subtitleslangs', False): @@ -2709,10 +2710,10 @@ class YoutubeDL(object): else: requested_langs.extend(current_langs) requested_langs = orderedSet(requested_langs) - elif 'en' in available_subs: - requested_langs = ['en'] + elif normal_sub_langs: + requested_langs = ['en'] if 'en' in normal_sub_langs else normal_sub_langs[:1] else: - requested_langs = [list(all_sub_langs)[0]] + requested_langs = ['en'] if 'en' in all_sub_langs else all_sub_langs[:1] if requested_langs: self.write_debug('Downloading subtitles: %s' % ', '.join(requested_langs))