]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/dfb.py
Completely change project name to yt-dlp (#85)
[yt-dlp.git] / yt_dlp / extractor / dfb.py
CommitLineData
74aa18f6
JMF
1from __future__ import unicode_literals
2
3import re
4
5from .common import InfoExtractor
ddcdc684 6from ..utils import unified_strdate
74aa18f6
JMF
7
8
9class DFBIE(InfoExtractor):
10 IE_NAME = 'tv.dfb.de'
ddcdc684 11 _VALID_URL = r'https?://tv\.dfb\.de/video/(?P<display_id>[^/]+)/(?P<id>\d+)'
74aa18f6
JMF
12
13 _TEST = {
eae89f92 14 'url': 'http://tv.dfb.de/video/u-19-em-stimmen-zum-spiel-gegen-russland/11633/',
65a3bfb3 15 'md5': 'ac0f98a52a330f700b4b3034ad240649',
74aa18f6 16 'info_dict': {
eae89f92 17 'id': '11633',
ddcdc684 18 'display_id': 'u-19-em-stimmen-zum-spiel-gegen-russland',
65a3bfb3 19 'ext': 'mp4',
eae89f92
S
20 'title': 'U 19-EM: Stimmen zum Spiel gegen Russland',
21 'upload_date': '20150714',
74aa18f6
JMF
22 },
23 }
24
25 def _real_extract(self, url):
65a3bfb3 26 display_id, video_id = re.match(self._VALID_URL, url).groups()
74aa18f6 27
74aa18f6
JMF
28 player_info = self._download_xml(
29 'http://tv.dfb.de/server/hd_video.php?play=%s' % video_id,
ddcdc684 30 display_id)
74aa18f6 31 video_info = player_info.find('video')
65a3bfb3 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))
19dbaeec 48 self._sort_formats(formats)
74aa18f6
JMF
49
50 return {
51 'id': video_id,
ddcdc684 52 'display_id': display_id,
74aa18f6 53 'title': video_info.find('title').text,
65a3bfb3 54 'thumbnail': 'http://tv.dfb.de/images/%s_640x360.jpg' % video_id,
ddcdc684 55 'upload_date': unified_strdate(video_info.find('time_date').text),
6c1b0c0e 56 'formats': formats,
74aa18f6 57 }