From 4825337f3b4ba7064e83f75c12abf44ff30ab6d7 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Sun, 16 Dec 2018 18:55:05 -0800 Subject: Put default language subtitles at end of list to work around browser bug when too many languages present --- youtube/watch.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/youtube/watch.py b/youtube/watch.py index 0f70635..5515616 100644 --- a/youtube/watch.py +++ b/youtube/watch.py @@ -180,18 +180,23 @@ subtitles_tag_template = Template(''' def subtitles_html(info): result = '' default_found = False + default = '' for language, formats in info['subtitles'].items(): for format in formats: if format['ext'] == 'vtt': - if language == settings.subtitles_language: - default_found = True - result += subtitles_tag_template.substitute( + append = subtitles_tag_template.substitute( src = html.escape('/' + format['url']), label = html.escape(language), srclang = html.escape(language), default = 'default' if language == settings.subtitles_language and settings.subtitles_mode > 0 else '', ) + if language == settings.subtitles_language: + default_found = True + default = append + else: + result += append break + result += default try: formats = info['automatic_captions'][settings.subtitles_language] except KeyError: -- cgit v1.2.3