diff --git a/youtube_dlc/extractor/adobetv.py b/youtube_dlc/extractor/adobetv.py index 80060f037..bccdf9ca4 100644 --- a/youtube_dlc/extractor/adobetv.py +++ b/youtube_dlc/extractor/adobetv.py @@ -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 diff --git a/youtube_dlc/extractor/arcpublishing.py b/youtube_dlc/extractor/arcpublishing.py index 48b83ce58..fd2c795ae 100644 --- a/youtube_dlc/extractor/arcpublishing.py +++ b/youtube_dlc/extractor/arcpublishing.py @@ -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) diff --git a/youtube_dlc/extractor/arte.py b/youtube_dlc/extractor/arte.py index ca41aaea9..5b38b20dd 100644 --- a/youtube_dlc/extractor/arte.py +++ b/youtube_dlc/extractor/arte.py @@ -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')), diff --git a/youtube_dlc/extractor/beatport.py b/youtube_dlc/extractor/beatport.py index e60709417..ae9c1a739 100644 --- a/youtube_dlc/extractor/beatport.py +++ b/youtube_dlc/extractor/beatport.py @@ -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 diff --git a/youtube_dlc/extractor/bilibili.py b/youtube_dlc/extractor/bilibili.py index d8a4a224f..b04077750 100644 --- a/youtube_dlc/extractor/bilibili.py +++ b/youtube_dlc/extractor/bilibili.py @@ -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: diff --git a/youtube_dlc/extractor/bokecc.py b/youtube_dlc/extractor/bokecc.py index 6017e8344..14840bd28 100644 --- a/youtube_dlc/extractor/bokecc.py +++ b/youtube_dlc/extractor/bokecc.py @@ -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) diff --git a/youtube_dlc/extractor/bpb.py b/youtube_dlc/extractor/bpb.py index 07833532e..8f6ef3cf0 100644 --- a/youtube_dlc/extractor/bpb.py +++ b/youtube_dlc/extractor/bpb.py @@ -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)), }) diff --git a/youtube_dlc/extractor/cammodels.py b/youtube_dlc/extractor/cammodels.py index 1eb81b75e..eb2a8b4c6 100644 --- a/youtube_dlc/extractor/cammodels.py +++ b/youtube_dlc/extractor/cammodels.py @@ -82,7 +82,7 @@ def _real_extract(self, url): f.update({ 'ext': 'mp4', # hls skips fragments, preferring rtmp - 'preference': -1, + 'quality': -10, }) else: continue diff --git a/youtube_dlc/extractor/canalplus.py b/youtube_dlc/extractor/canalplus.py index 51c11cb7e..1132ce4a7 100644 --- a/youtube_dlc/extractor/canalplus.py +++ b/youtube_dlc/extractor/canalplus.py @@ -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) diff --git a/youtube_dlc/extractor/cctv.py b/youtube_dlc/extractor/cctv.py index c76f361c6..9b8612138 100644 --- a/youtube_dlc/extractor/cctv.py +++ b/youtube_dlc/extractor/cctv.py @@ -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) diff --git a/youtube_dlc/extractor/common.py b/youtube_dlc/extractor/common.py index b8e84089b..ae1b34912 100644 --- a/youtube_dlc/extractor/common.py +++ b/youtube_dlc/extractor/common.py @@ -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( diff --git a/youtube_dlc/extractor/coub.py b/youtube_dlc/extractor/coub.py index 6ea03e65c..eba6b73ba 100644 --- a/youtube_dlc/extractor/coub.py +++ b/youtube_dlc/extractor/coub.py @@ -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) diff --git a/youtube_dlc/extractor/crunchyroll.py b/youtube_dlc/extractor/crunchyroll.py index 47892544f..d670c12c1 100644 --- a/youtube_dlc/extractor/crunchyroll.py +++ b/youtube_dlc/extractor/crunchyroll.py @@ -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 = [] diff --git a/youtube_dlc/extractor/dispeak.py b/youtube_dlc/extractor/dispeak.py index 22bdc5635..b1c02ca2b 100644 --- a/youtube_dlc/extractor/dispeak.py +++ b/youtube_dlc/extractor/dispeak.py @@ -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 diff --git a/youtube_dlc/extractor/drtv.py b/youtube_dlc/extractor/drtv.py index c0036adb6..7bb15f8d4 100644 --- a/youtube_dlc/extractor/drtv.py +++ b/youtube_dlc/extractor/drtv.py @@ -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): diff --git a/youtube_dlc/extractor/espn.py b/youtube_dlc/extractor/espn.py index 6cf05e6da..d4a66c29f 100644 --- a/youtube_dlc/extractor/espn.py +++ b/youtube_dlc/extractor/espn.py @@ -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', {}) diff --git a/youtube_dlc/extractor/facebook.py b/youtube_dlc/extractor/facebook.py index cb34c59f5..7906e813c 100644 --- a/youtube_dlc/extractor/facebook.py +++ b/youtube_dlc/extractor/facebook.py @@ -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') diff --git a/youtube_dlc/extractor/firsttv.py b/youtube_dlc/extractor/firsttv.py index 28617d83c..ccad173b7 100644 --- a/youtube_dlc/extractor/firsttv.py +++ b/youtube_dlc/extractor/firsttv.py @@ -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) diff --git a/youtube_dlc/extractor/flickr.py b/youtube_dlc/extractor/flickr.py index 9f166efd4..6c82fae3c 100644 --- a/youtube_dlc/extractor/flickr.py +++ b/youtube_dlc/extractor/flickr.py @@ -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) diff --git a/youtube_dlc/extractor/go.py b/youtube_dlc/extractor/go.py index 85dc561e2..dda08ae3e 100644 --- a/youtube_dlc/extractor/go.py +++ b/youtube_dlc/extractor/go.py @@ -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) diff --git a/youtube_dlc/extractor/hearthisat.py b/youtube_dlc/extractor/hearthisat.py index 18c252012..aeb216c71 100644 --- a/youtube_dlc/extractor/hearthisat.py +++ b/youtube_dlc/extractor/hearthisat.py @@ -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) diff --git a/youtube_dlc/extractor/ign.py b/youtube_dlc/extractor/ign.py index 0d9f50ed2..c826eb3ba 100644 --- a/youtube_dlc/extractor/ign.py +++ b/youtube_dlc/extractor/ign.py @@ -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, }) diff --git a/youtube_dlc/extractor/imgur.py b/youtube_dlc/extractor/imgur.py index 4dc7b0b5c..20fe6667b 100644 --- a/youtube_dlc/extractor/imgur.py +++ b/youtube_dlc/extractor/imgur.py @@ -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', diff --git a/youtube_dlc/extractor/iqiyi.py b/youtube_dlc/extractor/iqiyi.py index 5df674daf..0d7cc65d7 100644 --- a/youtube_dlc/extractor/iqiyi.py +++ b/youtube_dlc/extractor/iqiyi.py @@ -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', }) diff --git a/youtube_dlc/extractor/kuwo.py b/youtube_dlc/extractor/kuwo.py index cc5b2a1c1..460a4252f 100644 --- a/youtube_dlc/extractor/kuwo.py +++ b/youtube_dlc/extractor/kuwo.py @@ -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'), }) diff --git a/youtube_dlc/extractor/lifenews.py b/youtube_dlc/extractor/lifenews.py index 42e263bfa..49a0a5989 100644 --- a/youtube_dlc/extractor/lifenews.py +++ b/youtube_dlc/extractor/lifenews.py @@ -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( diff --git a/youtube_dlc/extractor/limelight.py b/youtube_dlc/extractor/limelight.py index b95b001ad..c0c35511f 100644 --- a/youtube_dlc/extractor/limelight.py +++ b/youtube_dlc/extractor/limelight.py @@ -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, }) diff --git a/youtube_dlc/extractor/liveleak.py b/youtube_dlc/extractor/liveleak.py index 4ac437c8b..114556ef0 100644 --- a/youtube_dlc/extractor/liveleak.py +++ b/youtube_dlc/extractor/liveleak.py @@ -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 diff --git a/youtube_dlc/extractor/livestream.py b/youtube_dlc/extractor/livestream.py index e55b1a202..036b39023 100644 --- a/youtube_dlc/extractor/livestream.py +++ b/youtube_dlc/extractor/livestream.py @@ -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 diff --git a/youtube_dlc/extractor/mdr.py b/youtube_dlc/extractor/mdr.py index dc6aa9819..0bdd62693 100644 --- a/youtube_dlc/extractor/mdr.py +++ b/youtube_dlc/extractor/mdr.py @@ -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) diff --git a/youtube_dlc/extractor/mediasite.py b/youtube_dlc/extractor/mediasite.py index d6eb15740..c18b16eb3 100644 --- a/youtube_dlc/extractor/mediasite.py +++ b/youtube_dlc/extractor/mediasite.py @@ -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: diff --git a/youtube_dlc/extractor/msn.py b/youtube_dlc/extractor/msn.py index e59b0b7b0..9ce90a928 100644 --- a/youtube_dlc/extractor/msn.py +++ b/youtube_dlc/extractor/msn.py @@ -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) diff --git a/youtube_dlc/extractor/muenchentv.py b/youtube_dlc/extractor/muenchentv.py index 2cc2bf229..d256236d1 100644 --- a/youtube_dlc/extractor/muenchentv.py +++ b/youtube_dlc/extractor/muenchentv.py @@ -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) diff --git a/youtube_dlc/extractor/nba.py b/youtube_dlc/extractor/nba.py index fbc7adaf4..a1dc1dde7 100644 --- a/youtube_dlc/extractor/nba.py +++ b/youtube_dlc/extractor/nba.py @@ -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') diff --git a/youtube_dlc/extractor/noco.py b/youtube_dlc/extractor/noco.py index 30df905af..aec8433de 100644 --- a/youtube_dlc/extractor/noco.py +++ b/youtube_dlc/extractor/noco.py @@ -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) diff --git a/youtube_dlc/extractor/npo.py b/youtube_dlc/extractor/npo.py index 416b6acfc..ca6dbfc81 100644 --- a/youtube_dlc/extractor/npo.py +++ b/youtube_dlc/extractor/npo.py @@ -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( diff --git a/youtube_dlc/extractor/ntvde.py b/youtube_dlc/extractor/ntvde.py index 101a5374c..035582ee8 100644 --- a/youtube_dlc/extractor/ntvde.py +++ b/youtube_dlc/extractor/ntvde.py @@ -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 { diff --git a/youtube_dlc/extractor/ora.py b/youtube_dlc/extractor/ora.py index 1d42be39b..422d0b330 100644 --- a/youtube_dlc/extractor/ora.py +++ b/youtube_dlc/extractor/ora.py @@ -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: diff --git a/youtube_dlc/extractor/picarto.py b/youtube_dlc/extractor/picarto.py index 8099ef1d6..1abda865d 100644 --- a/youtube_dlc/extractor/picarto.py +++ b/youtube_dlc/extractor/picarto.py @@ -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 diff --git a/youtube_dlc/extractor/playtvak.py b/youtube_dlc/extractor/playtvak.py index 4c5f57919..84e92dda4 100644 --- a/youtube_dlc/extractor/playtvak.py +++ b/youtube_dlc/extractor/playtvak.py @@ -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 diff --git a/youtube_dlc/extractor/qqmusic.py b/youtube_dlc/extractor/qqmusic.py index 084308aeb..0106d166f 100644 --- a/youtube_dlc/extractor/qqmusic.py +++ b/youtube_dlc/extractor/qqmusic.py @@ -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) diff --git a/youtube_dlc/extractor/radiofrance.py b/youtube_dlc/extractor/radiofrance.py index a8afc0014..2b5fea945 100644 --- a/youtube_dlc/extractor/radiofrance.py +++ b/youtube_dlc/extractor/radiofrance.py @@ -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)) diff --git a/youtube_dlc/extractor/rtl2.py b/youtube_dlc/extractor/rtl2.py index 70f000ca8..d7baa3aa5 100644 --- a/youtube_dlc/extractor/rtl2.py +++ b/youtube_dlc/extractor/rtl2.py @@ -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') diff --git a/youtube_dlc/extractor/rtp.py b/youtube_dlc/extractor/rtp.py index 02986f442..f78e90e97 100644 --- a/youtube_dlc/extractor/rtp.py +++ b/youtube_dlc/extractor/rtp.py @@ -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: diff --git a/youtube_dlc/extractor/rutv.py b/youtube_dlc/extractor/rutv.py index aceb35994..e66036c79 100644 --- a/youtube_dlc/extractor/rutv.py +++ b/youtube_dlc/extractor/rutv.py @@ -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 = { diff --git a/youtube_dlc/extractor/sina.py b/youtube_dlc/extractor/sina.py index 07b766b4a..60f2dd053 100644 --- a/youtube_dlc/extractor/sina.py +++ b/youtube_dlc/extractor/sina.py @@ -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) diff --git a/youtube_dlc/extractor/soundcloud.py b/youtube_dlc/extractor/soundcloud.py index 47f68bf19..72562379b 100644 --- a/youtube_dlc/extractor/soundcloud.py +++ b/youtube_dlc/extractor/soundcloud.py @@ -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): diff --git a/youtube_dlc/extractor/srgssr.py b/youtube_dlc/extractor/srgssr.py index f63a1359a..0f4c8189c 100644 --- a/youtube_dlc/extractor/srgssr.py +++ b/youtube_dlc/extractor/srgssr.py @@ -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) diff --git a/youtube_dlc/extractor/storyfire.py b/youtube_dlc/extractor/storyfire.py index 67457cc94..19cb1ff9e 100644 --- a/youtube_dlc/extractor/storyfire.py +++ b/youtube_dlc/extractor/storyfire.py @@ -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) diff --git a/youtube_dlc/extractor/tele13.py b/youtube_dlc/extractor/tele13.py index a29a64b6d..f8a27550e 100644 --- a/youtube_dlc/extractor/tele13.py +++ b/youtube_dlc/extractor/tele13.py @@ -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) diff --git a/youtube_dlc/extractor/telemb.py b/youtube_dlc/extractor/telemb.py index 9bcac4ec0..44d5d220b 100644 --- a/youtube_dlc/extractor/telemb.py +++ b/youtube_dlc/extractor/telemb.py @@ -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) diff --git a/youtube_dlc/extractor/threeqsdn.py b/youtube_dlc/extractor/threeqsdn.py index 71aa357df..5eaa991eb 100644 --- a/youtube_dlc/extractor/threeqsdn.py +++ b/youtube_dlc/extractor/threeqsdn.py @@ -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 diff --git a/youtube_dlc/extractor/uol.py b/youtube_dlc/extractor/uol.py index 628adf219..4a2a97fa4 100644 --- a/youtube_dlc/extractor/uol.py +++ b/youtube_dlc/extractor/uol.py @@ -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) diff --git a/youtube_dlc/extractor/urort.py b/youtube_dlc/extractor/urort.py index 8f6edab4b..020425fc7 100644 --- a/youtube_dlc/extractor/urort.py +++ b/youtube_dlc/extractor/urort.py @@ -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 = { diff --git a/youtube_dlc/extractor/vidme.py b/youtube_dlc/extractor/vidme.py index 174e69cd6..a02f91731 100644 --- a/youtube_dlc/extractor/vidme.py +++ b/youtube_dlc/extractor/vidme.py @@ -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, }) diff --git a/youtube_dlc/extractor/vimeo.py b/youtube_dlc/extractor/vimeo.py index 600426197..bbb1024d9 100644 --- a/youtube_dlc/extractor/vimeo.py +++ b/youtube_dlc/extractor/vimeo.py @@ -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, } diff --git a/youtube_dlc/extractor/vzaar.py b/youtube_dlc/extractor/vzaar.py index b7d02fca3..54f88bba8 100644 --- a/youtube_dlc/extractor/vzaar.py +++ b/youtube_dlc/extractor/vzaar.py @@ -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({ diff --git a/youtube_dlc/extractor/wistia.py b/youtube_dlc/extractor/wistia.py index ae32a0a68..a170966c3 100644 --- a/youtube_dlc/extractor/wistia.py +++ b/youtube_dlc/extractor/wistia.py @@ -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({ diff --git a/youtube_dlc/extractor/xnxx.py b/youtube_dlc/extractor/xnxx.py index ac1ccc404..dd4fb54d4 100644 --- a/youtube_dlc/extractor/xnxx.py +++ b/youtube_dlc/extractor/xnxx.py @@ -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: diff --git a/youtube_dlc/extractor/xstream.py b/youtube_dlc/extractor/xstream.py index 76c91bd92..cd9c465e4 100644 --- a/youtube_dlc/extractor/xstream.py +++ b/youtube_dlc/extractor/xstream.py @@ -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 = [{ diff --git a/youtube_dlc/extractor/zattoo.py b/youtube_dlc/extractor/zattoo.py index 6bac3026e..32dcc03b1 100644 --- a/youtube_dlc/extractor/zattoo.py +++ b/youtube_dlc/extractor/zattoo.py @@ -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