mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-03 04:55:25 +02:00
[youtube] Prefer audio stream that YouTube considers default
Fixes: https://github.com/ytdl-org/youtube-dl/issues/29864 Related: https://github.com/clsid2/mpc-hc/issues/1268
This commit is contained in:
parent
198e3a04c9
commit
26e8e04454
@ -2622,7 +2622,8 @@ def _extract_formats(self, streaming_data, video_id, player_url, is_live):
|
|||||||
'filesize': int_or_none(fmt.get('contentLength')),
|
'filesize': int_or_none(fmt.get('contentLength')),
|
||||||
'format_id': itag,
|
'format_id': itag,
|
||||||
'format_note': ', '.join(filter(None, (
|
'format_note': ', '.join(filter(None, (
|
||||||
audio_track.get('displayName'),
|
'%s%s' % (audio_track.get('displayName') or '',
|
||||||
|
' (default)' if audio_track.get('audioIsDefault') else ''),
|
||||||
fmt.get('qualityLabel') or quality.replace('audio_quality_', '')))),
|
fmt.get('qualityLabel') or quality.replace('audio_quality_', '')))),
|
||||||
'fps': int_or_none(fmt.get('fps')),
|
'fps': int_or_none(fmt.get('fps')),
|
||||||
'height': height,
|
'height': height,
|
||||||
@ -2631,6 +2632,7 @@ def _extract_formats(self, streaming_data, video_id, player_url, is_live):
|
|||||||
'url': fmt_url,
|
'url': fmt_url,
|
||||||
'width': int_or_none(fmt.get('width')),
|
'width': int_or_none(fmt.get('width')),
|
||||||
'language': audio_track.get('id', '').split('.')[0],
|
'language': audio_track.get('id', '').split('.')[0],
|
||||||
|
'language_preference': 1 if audio_track.get('audioIsDefault') else -1,
|
||||||
}
|
}
|
||||||
mime_mobj = re.match(
|
mime_mobj = re.match(
|
||||||
r'((?:[^/]+)/(?:[^;]+))(?:;\s*codecs="([^"]+)")?', fmt.get('mimeType') or '')
|
r'((?:[^/]+)/(?:[^;]+))(?:;\s*codecs="([^"]+)")?', fmt.get('mimeType') or '')
|
||||||
@ -2817,7 +2819,7 @@ def feed_entry(name):
|
|||||||
|
|
||||||
# Source is given priority since formats that throttle are given lower source_preference
|
# Source is given priority since formats that throttle are given lower source_preference
|
||||||
# When throttling issue is fully fixed, remove this
|
# When throttling issue is fully fixed, remove this
|
||||||
self._sort_formats(formats, ('quality', 'height', 'fps', 'source'))
|
self._sort_formats(formats, ('quality', 'res', 'fps', 'source', 'codec:vp9.2', 'size', 'br', 'lang'))
|
||||||
|
|
||||||
keywords = get_first(video_details, 'keywords', expected_type=list) or []
|
keywords = get_first(video_details, 'keywords', expected_type=list) or []
|
||||||
if not keywords and webpage:
|
if not keywords and webpage:
|
||||||
|
Loading…
Reference in New Issue
Block a user