1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-12-05 14:47:55 +01:00
youtube-dl/youtube_dl/extractor/dfb.py

58 lines
2.2 KiB
Python
Raw Normal View History

2014-07-17 10:07:51 +02:00
from __future__ import unicode_literals
import re
from .common import InfoExtractor
2015-07-14 19:59:21 +02:00
from ..utils import unified_strdate
2014-07-17 10:07:51 +02:00
class DFBIE(InfoExtractor):
IE_NAME = 'tv.dfb.de'
2015-07-14 19:59:21 +02:00
_VALID_URL = r'https?://tv\.dfb\.de/video/(?P<display_id>[^/]+)/(?P<id>\d+)'
2014-07-17 10:07:51 +02:00
_TEST = {
2015-07-14 19:54:13 +02:00
'url': 'http://tv.dfb.de/video/u-19-em-stimmen-zum-spiel-gegen-russland/11633/',
2016-04-29 20:21:17 +02:00
'md5': 'ac0f98a52a330f700b4b3034ad240649',
2014-07-17 10:07:51 +02:00
'info_dict': {
2015-07-14 19:54:13 +02:00
'id': '11633',
2015-07-14 19:59:21 +02:00
'display_id': 'u-19-em-stimmen-zum-spiel-gegen-russland',
2016-04-29 20:21:17 +02:00
'ext': 'mp4',
2015-07-14 19:54:13 +02:00
'title': 'U 19-EM: Stimmen zum Spiel gegen Russland',
'upload_date': '20150714',
2014-07-17 10:07:51 +02:00
},
}
def _real_extract(self, url):
2016-04-29 20:21:17 +02:00
display_id, video_id = re.match(self._VALID_URL, url).groups()
2014-07-17 10:07:51 +02:00
player_info = self._download_xml(
'http://tv.dfb.de/server/hd_video.php?play=%s' % video_id,
2015-07-14 19:59:21 +02:00
display_id)
2014-07-17 10:07:51 +02:00
video_info = player_info.find('video')
2016-04-29 20:21:17 +02:00
stream_access_url = self._proto_relative_url(video_info.find('url').text.strip())
formats = []
# see http://tv.dfb.de/player/js/ajax.js for the method to extract m3u8 formats
for sa_url in (stream_access_url, stream_access_url + '&area=&format=iphone'):
stream_access_info = self._download_xml(sa_url, display_id)
token_el = stream_access_info.find('token')
manifest_url = token_el.attrib['url'] + '?' + 'hdnea=' + token_el.attrib['auth']
if '.f4m' in manifest_url:
formats.extend(self._extract_f4m_formats(
manifest_url + '&hdcore=3.2.0',
display_id, f4m_id='hds', fatal=False))
else:
formats.extend(self._extract_m3u8_formats(
manifest_url, display_id, 'mp4',
'm3u8_native', m3u8_id='hls', fatal=False))
self._sort_formats(formats)
2014-07-17 10:07:51 +02:00
return {
'id': video_id,
2015-07-14 19:59:21 +02:00
'display_id': display_id,
2014-07-17 10:07:51 +02:00
'title': video_info.find('title').text,
2016-04-29 20:21:17 +02:00
'thumbnail': 'http://tv.dfb.de/images/%s_640x360.jpg' % video_id,
2015-07-14 19:59:21 +02:00
'upload_date': unified_strdate(video_info.find('time_date').text),
2015-07-14 20:01:41 +02:00
'formats': formats,
2014-07-17 10:07:51 +02:00
}