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