mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 06:10:12 +01:00
[formatsort] Remove misuse of 'preference'
'preference' is to be used only when the format is better that ALL qualities of a lower preference irrespective of ANY sorting order the user requests. See deezer.py for correct use of this In the older sorting method, `preference`, `quality` and `language_preference` were functionally almost equivalent. So these disparities doesn't really matter there Also, despite what the documentation says, the default for `preference` was actually 0 and not -1. I have tried to correct this and also account for it when converting `preference` to `quality`
This commit is contained in:
parent
dca3ff4a5e
commit
f983b87567
|
@ -66,7 +66,7 @@ def _parse_video_data(self, video_data):
|
|||
if original_filename.startswith('s3://') and not s3_extracted:
|
||||
formats.append({
|
||||
'format_id': 'original',
|
||||
'preference': 1,
|
||||
'quality': 1,
|
||||
'url': original_filename.replace('s3://', 'https://s3.amazonaws.com/'),
|
||||
})
|
||||
s3_extracted = True
|
||||
|
|
|
@ -129,10 +129,6 @@ def _real_extract(self, url):
|
|||
if all([f.get('acodec') == 'none' for f in m3u8_formats]):
|
||||
continue
|
||||
for f in m3u8_formats:
|
||||
if f.get('acodec') == 'none':
|
||||
f['preference'] = -40
|
||||
elif f.get('vcodec') == 'none':
|
||||
f['preference'] = -50
|
||||
height = f.get('height')
|
||||
if not height:
|
||||
continue
|
||||
|
@ -150,7 +146,7 @@ def _real_extract(self, url):
|
|||
'height': int_or_none(s.get('height')),
|
||||
'filesize': int_or_none(s.get('filesize')),
|
||||
'url': s_url,
|
||||
'preference': -1,
|
||||
'quality': -10,
|
||||
})
|
||||
self._sort_formats(formats)
|
||||
|
||||
|
|
|
@ -150,7 +150,6 @@ def _real_extract(self, url):
|
|||
|
||||
format = {
|
||||
'format_id': format_id,
|
||||
'preference': -10 if f.get('videoFormat') == 'M3U8' else None,
|
||||
'language_preference': lang_pref,
|
||||
'format_note': '%s, %s' % (f.get('versionCode'), f.get('versionLibelle')),
|
||||
'width': int_or_none(f.get('width')),
|
||||
|
|
|
@ -69,12 +69,10 @@ def _real_extract(self, url):
|
|||
'vcodec': 'none',
|
||||
}
|
||||
if ext == 'mp3':
|
||||
fmt['preference'] = 0
|
||||
fmt['acodec'] = 'mp3'
|
||||
fmt['abr'] = 96
|
||||
fmt['asr'] = 44100
|
||||
elif ext == 'mp4':
|
||||
fmt['preference'] = 1
|
||||
fmt['acodec'] = 'aac'
|
||||
fmt['abr'] = 96
|
||||
fmt['asr'] = 44100
|
||||
|
|
|
@ -203,7 +203,7 @@ def _real_extract(self, url):
|
|||
formats.append({
|
||||
'url': backup_url,
|
||||
# backup URLs have lower priorities
|
||||
'preference': -2 if 'hd.mp4' in backup_url else -3,
|
||||
'quality': -2 if 'hd.mp4' in backup_url else -3,
|
||||
})
|
||||
|
||||
for a_format in formats:
|
||||
|
|
|
@ -23,7 +23,7 @@ def _extract_bokecc_formats(self, webpage, video_id, format_id=None):
|
|||
formats = [{
|
||||
'format_id': format_id,
|
||||
'url': quality.find('./copy').attrib['playurl'],
|
||||
'preference': int(quality.attrib['value']),
|
||||
'quality': int(quality.attrib['value']),
|
||||
} for quality in info_xml.findall('./video/quality')]
|
||||
|
||||
self._sort_formats(formats)
|
||||
|
|
|
@ -47,7 +47,7 @@ def _real_extract(self, url):
|
|||
quality = 'high' if '_high' in video_url else 'low'
|
||||
formats.append({
|
||||
'url': video_url,
|
||||
'preference': 10 if quality == 'high' else 0,
|
||||
'quality': 10 if quality == 'high' else 0,
|
||||
'format_note': quality,
|
||||
'format_id': '%s-%s' % (quality, determine_ext(video_url)),
|
||||
})
|
||||
|
|
|
@ -82,7 +82,7 @@ def _real_extract(self, url):
|
|||
f.update({
|
||||
'ext': 'mp4',
|
||||
# hls skips fragments, preferring rtmp
|
||||
'preference': -1,
|
||||
'quality': -10,
|
||||
})
|
||||
else:
|
||||
continue
|
||||
|
|
|
@ -89,7 +89,7 @@ def _real_extract(self, url):
|
|||
# the secret extracted from ya function in http://player.canalplus.fr/common/js/canalPlayer.js
|
||||
'url': format_url + '?secret=pqzerjlsmdkjfoiuerhsdlfknaes',
|
||||
'format_id': format_id,
|
||||
'preference': preference(format_id),
|
||||
'quality': preference(format_id),
|
||||
})
|
||||
self._sort_formats(formats)
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ def _real_extract(self, url):
|
|||
'url': video_url,
|
||||
'format_id': 'http',
|
||||
'quality': quality,
|
||||
'preference': -1,
|
||||
'source_preference': -10
|
||||
})
|
||||
|
||||
hls_url = try_get(data, lambda x: x['hls_url'], compat_str)
|
||||
|
|
|
@ -1384,11 +1384,11 @@ class FormatSort:
|
|||
'order': ('m4a', 'aac', 'mp3', 'ogg', 'opus', 'webm', '', 'none'),
|
||||
'order_free': ('opus', 'ogg', 'webm', 'm4a', 'mp3', 'aac', '', 'none')},
|
||||
'hidden': {'visible': False, 'forced': True, 'type': 'extractor', 'max': -1000},
|
||||
'ie_pref': {'priority': True, 'type': 'extractor', 'field': 'extractor_preference'},
|
||||
'ie_pref': {'priority': True, 'type': 'extractor'},
|
||||
'hasvid': {'priority': True, 'field': 'vcodec', 'type': 'boolean', 'not_in_list': ('none',)},
|
||||
'hasaud': {'field': 'acodec', 'type': 'boolean', 'not_in_list': ('none',)},
|
||||
'lang': {'priority': True, 'convert': 'ignore', 'field': 'language_preference'},
|
||||
'quality': {'convert': 'float_none'},
|
||||
'lang': {'priority': True, 'convert': 'ignore', 'type': 'extractor', 'field': 'language_preference'},
|
||||
'quality': {'convert': 'float_none', 'type': 'extractor'},
|
||||
'filesize': {'convert': 'bytes'},
|
||||
'fs_approx': {'convert': 'bytes', 'field': 'filesize_approx'},
|
||||
'id': {'convert': 'string', 'field': 'format_id'},
|
||||
|
@ -1399,7 +1399,7 @@ class FormatSort:
|
|||
'vbr': {'convert': 'float_none'},
|
||||
'abr': {'convert': 'float_none'},
|
||||
'asr': {'convert': 'float_none'},
|
||||
'source': {'convert': 'ignore', 'field': 'source_preference'},
|
||||
'source': {'convert': 'ignore', 'type': 'extractor', 'field': 'source_preference'},
|
||||
|
||||
'codec': {'type': 'combined', 'field': ('vcodec', 'acodec')},
|
||||
'br': {'type': 'combined', 'field': ('tbr', 'vbr', 'abr'), 'same_limit': True},
|
||||
|
@ -1543,7 +1543,7 @@ def add_item(field, reverse, closest, limit_text):
|
|||
def print_verbose_info(self, to_screen):
|
||||
to_screen('[debug] Sort order given by user: %s' % ','.join(self._sort_user))
|
||||
if self._sort_extractor:
|
||||
to_screen('[debug] Sort order given by extractor: %s' % ','.join(self._sort_extractor))
|
||||
to_screen('[debug] Sort order given by extractor: %s' % ', '.join(self._sort_extractor))
|
||||
to_screen('[debug] Formats sorted by: %s' % ', '.join(['%s%s%s' % (
|
||||
'+' if self._get_field_setting(field, 'reverse') else '', field,
|
||||
'%s%s(%s)' % ('~' if self._get_field_setting(field, 'closest') else ':',
|
||||
|
@ -1560,7 +1560,7 @@ def _calculate_field_preference_from_value(self, format, field, type, value):
|
|||
if type == 'extractor':
|
||||
maximum = self._get_field_setting(field, 'max')
|
||||
if value is None or (maximum is not None and value >= maximum):
|
||||
value = 0
|
||||
value = -1
|
||||
elif type == 'boolean':
|
||||
in_list = self._get_field_setting(field, 'in_list')
|
||||
not_in_list = self._get_field_setting(field, 'not_in_list')
|
||||
|
@ -1693,7 +1693,7 @@ def _sleep(self, timeout, video_id, msg_template=None):
|
|||
self.to_screen(msg)
|
||||
time.sleep(timeout)
|
||||
|
||||
def _extract_f4m_formats(self, manifest_url, video_id, preference=None, f4m_id=None,
|
||||
def _extract_f4m_formats(self, manifest_url, video_id, preference=None, quality=None, f4m_id=None,
|
||||
transform_source=lambda s: fix_xml_ampersands(s).strip(),
|
||||
fatal=True, m3u8_id=None, data=None, headers={}, query={}):
|
||||
manifest = self._download_xml(
|
||||
|
@ -1708,10 +1708,10 @@ def _extract_f4m_formats(self, manifest_url, video_id, preference=None, f4m_id=N
|
|||
return []
|
||||
|
||||
return self._parse_f4m_formats(
|
||||
manifest, manifest_url, video_id, preference=preference, f4m_id=f4m_id,
|
||||
manifest, manifest_url, video_id, preference=preference, quality=quality, f4m_id=f4m_id,
|
||||
transform_source=transform_source, fatal=fatal, m3u8_id=m3u8_id)
|
||||
|
||||
def _parse_f4m_formats(self, manifest, manifest_url, video_id, preference=None, f4m_id=None,
|
||||
def _parse_f4m_formats(self, manifest, manifest_url, video_id, preference=None, quality=None, f4m_id=None,
|
||||
transform_source=lambda s: fix_xml_ampersands(s).strip(),
|
||||
fatal=True, m3u8_id=None):
|
||||
if not isinstance(manifest, compat_etree_Element) and not fatal:
|
||||
|
@ -1776,7 +1776,7 @@ def _parse_f4m_formats(self, manifest, manifest_url, video_id, preference=None,
|
|||
ext = determine_ext(manifest_url)
|
||||
if ext == 'f4m':
|
||||
f4m_formats = self._extract_f4m_formats(
|
||||
manifest_url, video_id, preference=preference, f4m_id=f4m_id,
|
||||
manifest_url, video_id, preference=preference, quality=quality, f4m_id=f4m_id,
|
||||
transform_source=transform_source, fatal=fatal)
|
||||
# Sometimes stream-level manifest contains single media entry that
|
||||
# does not contain any quality metadata (e.g. http://matchtv.ru/#live-player).
|
||||
|
@ -1796,7 +1796,7 @@ def _parse_f4m_formats(self, manifest, manifest_url, video_id, preference=None,
|
|||
elif ext == 'm3u8':
|
||||
formats.extend(self._extract_m3u8_formats(
|
||||
manifest_url, video_id, 'mp4', preference=preference,
|
||||
m3u8_id=m3u8_id, fatal=fatal))
|
||||
quality=quality, m3u8_id=m3u8_id, fatal=fatal))
|
||||
continue
|
||||
formats.append({
|
||||
'format_id': format_id,
|
||||
|
@ -1809,22 +1809,24 @@ def _parse_f4m_formats(self, manifest, manifest_url, video_id, preference=None,
|
|||
'height': height,
|
||||
'vcodec': vcodec,
|
||||
'preference': preference,
|
||||
'quality': quality,
|
||||
})
|
||||
return formats
|
||||
|
||||
def _m3u8_meta_format(self, m3u8_url, ext=None, preference=None, m3u8_id=None):
|
||||
def _m3u8_meta_format(self, m3u8_url, ext=None, preference=None, quality=None, m3u8_id=None):
|
||||
return {
|
||||
'format_id': '-'.join(filter(None, [m3u8_id, 'meta'])),
|
||||
'url': m3u8_url,
|
||||
'ext': ext,
|
||||
'protocol': 'm3u8',
|
||||
'preference': preference - 100 if preference else -100,
|
||||
'quality': quality,
|
||||
'resolution': 'multiple',
|
||||
'format_note': 'Quality selection URL',
|
||||
}
|
||||
|
||||
def _extract_m3u8_formats(self, m3u8_url, video_id, ext=None,
|
||||
entry_protocol='m3u8', preference=None,
|
||||
entry_protocol='m3u8', preference=None, quality=None,
|
||||
m3u8_id=None, note=None, errnote=None,
|
||||
fatal=True, live=False, data=None, headers={},
|
||||
query={}):
|
||||
|
@ -1842,10 +1844,10 @@ def _extract_m3u8_formats(self, m3u8_url, video_id, ext=None,
|
|||
|
||||
return self._parse_m3u8_formats(
|
||||
m3u8_doc, m3u8_url, ext=ext, entry_protocol=entry_protocol,
|
||||
preference=preference, m3u8_id=m3u8_id, live=live)
|
||||
preference=preference, quality=quality, m3u8_id=m3u8_id, live=live)
|
||||
|
||||
def _parse_m3u8_formats(self, m3u8_doc, m3u8_url, ext=None,
|
||||
entry_protocol='m3u8', preference=None,
|
||||
entry_protocol='m3u8', preference=None, quality=None,
|
||||
m3u8_id=None, live=False):
|
||||
if '#EXT-X-FAXS-CM:' in m3u8_doc: # Adobe Flash Access
|
||||
return []
|
||||
|
@ -1883,6 +1885,7 @@ def _parse_m3u8_formats(self, m3u8_doc, m3u8_url, ext=None,
|
|||
'ext': ext,
|
||||
'protocol': entry_protocol,
|
||||
'preference': preference,
|
||||
'quality': quality,
|
||||
}]
|
||||
|
||||
groups = {}
|
||||
|
@ -1911,6 +1914,7 @@ def extract_media(x_media_line):
|
|||
'ext': ext,
|
||||
'protocol': entry_protocol,
|
||||
'preference': preference,
|
||||
'quality': quality,
|
||||
}
|
||||
if media_type == 'AUDIO':
|
||||
f['vcodec'] = 'none'
|
||||
|
@ -1970,6 +1974,7 @@ def build_stream_name():
|
|||
'fps': float_or_none(last_stream_inf.get('FRAME-RATE')),
|
||||
'protocol': entry_protocol,
|
||||
'preference': preference,
|
||||
'quality': quality,
|
||||
}
|
||||
resolution = last_stream_inf.get('RESOLUTION')
|
||||
if resolution:
|
||||
|
@ -2677,7 +2682,7 @@ def _parse_ism_formats(self, ism_doc, ism_url, ism_id=None):
|
|||
})
|
||||
return formats
|
||||
|
||||
def _parse_html5_media_entries(self, base_url, webpage, video_id, m3u8_id=None, m3u8_entry_protocol='m3u8', mpd_id=None, preference=None):
|
||||
def _parse_html5_media_entries(self, base_url, webpage, video_id, m3u8_id=None, m3u8_entry_protocol='m3u8', mpd_id=None, preference=None, quality=None):
|
||||
def absolute_url(item_url):
|
||||
return urljoin(base_url, item_url)
|
||||
|
||||
|
@ -2700,7 +2705,7 @@ def _media_formats(src, cur_media_type, type_info={}):
|
|||
formats = self._extract_m3u8_formats(
|
||||
full_url, video_id, ext='mp4',
|
||||
entry_protocol=m3u8_entry_protocol, m3u8_id=m3u8_id,
|
||||
preference=preference, fatal=False)
|
||||
preference=preference, quality=quality, fatal=False)
|
||||
elif ext == 'mpd':
|
||||
is_plain_url = False
|
||||
formats = self._extract_mpd_formats(
|
||||
|
|
|
@ -87,7 +87,7 @@ def _real_extract(self, url):
|
|||
'filesize': int_or_none(item.get('size')),
|
||||
'vcodec': 'none' if kind == 'audio' else None,
|
||||
'quality': quality_key(quality),
|
||||
'preference': preference_key(HTML5),
|
||||
'source_preference': preference_key(HTML5),
|
||||
})
|
||||
|
||||
iphone_url = file_versions.get(IPHONE, {}).get('url')
|
||||
|
@ -95,7 +95,7 @@ def _real_extract(self, url):
|
|||
formats.append({
|
||||
'url': iphone_url,
|
||||
'format_id': IPHONE,
|
||||
'preference': preference_key(IPHONE),
|
||||
'source_preference': preference_key(IPHONE),
|
||||
})
|
||||
|
||||
mobile_url = file_versions.get(MOBILE, {}).get('audio_url')
|
||||
|
@ -103,7 +103,7 @@ def _real_extract(self, url):
|
|||
formats.append({
|
||||
'url': mobile_url,
|
||||
'format_id': '%s-audio' % MOBILE,
|
||||
'preference': preference_key(MOBILE),
|
||||
'source_preference': preference_key(MOBILE),
|
||||
})
|
||||
|
||||
self._sort_formats(formats)
|
||||
|
|
|
@ -473,15 +473,11 @@ def _real_extract(self, url):
|
|||
stream.get('url'), video_id, stream.get('format'),
|
||||
audio_lang, hardsub_lang)
|
||||
for f in vrv_formats:
|
||||
if not hardsub_lang:
|
||||
f['preference'] = 1
|
||||
language_preference = 0
|
||||
if audio_lang == language:
|
||||
language_preference += 1
|
||||
if hardsub_lang == language:
|
||||
language_preference += 1
|
||||
if language_preference:
|
||||
f['language_preference'] = language_preference
|
||||
f['language_preference'] = 1 if audio_lang == language else 0
|
||||
f['quality'] = (
|
||||
1 if not hardsub_lang
|
||||
else 0 if hardsub_lang == language
|
||||
else -1)
|
||||
formats.extend(vrv_formats)
|
||||
if not formats:
|
||||
available_fmts = []
|
||||
|
|
|
@ -82,6 +82,7 @@ def _parse_flv(self, metadata):
|
|||
'play_path': remove_end(audio.get('url'), '.flv'),
|
||||
'ext': 'flv',
|
||||
'vcodec': 'none',
|
||||
'quality': 1,
|
||||
'format_id': audio.get('code'),
|
||||
})
|
||||
slide_video_path = xpath_text(metadata, './slideVideo', fatal=True)
|
||||
|
@ -91,7 +92,6 @@ def _parse_flv(self, metadata):
|
|||
'ext': 'flv',
|
||||
'format_note': 'slide deck video',
|
||||
'quality': -2,
|
||||
'preference': -2,
|
||||
'format_id': 'slides',
|
||||
'acodec': 'none',
|
||||
})
|
||||
|
@ -102,7 +102,6 @@ def _parse_flv(self, metadata):
|
|||
'ext': 'flv',
|
||||
'format_note': 'speaker video',
|
||||
'quality': -1,
|
||||
'preference': -1,
|
||||
'format_id': 'speaker',
|
||||
})
|
||||
return formats
|
||||
|
|
|
@ -242,7 +242,7 @@ def decrypt_uri(e):
|
|||
elif target == 'HLS':
|
||||
formats.extend(self._extract_m3u8_formats(
|
||||
uri, video_id, 'mp4', entry_protocol='m3u8_native',
|
||||
preference=preference, m3u8_id=format_id,
|
||||
quality=preference, m3u8_id=format_id,
|
||||
fatal=False))
|
||||
else:
|
||||
bitrate = link.get('Bitrate')
|
||||
|
@ -254,7 +254,7 @@ def decrypt_uri(e):
|
|||
'tbr': int_or_none(bitrate),
|
||||
'ext': link.get('FileFormat'),
|
||||
'vcodec': 'none' if kind == 'AudioResource' else None,
|
||||
'preference': preference,
|
||||
'quality': preference,
|
||||
})
|
||||
subtitles_list = asset.get('SubtitlesList') or asset.get('Subtitleslist')
|
||||
if isinstance(subtitles_list, list):
|
||||
|
|
|
@ -154,7 +154,7 @@ def extract_source(source_url, source_id=None):
|
|||
'tbr': int(mobj.group(3)),
|
||||
})
|
||||
if source_id == 'mezzanine':
|
||||
f['preference'] = 1
|
||||
f['quality'] = 1
|
||||
formats.append(f)
|
||||
|
||||
links = clip.get('links', {})
|
||||
|
|
|
@ -619,7 +619,7 @@ def parse_attachment(attachment, key='media'):
|
|||
formats.append({
|
||||
'format_id': '%s_%s_%s' % (format_id, quality, src_type),
|
||||
'url': src,
|
||||
'preference': preference,
|
||||
'quality': preference,
|
||||
})
|
||||
extract_dash_manifest(f[0], formats)
|
||||
subtitles_src = f[0].get('subtitles_src')
|
||||
|
|
|
@ -104,7 +104,7 @@ def _real_extract(self, url):
|
|||
'tbr': tbr,
|
||||
'source_preference': quality(f.get('name')),
|
||||
# quality metadata of http formats may be incorrect
|
||||
'preference': -1,
|
||||
'preference': -10,
|
||||
})
|
||||
# m3u8 URL format is reverse engineered from [1] (search for
|
||||
# master.m3u8). dashEdges (that is currently balancer-vod.1tv.ru)
|
||||
|
|
|
@ -88,7 +88,7 @@ def _real_extract(self, url):
|
|||
formats.append({
|
||||
'format_id': stream_type,
|
||||
'url': stream['_content'],
|
||||
'preference': preference(stream_type),
|
||||
'quality': preference(stream_type),
|
||||
})
|
||||
self._sort_formats(formats)
|
||||
|
||||
|
|
|
@ -236,7 +236,7 @@ def _real_extract(self, url):
|
|||
if re.search(r'(?:/mp4/source/|_source\.mp4)', asset_url):
|
||||
f.update({
|
||||
'format_id': ('%s-' % format_id if format_id else '') + 'SOURCE',
|
||||
'preference': 1,
|
||||
'quality': 1,
|
||||
})
|
||||
else:
|
||||
mobj = re.search(r'/(\d+)x(\d+)/', asset_url)
|
||||
|
|
|
@ -115,7 +115,7 @@ def _real_extract(self, url):
|
|||
'vcodec': 'none',
|
||||
'ext': ext,
|
||||
'url': download_url,
|
||||
'preference': 2, # Usually better quality
|
||||
'quality': 2, # Usually better quality
|
||||
})
|
||||
self._sort_formats(formats)
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ def _real_extract(self, url):
|
|||
formats.append({
|
||||
'ext': determine_ext(mezzanine_url, 'mp4'),
|
||||
'format_id': 'mezzanine',
|
||||
'preference': 1,
|
||||
'quality': 1,
|
||||
'url': mezzanine_url,
|
||||
})
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ def _real_extract(self, url):
|
|||
gif_json, video_id, transform_source=js_to_json)
|
||||
formats.append({
|
||||
'format_id': 'gif',
|
||||
'preference': -10,
|
||||
'preference': -10, # gifs are worse than videos
|
||||
'width': width,
|
||||
'height': height,
|
||||
'ext': 'gif',
|
||||
|
|
|
@ -373,7 +373,7 @@ def _real_extract(self, url):
|
|||
'url': stream['m3utx'],
|
||||
'format_id': vd,
|
||||
'ext': 'mp4',
|
||||
'preference': self._FORMATS_MAP.get(vd, -1),
|
||||
'quality': self._FORMATS_MAP.get(vd, -1),
|
||||
'protocol': 'm3u8_native',
|
||||
})
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ def _get_formats(self, song_id, tolerate_ip_deny=False):
|
|||
'url': song_url,
|
||||
'format_id': file_format['format'],
|
||||
'format': file_format['format'],
|
||||
'preference': file_format['preference'],
|
||||
'quality': file_format['preference'],
|
||||
'abr': file_format.get('abr'),
|
||||
})
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ def extract_original(original_url):
|
|||
formats.append({
|
||||
'url': original_url,
|
||||
'format_id': determine_ext(original_url, None),
|
||||
'preference': 1,
|
||||
'quality': 1,
|
||||
})
|
||||
|
||||
playlist = self._parse_json(
|
||||
|
|
|
@ -175,7 +175,7 @@ def _extract_info(self, pc, mobile, i, referer):
|
|||
formats.append({
|
||||
'url': media_url,
|
||||
'format_id': format_id,
|
||||
'preference': -1,
|
||||
'quality': -10,
|
||||
'ext': ext,
|
||||
})
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ def _real_extract(self, url):
|
|||
formats.append({
|
||||
'format_id': format_id,
|
||||
'url': orig_url,
|
||||
'preference': 1,
|
||||
'quality': 1,
|
||||
})
|
||||
self._sort_formats(formats)
|
||||
info_dict['formats'] = formats
|
||||
|
|
|
@ -84,7 +84,7 @@ def _parse_smil_formats(self, smil, smil_url, video_id, namespace=None, f4m_para
|
|||
'format_id': 'smil_%d' % tbr,
|
||||
'ext': 'flv',
|
||||
'tbr': tbr,
|
||||
'preference': -1000,
|
||||
'preference': -1000, # Strictly inferior than all other formats?
|
||||
})
|
||||
return formats
|
||||
|
||||
|
|
|
@ -137,11 +137,11 @@ def _real_extract(self, url):
|
|||
if ext == 'm3u8':
|
||||
formats.extend(self._extract_m3u8_formats(
|
||||
video_url, video_id, 'mp4', entry_protocol='m3u8_native',
|
||||
preference=0, m3u8_id='HLS', fatal=False))
|
||||
quality=1, m3u8_id='HLS', fatal=False))
|
||||
elif ext == 'f4m':
|
||||
formats.extend(self._extract_f4m_formats(
|
||||
video_url + '?hdcore=3.7.0&plugin=aasp-3.7.0.39.44', video_id,
|
||||
preference=0, f4m_id='HDS', fatal=False))
|
||||
quality=1, f4m_id='HDS', fatal=False))
|
||||
else:
|
||||
media_type = xpath_text(asset, './mediaType', 'media type', default='MP4')
|
||||
vbr = int_or_none(xpath_text(asset, './bitrateVideo', 'vbr'), 1000)
|
||||
|
|
|
@ -206,7 +206,7 @@ def _real_extract(self, url):
|
|||
# disprefer 'secondary' streams
|
||||
if stream_type != 0:
|
||||
for fmt in stream_formats:
|
||||
fmt['preference'] = -1
|
||||
fmt['quality'] = -10
|
||||
|
||||
thumbnail_url = Stream.get('ThumbnailUrl')
|
||||
if thumbnail_url:
|
||||
|
|
|
@ -132,7 +132,7 @@ def _real_extract(self, url):
|
|||
'width': int_or_none(file_.get('width')),
|
||||
'height': int_or_none(file_.get('height')),
|
||||
'vbr': int_or_none(self._search_regex(r'_(\d+)\.mp4', format_url, 'vbr', default=None)),
|
||||
'preference': 1 if format_id == '1001' else None,
|
||||
'quality': 1 if format_id == '1001' else None,
|
||||
})
|
||||
self._sort_formats(formats)
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ def _real_extract(self, url):
|
|||
'tbr': int_or_none(s.get('label')),
|
||||
'ext': 'mp4',
|
||||
'format_id': format_id,
|
||||
'preference': -100 if '.smil' in s['file'] else 0,
|
||||
'preference': -100 if '.smil' in s['file'] else 0, # Strictly inferior than all other formats?
|
||||
})
|
||||
self._sort_formats(formats)
|
||||
|
||||
|
|
|
@ -303,7 +303,7 @@ def _extract_video(self, video, team, extract_all=True):
|
|||
formats.append({
|
||||
'format_id': 'source',
|
||||
'url': source_url,
|
||||
'preference': 1,
|
||||
'quality': 1,
|
||||
})
|
||||
|
||||
m3u8_url = video.get('m3u8')
|
||||
|
|
|
@ -183,7 +183,7 @@ def _real_extract(self, url):
|
|||
'filesize': int_or_none(fmt.get('filesize')),
|
||||
'format_note': qualities[format_id].get('quality_name'),
|
||||
'quality': qualities[format_id].get('priority'),
|
||||
'preference': preference,
|
||||
'language_preference': preference,
|
||||
})
|
||||
|
||||
self._sort_formats(formats)
|
||||
|
|
|
@ -425,7 +425,7 @@ def add_format_url(format_url):
|
|||
stream_url, video_id, fatal=False)
|
||||
# f4m downloader downloads only piece of live stream
|
||||
for f4m_format in f4m_formats:
|
||||
f4m_format['preference'] = -1
|
||||
f4m_format['preference'] = -5
|
||||
formats.extend(f4m_formats)
|
||||
elif stream_type == 'hls':
|
||||
formats.extend(self._extract_m3u8_formats(
|
||||
|
|
|
@ -62,7 +62,7 @@ def _real_extract(self, url):
|
|||
m3u8_url = compat_urlparse.urljoin('http://video.n-tv.de', vdata['videoM3u8'])
|
||||
formats.extend(self._extract_m3u8_formats(
|
||||
m3u8_url, video_id, ext='mp4', entry_protocol='m3u8_native',
|
||||
preference=0, m3u8_id='hls', fatal=False))
|
||||
quality=1, m3u8_id='hls', fatal=False))
|
||||
self._sort_formats(formats)
|
||||
|
||||
return {
|
||||
|
|
|
@ -55,7 +55,7 @@ def _real_extract(self, url):
|
|||
formats.append({
|
||||
'url': http_template % q,
|
||||
'format_id': q,
|
||||
'preference': preference(q),
|
||||
'quality': preference(q),
|
||||
})
|
||||
self._sort_formats(formats)
|
||||
else:
|
||||
|
|
|
@ -78,7 +78,7 @@ def _real_extract(self, url):
|
|||
update_url_query(
|
||||
'https://%s/hls/%s/index.m3u8'
|
||||
% (edge_ep, channel_id), params),
|
||||
channel_id, 'mp4', preference=preference,
|
||||
channel_id, 'mp4', quality=preference,
|
||||
m3u8_id='-'.join(format_id), fatal=False))
|
||||
continue
|
||||
elif tech_type == 'video/mp4' or tech_label == 'MP4':
|
||||
|
@ -88,7 +88,7 @@ def _real_extract(self, url):
|
|||
'https://%s/mp4/%s.mp4' % (edge_ep, channel_id),
|
||||
params),
|
||||
'format_id': '-'.join(format_id),
|
||||
'preference': preference,
|
||||
'quality': preference,
|
||||
})
|
||||
else:
|
||||
# rtmp format does not seem to work
|
||||
|
|
|
@ -150,7 +150,7 @@ def _real_extract(self, url):
|
|||
ext = 'mp4'
|
||||
# Some streams have mp3 audio which does not play
|
||||
# well with ffmpeg filter aac_adtstoasc
|
||||
preference = -1
|
||||
preference = -10
|
||||
elif format_ == 'adobe': # f4m manifest fails with 404 in 80% of requests
|
||||
continue
|
||||
else: # Other formats not supported yet
|
||||
|
|
|
@ -121,7 +121,7 @@ def _real_extract(self, url):
|
|||
% (details['prefix'], mid, details['ext'], vkey, guid),
|
||||
'format': format_id,
|
||||
'format_id': format_id,
|
||||
'preference': details['preference'],
|
||||
'quality': details['preference'],
|
||||
'abr': details.get('abr'),
|
||||
})
|
||||
self._check_formats(formats, mid)
|
||||
|
|
|
@ -43,7 +43,7 @@ def _real_extract(self, url):
|
|||
'format_id': fm[0],
|
||||
'url': fm[1],
|
||||
'vcodec': 'none',
|
||||
'preference': i,
|
||||
'quality': i,
|
||||
}
|
||||
for i, fm in
|
||||
enumerate(re.findall(r"([a-z0-9]+)\s*:\s*'([^']+)'", formats_str))
|
||||
|
|
|
@ -93,7 +93,7 @@ def _real_extract(self, url):
|
|||
'flash_version': 'LNX 11,2,202,429',
|
||||
'rtmp_conn': rtmp_conn,
|
||||
'no_resume': True,
|
||||
'preference': 1,
|
||||
'quality': 1,
|
||||
})
|
||||
|
||||
m3u8_url = video_info.get('streamurl_hls')
|
||||
|
|
|
@ -45,7 +45,7 @@ def _real_extract(self, url):
|
|||
if file_key:
|
||||
formats.append({
|
||||
'url': 'https://cdn-ondemand.rtp.pt' + file_key,
|
||||
'preference': 1,
|
||||
'quality': 1,
|
||||
})
|
||||
self._sort_formats(formats)
|
||||
else:
|
||||
|
|
|
@ -180,11 +180,11 @@ def _real_extract(self, url):
|
|||
'rtmp_live': True,
|
||||
'ext': 'flv',
|
||||
'vbr': int(quality),
|
||||
'preference': preference,
|
||||
'quality': preference,
|
||||
}
|
||||
elif transport == 'm3u8':
|
||||
formats.extend(self._extract_m3u8_formats(
|
||||
url, video_id, 'mp4', preference=preference, m3u8_id='hls'))
|
||||
url, video_id, 'mp4', quality=preference, m3u8_id='hls'))
|
||||
continue
|
||||
else:
|
||||
fmt = {
|
||||
|
|
|
@ -99,7 +99,7 @@ def _real_extract(self, url):
|
|||
formats.append({
|
||||
'format_id': quality_id,
|
||||
'url': update_url_query(file_api, {'vid': file_id}),
|
||||
'preference': preference(quality_id),
|
||||
'quality': preference(quality_id),
|
||||
'ext': 'mp4',
|
||||
})
|
||||
self._sort_formats(formats)
|
||||
|
|
|
@ -422,7 +422,7 @@ def _extract_info_dict(self, info, full_title=None, secret_token=None):
|
|||
'ext': urlhandle_detect_ext(urlh) or 'mp3',
|
||||
'filesize': int_or_none(urlh.headers.get('Content-Length')),
|
||||
'url': format_url,
|
||||
'preference': 10,
|
||||
'quality': 10,
|
||||
})
|
||||
|
||||
def invalid_url(url):
|
||||
|
|
|
@ -89,7 +89,7 @@ def _real_extract(self, url):
|
|||
formats.append({
|
||||
'format_id': format_id,
|
||||
'url': asset_url,
|
||||
'preference': preference(quality),
|
||||
'quality': preference(quality),
|
||||
'ext': 'flv' if protocol == 'RTMP' else None,
|
||||
})
|
||||
self._sort_formats(formats)
|
||||
|
|
|
@ -92,7 +92,7 @@ def _real_extract(self, url):
|
|||
if aformat:
|
||||
format['acodec'] = aformat['acodec']
|
||||
format['abr'] = aformat['abr']
|
||||
format['preference'] = aformat['preference']
|
||||
format['quality'] = aformat['preference']
|
||||
format['ext'] = 'm4a'
|
||||
|
||||
self._sort_formats(formats)
|
||||
|
|
|
@ -70,7 +70,7 @@ def _real_extract(self, url):
|
|||
formats.append({
|
||||
'url': format_url,
|
||||
'format_id': f.get('label'),
|
||||
'preference': preference(f.get('label')),
|
||||
'quality': preference(f.get('label')),
|
||||
'ext': ext,
|
||||
})
|
||||
urls.append(format_url)
|
||||
|
|
|
@ -57,7 +57,7 @@ def _real_extract(self, url):
|
|||
'app': rtmp.group('app'),
|
||||
'player_url': 'http://p.jwpcdn.com/6/10/jwplayer.flash.swf',
|
||||
'page_url': 'http://www.telemb.be',
|
||||
'preference': -1,
|
||||
'preference': -10,
|
||||
})
|
||||
formats.append(fmt)
|
||||
self._sort_formats(formats)
|
||||
|
|
|
@ -133,11 +133,6 @@ def _real_extract(self, url):
|
|||
'vcodec': 'none' if height == 0 else None,
|
||||
'width': width,
|
||||
})
|
||||
for f in formats:
|
||||
if f.get('acodec') == 'none':
|
||||
f['preference'] = -40
|
||||
elif f.get('vcodec') == 'none':
|
||||
f['preference'] = -50
|
||||
# It seems like this would be correctly handled by default
|
||||
# However, unless someone can confirm this, the old
|
||||
# behaviour is being kept as-is
|
||||
|
|
|
@ -110,7 +110,6 @@ def _real_extract(self, url):
|
|||
'format_id': format_id,
|
||||
'url': f_url,
|
||||
'quality': quality(format_id),
|
||||
'preference': -1,
|
||||
})
|
||||
self._sort_formats(formats)
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ def _real_extract(self, url):
|
|||
'ext': f['FileType'],
|
||||
'format_id': '%s-%s' % (f['FileType'], f.get('Quality', '')),
|
||||
'url': 'http://p3urort.blob.core.windows.net/tracks/%s' % f['FileRef'],
|
||||
'preference': 3 if f['FileType'] == 'mp3' else 2,
|
||||
'quality': 3 if f['FileType'] == 'mp3' else 2,
|
||||
} for f in s['Files']]
|
||||
self._sort_formats(formats)
|
||||
e = {
|
||||
|
|
|
@ -181,6 +181,7 @@ def _real_extract(self, url):
|
|||
'url': format_url,
|
||||
'width': int_or_none(f.get('width')),
|
||||
'height': int_or_none(f.get('height')),
|
||||
# Clips should never be prefered over full video
|
||||
'preference': 0 if f.get('type', '').endswith(
|
||||
'clip') else 1,
|
||||
})
|
||||
|
|
|
@ -179,16 +179,9 @@ def _parse_config(self, config, video_id):
|
|||
formats.append({
|
||||
'format_id': 'live-archive-source',
|
||||
'url': live_archive_source_url,
|
||||
'preference': 1,
|
||||
'quality': 10,
|
||||
})
|
||||
|
||||
# Reduntant code! This is already done in common.py
|
||||
# for f in formats:
|
||||
# if f.get('vcodec') == 'none':
|
||||
# f['preference'] = -50
|
||||
# elif f.get('acodec') == 'none':
|
||||
# f['preference'] = -40
|
||||
|
||||
subtitles = {}
|
||||
text_tracks = config['request'].get('text_tracks')
|
||||
if text_tracks:
|
||||
|
@ -251,7 +244,7 @@ def _extract_original_format(self, url, video_id):
|
|||
'height': int_or_none(source_file.get('height')),
|
||||
'filesize': parse_filesize(source_file.get('size')),
|
||||
'format_id': source_name,
|
||||
'preference': 1,
|
||||
'quality': 1,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ def _real_extract(self, url):
|
|||
f = {
|
||||
'url': source_url,
|
||||
'format_id': 'http',
|
||||
'preference': 1,
|
||||
'quality': 1,
|
||||
}
|
||||
if 'audio' in source_url:
|
||||
f.update({
|
||||
|
|
|
@ -62,7 +62,7 @@ def _extract_media(self, embed_config):
|
|||
'format_id': format_id,
|
||||
'url': aurl,
|
||||
'tbr': int_or_none(a.get('bitrate')) or None,
|
||||
'preference': 1 if atype == 'original' else None,
|
||||
'quality': 1 if atype == 'original' else None,
|
||||
}
|
||||
if display_name == 'Audio':
|
||||
f.update({
|
||||
|
|
|
@ -54,7 +54,7 @@ def get(meta, default=NO_DEFAULT, fatal=True):
|
|||
if determine_ext(format_url) == 'm3u8':
|
||||
formats.extend(self._extract_m3u8_formats(
|
||||
format_url, video_id, 'mp4', entry_protocol='m3u8_native',
|
||||
preference=1, m3u8_id='hls', fatal=False))
|
||||
quality=1, m3u8_id='hls', fatal=False))
|
||||
else:
|
||||
format_id = mobj.group('id')
|
||||
if format_id:
|
||||
|
|
|
@ -93,7 +93,7 @@ def _extract_video_info(self, partner_id, video_id):
|
|||
formats.append({
|
||||
'url': link.get('href'),
|
||||
'format_id': link.get('rel'),
|
||||
'preference': 1,
|
||||
'quality': 1,
|
||||
})
|
||||
|
||||
thumbnails = [{
|
||||
|
|
|
@ -182,7 +182,7 @@ def _extract_formats(self, cid, video_id, record_id=None, is_live=False):
|
|||
else:
|
||||
assert False
|
||||
for this_format in this_formats:
|
||||
this_format['preference'] = preference
|
||||
this_format['quality'] = preference
|
||||
formats.extend(this_formats)
|
||||
self._sort_formats(formats)
|
||||
return formats
|
||||
|
|
Loading…
Reference in New Issue
Block a user