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

master
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 = [] formats = []
for item in video_data.findall('./Playlists/Playlist') + video_data.findall('./Downloads/Download'): 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'] quality = url_node.attrib['quality']
full_url = url_node.text full_url = url_node.text
original_ext = determine_ext(full_url) original_ext = determine_ext(full_url)
format_id = '%s-%s' % (quality, item.attrib['protocol'])
if original_ext == 'f4m': 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({ formats.append({
'url': full_url, 'url': full_url,
'ext': 'mp4' if original_ext == 'm3u8' else original_ext, 'ext': 'mp4' if original_ext == 'm3u8' else original_ext,
'format_id': '%s-%s' % (quality, item.attrib['protocol']), 'format_id': format_id,
'preference': 0 if 'HD' in quality else -1, 'quality': 0 if 'HD' in quality else -1,
'preference': 1,
}) })
self._sort_formats(formats) self._sort_formats(formats)