[srf] Extract all formats and prefer direct links over hls and hds

This commit is contained in:
Sergey M․ 2015-04-16 20:31:02 +06:00
parent c052ce6cde
commit 355c524bfa
1 changed files with 19 additions and 12 deletions

View File

@ -61,17 +61,24 @@ class SrfIE(InfoExtractor):
formats = []
for item in video_data.findall('./Playlists/Playlist') + video_data.findall('./Downloads/Download'):
url_node = item.find('url')
for url_node in item.findall('url'):
quality = url_node.attrib['quality']
full_url = url_node.text
original_ext = determine_ext(full_url)
format_id = '%s-%s' % (quality, item.attrib['protocol'])
if original_ext == 'f4m':
full_url += '?hdcore=3.4.0' # Without this, you get a 403 error
formats.extend(self._extract_f4m_formats(
full_url + '?hdcore=3.4.0', video_id, f4m_id=format_id))
elif original_ext == 'm3u8':
formats.extend(self._extract_m3u8_formats(
full_url, video_id, 'mp4', m3u8_id=format_id))
else:
formats.append({
'url': full_url,
'ext': 'mp4' if original_ext == 'm3u8' else original_ext,
'format_id': '%s-%s' % (quality, item.attrib['protocol']),
'preference': 0 if 'HD' in quality else -1,
'format_id': format_id,
'quality': 0 if 'HD' in quality else -1,
'preference': 1,
})
self._sort_formats(formats)