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