aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/arte.py
diff options
context:
space:
mode:
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-10-21 14:40:06 +0200
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-10-21 14:42:30 +0200
commit182a107877786516f612535a9ad8db5d7487e9e0 (patch)
tree33b61a3c3780c616c1c02183509e4d5d9d43bc51 /youtube_dl/extractor/arte.py
parent8c51aa6506c85f3826b55c35a1ebf470bd4ebe3a (diff)
[arte] Set the format_note and the format_id fields (closes #1628)
Diffstat (limited to 'youtube_dl/extractor/arte.py')
-rw-r--r--youtube_dl/extractor/arte.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/youtube_dl/extractor/arte.py b/youtube_dl/extractor/arte.py
index 5ee8a67b1..d8e32f187 100644
--- a/youtube_dl/extractor/arte.py
+++ b/youtube_dl/extractor/arte.py
@@ -174,12 +174,27 @@ class ArteTVPlus7IE(InfoExtractor):
# Some formats use the m3u8 protocol
formats = filter(lambda f: f.get('videoFormat') != 'M3U8', formats)
# We order the formats by quality
- formats = sorted(formats, key=lambda f: int(f.get('height',-1)))
+ formats = list(formats) # in python3 filter returns an iterator
+ if re.match(r'[A-Z]Q', formats[0]['quality']) is not None:
+ sort_key = lambda f: ['HQ', 'MQ', 'EQ', 'SQ'].index(f['quality'])
+ else:
+ sort_key = lambda f: int(f.get('height',-1))
+ formats = sorted(formats, key=sort_key)
# Prefer videos without subtitles in the same language
formats = sorted(formats, key=lambda f: re.match(r'VO(F|A)-STM\1', f.get('versionCode', '')) is None)
# Pick the best quality
def _format(format_info):
+ quality = format_info['quality']
+ m_quality = re.match(r'\w*? - (\d*)p', quality)
+ if m_quality is not None:
+ quality = m_quality.group(1)
+ if format_info.get('versionCode') is not None:
+ format_id = u'%s-%s' % (quality, format_info['versionCode'])
+ else:
+ format_id = quality
info = {
+ 'format_id': format_id,
+ 'format_note': format_info.get('versionLibelle'),
'width': format_info.get('width'),
'height': format_info.get('height'),
}
@@ -192,8 +207,6 @@ class ArteTVPlus7IE(InfoExtractor):
info['ext'] = determine_ext(info['url'])
return info
info_dict['formats'] = [_format(f) for f in formats]
- # TODO: Remove when #980 has been merged
- info_dict.update(info_dict['formats'][-1])
return info_dict