[extractor/youtube] Determine audio language using automatic captions

pull/7353/head
pukkandan 2 years ago
parent 0a5d7c39e1
commit ff9b0e071f
No known key found for this signature in database
GPG Key ID: 7EEE9E1E817D0A39

@ -4312,9 +4312,13 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
continue continue
trans_code += f'-{lang_code}' trans_code += f'-{lang_code}'
trans_name += format_field(lang_name, None, ' from %s') trans_name += format_field(lang_name, None, ' from %s')
if lang_code == f'a-{orig_trans_code}':
# Set audio language based on original subtitles
for f in formats:
if f.get('acodec') != 'none' and not f.get('language'):
f['language'] = orig_trans_code
# Add an "-orig" label to the original language so that it can be distinguished. # Add an "-orig" label to the original language so that it can be distinguished.
# The subs are returned without "-orig" as well for compatibility # The subs are returned without "-orig" as well for compatibility
if lang_code == f'a-{orig_trans_code}':
process_language( process_language(
automatic_captions, base_url, f'{trans_code}-orig', f'{trans_name} (Original)', {}) automatic_captions, base_url, f'{trans_code}-orig', f'{trans_name} (Original)', {})
# Setting tlang=lang returns damaged subtitles. # Setting tlang=lang returns damaged subtitles.

Loading…
Cancel
Save