1
0
mirror of https://github.com/l1ving/youtube-dl synced 2024-12-31 01:12:51 +08:00

[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

View File

@ -61,18 +61,25 @@ 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)
if original_ext == 'f4m': format_id = '%s-%s' % (quality, item.attrib['protocol'])
full_url += '?hdcore=3.4.0' # Without this, you get a 403 error if original_ext == 'f4m':
formats.append({ formats.extend(self._extract_f4m_formats(
'url': full_url, full_url + '?hdcore=3.4.0', video_id, f4m_id=format_id))
'ext': 'mp4' if original_ext == 'm3u8' else original_ext, elif original_ext == 'm3u8':
'format_id': '%s-%s' % (quality, item.attrib['protocol']), formats.extend(self._extract_m3u8_formats(
'preference': 0 if 'HD' in quality else -1, 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': format_id,
'quality': 0 if 'HD' in quality else -1,
'preference': 1,
})
self._sort_formats(formats) self._sort_formats(formats)