diff options
author | James Taylor <user234683@users.noreply.github.com> | 2018-12-16 18:55:05 -0800 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2018-12-16 18:55:05 -0800 |
commit | 4825337f3b4ba7064e83f75c12abf44ff30ab6d7 (patch) | |
tree | a8c13aeedeac2b645256ac6bcf38a887237fb3d5 /youtube | |
parent | 7c97a1705301219783d901332951a2f1e86ed26f (diff) | |
download | yt-local-4825337f3b4ba7064e83f75c12abf44ff30ab6d7.tar.lz yt-local-4825337f3b4ba7064e83f75c12abf44ff30ab6d7.tar.xz yt-local-4825337f3b4ba7064e83f75c12abf44ff30ab6d7.zip |
Put default language subtitles at end of list to work around browser bug when too many languages present
Diffstat (limited to 'youtube')
-rw-r--r-- | youtube/watch.py | 11 |
1 files 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: |