[youtube] Differentiate descriptive audio by language code

Related: #2677
This commit is contained in:
pukkandan 2022-02-12 02:13:17 +05:30
parent 0c8d9e5fec
commit ab6df717d1
No known key found for this signature in database
GPG key ID: 7EEE9E1E817D0A39

View file

@ -3006,13 +3006,17 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
tbr = float_or_none(
fmt.get('averageBitrate') or fmt.get('bitrate'), 1000)
language_preference = (
10 if audio_track.get('audioIsDefault') and 10
else -10 if 'descriptive' in (audio_track.get('displayName') or '').lower() and -10
else -1)
dct = {
'asr': int_or_none(fmt.get('audioSampleRate')),
'filesize': int_or_none(fmt.get('contentLength')),
'format_id': itag,
'format_note': join_nonempty(
'%s%s' % (audio_track.get('displayName') or '',
' (default)' if audio_track.get('audioIsDefault') else ''),
' (default)' if language_preference > 0 else ''),
fmt.get('qualityLabel') or quality.replace('audio_quality_', ''),
throttled and 'THROTTLED', delim=', '),
'source_preference': -10 if throttled else -1,
@ -3022,8 +3026,9 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'tbr': tbr,
'url': fmt_url,
'width': int_or_none(fmt.get('width')),
'language': audio_track.get('id', '').split('.')[0],
'language_preference': 1 if audio_track.get('audioIsDefault') else -1,
'language': join_nonempty(audio_track.get('id', '').split('.')[0],
'desc' if language_preference < -1 else ''),
'language_preference': language_preference,
}
mime_mobj = re.match(
r'((?:[^/]+)/(?:[^;]+))(?:;\s*codecs="([^"]+)")?', fmt.get('mimeType') or '')