]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/dfb.py
Prepare upload.
[youtubedl] / youtube_dl / extractor / dfb.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import unified_strdate
7
8
9 class DFBIE(InfoExtractor):
10 IE_NAME = 'tv.dfb.de'
11 _VALID_URL = r'https?://tv\.dfb\.de/video/(?P<display_id>[^/]+)/(?P<id>\d+)'
12
13 _TEST = {
14 'url': 'http://tv.dfb.de/video/u-19-em-stimmen-zum-spiel-gegen-russland/11633/',
15 'md5': 'ac0f98a52a330f700b4b3034ad240649',
16 'info_dict': {
17 'id': '11633',
18 'display_id': 'u-19-em-stimmen-zum-spiel-gegen-russland',
19 'ext': 'mp4',
20 'title': 'U 19-EM: Stimmen zum Spiel gegen Russland',
21 'upload_date': '20150714',
22 },
23 }
24
25 def _real_extract(self, url):
26 display_id, video_id = re.match(self._VALID_URL, url).groups()
27
28 player_info = self._download_xml(
29 'http://tv.dfb.de/server/hd_video.php?play=%s' % video_id,
30 display_id)
31 video_info = player_info.find('video')
32 stream_access_url = self._proto_relative_url(video_info.find('url').text.strip())
33
34 formats = []
35 # see http://tv.dfb.de/player/js/ajax.js for the method to extract m3u8 formats
36 for sa_url in (stream_access_url, stream_access_url + '&area=&format=iphone'):
37 stream_access_info = self._download_xml(sa_url, display_id)
38 token_el = stream_access_info.find('token')
39 manifest_url = token_el.attrib['url'] + '?' + 'hdnea=' + token_el.attrib['auth']
40 if '.f4m' in manifest_url:
41 formats.extend(self._extract_f4m_formats(
42 manifest_url + '&hdcore=3.2.0',
43 display_id, f4m_id='hds', fatal=False))
44 else:
45 formats.extend(self._extract_m3u8_formats(
46 manifest_url, display_id, 'mp4',
47 'm3u8_native', m3u8_id='hls', fatal=False))
48 self._sort_formats(formats)
49
50 return {
51 'id': video_id,
52 'display_id': display_id,
53 'title': video_info.find('title').text,
54 'thumbnail': 'http://tv.dfb.de/images/%s_640x360.jpg' % video_id,
55 'upload_date': unified_strdate(video_info.find('time_date').text),
56 'formats': formats,
57 }