1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-02 17:22:31 +01:00

[arte.tv:+7] Use original format ids to avoid duplicates

This commit is contained in:
Sergey M․ 2014-10-20 20:27:59 +07:00
parent cc98a3f096
commit d24a2b20b4

View File

@ -12,6 +12,7 @@
get_element_by_id, get_element_by_id,
compat_str, compat_str,
get_element_by_attribute, get_element_by_attribute,
int_or_none,
) )
# There are different sources of video in arte.tv, the extraction process # There are different sources of video in arte.tv, the extraction process
@ -98,7 +99,11 @@ def _extract_from_json_url(self, json_url, video_id, lang):
'thumbnail': player_info.get('programImage') or player_info.get('VTU', {}).get('IUR'), 'thumbnail': player_info.get('programImage') or player_info.get('VTU', {}).get('IUR'),
} }
all_formats = player_info['VSR'].values() all_formats = []
for format_id, format_dict in player_info['VSR'].items():
fmt = dict(format_dict)
fmt['format_id'] = format_id
all_formats.append(fmt)
# Some formats use the m3u8 protocol # Some formats use the m3u8 protocol
all_formats = list(filter(lambda f: f.get('videoFormat') != 'M3U8', all_formats)) all_formats = list(filter(lambda f: f.get('videoFormat') != 'M3U8', all_formats))
def _match_lang(f): def _match_lang(f):
@ -149,25 +154,12 @@ def sort_key(f):
) )
formats = sorted(formats, key=sort_key) formats = sorted(formats, key=sort_key)
def _format(format_info): def _format(format_info):
quality = ''
height = format_info.get('height')
if height is not None:
quality = compat_str(height)
bitrate = format_info.get('bitrate')
if bitrate is not None:
quality += '-%d' % bitrate
if format_info.get('versionCode') is not None:
format_id = '%s-%s' % (quality, format_info['versionCode'])
else:
format_id = quality
media_type = format_info.get('mediaType')
if media_type is not None:
format_id += '-%s' % media_type
info = { info = {
'format_id': format_id, 'format_id': format_info['format_id'],
'format_note': format_info.get('versionLibelle'), 'format_note': '%s, %s' % (format_info.get('versionCode'), format_info.get('versionLibelle')),
'width': format_info.get('width'), 'width': int_or_none(format_info.get('width')),
'height': height, 'height': int_or_none(format_info.get('height')),
'tbr': int_or_none(format_info.get('bitrate')),
} }
if format_info['mediaType'] == 'rtmp': if format_info['mediaType'] == 'rtmp':
info['url'] = format_info['streamer'] info['url'] = format_info['streamer']