From 5cc1fbdd6cdcbbe84da38a55ade748262ab96d7d Mon Sep 17 00:00:00 2001 From: girst Date: Tue, 21 Jul 2020 11:21:53 +0200 Subject: [PATCH] move main (non-translation) subtitles to the first slot --- app/common/common.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/common/common.py b/app/common/common.py index 90b094b..90541a9 100644 --- a/app/common/common.py +++ b/app/common/common.py @@ -261,6 +261,13 @@ def prepare_metadata(metadata): .get('captionTracks',[]) ], key=lambda cc: cc['autogenerated']) + try: # any level might not exist + # find the native language captions (assuming there is only 1 audioTrack): + main_subtitle = metadata['captions']['playerCaptionsTracklistRenderer']['audioTracks'][0]['defaultCaptionTrackIndex'] + # and move it to the first place: + subtitles.insert(0, subtitles.pop(main_subtitle)) + except: pass + def clean_url(url): # externals URLs are redirected through youtube.com/redirect, but we # may encounter internal URLs, too -- 2.39.3