mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-07 19:52:40 +01:00
[arte] Make sorting aware of en/es formats
This commit is contained in:
parent
44b9745000
commit
08d65046f0
@ -142,27 +142,30 @@ def _extract_from_json_url(self, json_url, video_id, lang):
|
|||||||
}
|
}
|
||||||
qfunc = qualities(['HQ', 'MQ', 'EQ', 'SQ'])
|
qfunc = qualities(['HQ', 'MQ', 'EQ', 'SQ'])
|
||||||
|
|
||||||
|
LANGS = {
|
||||||
|
'fr': 'F',
|
||||||
|
'de': 'A',
|
||||||
|
'en': 'E[ANG]',
|
||||||
|
'es': 'E[ESP]',
|
||||||
|
}
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for format_id, format_dict in player_info['VSR'].items():
|
for format_id, format_dict in player_info['VSR'].items():
|
||||||
f = dict(format_dict)
|
f = dict(format_dict)
|
||||||
versionCode = f.get('versionCode')
|
versionCode = f.get('versionCode')
|
||||||
|
langcode = LANGS.get(lang, lang)
|
||||||
langcode = {
|
lang_rexs = [r'VO?%s-' % re.escape(langcode), r'VO?.-ST%s$' % re.escape(langcode)]
|
||||||
'fr': 'F',
|
lang_pref = None
|
||||||
'de': 'A',
|
if versionCode:
|
||||||
}.get(lang, lang)
|
matched_lang_rexs = [r for r in lang_rexs if re.match(r, versionCode)]
|
||||||
lang_rexs = [r'VO?%s' % langcode, r'VO?.-ST%s' % langcode]
|
lang_pref = -10 if not matched_lang_rexs else 10 * len(matched_lang_rexs)
|
||||||
lang_pref = (
|
|
||||||
None if versionCode is None else (
|
|
||||||
10 if any(re.match(r, versionCode) for r in lang_rexs)
|
|
||||||
else -10))
|
|
||||||
source_pref = 0
|
source_pref = 0
|
||||||
if versionCode is not None:
|
if versionCode is not None:
|
||||||
# The original version with subtitles has lower relevance
|
# The original version with subtitles has lower relevance
|
||||||
if re.match(r'VO-ST(F|A)', versionCode):
|
if re.match(r'VO-ST(F|A|E)', versionCode):
|
||||||
source_pref -= 10
|
source_pref -= 10
|
||||||
# The version with sourds/mal subtitles has also lower relevance
|
# The version with sourds/mal subtitles has also lower relevance
|
||||||
elif re.match(r'VO?(F|A)-STM\1', versionCode):
|
elif re.match(r'VO?(F|A|E)-STM\1', versionCode):
|
||||||
source_pref -= 9
|
source_pref -= 9
|
||||||
format = {
|
format = {
|
||||||
'format_id': format_id,
|
'format_id': format_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user