aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2023-06-19 14:09:26 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2023-06-21 06:10:38 +0530
commit51a07b0dca4c079d58311c19b6d1c097c24bb021 (patch)
tree2032346287a53be63b2e7317f54b429de1f4763c
parenteedda5252c05327748dede204a8fccafa0288118 (diff)
downloadhypervideo-pre-51a07b0dca4c079d58311c19b6d1c097c24bb021.tar.lz
hypervideo-pre-51a07b0dca4c079d58311c19b6d1c097c24bb021.tar.xz
hypervideo-pre-51a07b0dca4c079d58311c19b6d1c097c24bb021.zip
[extractor/youtube] Prioritize premium formats
Closes #7283
-rw-r--r--yt_dlp/extractor/youtube.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py
index 606f24d04..4cbf0115c 100644
--- a/yt_dlp/extractor/youtube.py
+++ b/yt_dlp/extractor/youtube.py
@@ -3848,6 +3848,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
f'{video_id}: Some formats are possibly damaged. They will be deprioritized', only_once=True)
client_name = fmt.get(STREAMING_DATA_CLIENT_NAME)
+ name = fmt.get('qualityLabel') or quality.replace('audio_quality_', '') or ''
dct = {
'asr': int_or_none(fmt.get('audioSampleRate')),
'filesize': int_or_none(fmt.get('contentLength')),
@@ -3855,15 +3856,15 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'format_note': join_nonempty(
join_nonempty(audio_track.get('displayName'),
language_preference > 0 and ' (default)', delim=''),
- fmt.get('qualityLabel') or quality.replace('audio_quality_', ''),
- fmt.get('isDrc') and 'DRC',
+ name, fmt.get('isDrc') and 'DRC',
try_get(fmt, lambda x: x['projectionType'].replace('RECTANGULAR', '').lower()),
try_get(fmt, lambda x: x['spatialAudioType'].replace('SPATIAL_AUDIO_TYPE_', '').lower()),
throttled and 'THROTTLED', is_damaged and 'DAMAGED',
(self.get_param('verbose') or all_formats) and client_name,
delim=', '),
# Format 22 is likely to be damaged. See https://github.com/yt-dlp/yt-dlp/issues/3372
- 'source_preference': -10 if throttled else -5 if itag == '22' else -1,
+ 'source_preference': ((-10 if throttled else -5 if itag == '22' else -1)
+ + (100 if 'Premium' in name else 0)),
'fps': int_or_none(fmt.get('fps')) or None,
'audio_channels': fmt.get('audioChannels'),
'height': height,