0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-04 23:35:04 +00:00
yt-dlp/youtube_dl/extractor/dfb.py

50 lines
1.7 KiB
Python
Raw Normal View History

2014-07-17 08:07:51 +00:00
from __future__ import unicode_literals
import re
from .common import InfoExtractor
2015-07-14 17:59:21 +00:00
from ..utils import unified_strdate
2014-07-17 08:07:51 +00:00
class DFBIE(InfoExtractor):
IE_NAME = 'tv.dfb.de'
2015-07-14 17:59:21 +00:00
_VALID_URL = r'https?://tv\.dfb\.de/video/(?P<display_id>[^/]+)/(?P<id>\d+)'
2014-07-17 08:07:51 +00:00
_TEST = {
2015-07-14 17:54:13 +00:00
'url': 'http://tv.dfb.de/video/u-19-em-stimmen-zum-spiel-gegen-russland/11633/',
2014-07-17 08:07:51 +00:00
# The md5 is different each time
'info_dict': {
2015-07-14 17:54:13 +00:00
'id': '11633',
2015-07-14 17:59:21 +00:00
'display_id': 'u-19-em-stimmen-zum-spiel-gegen-russland',
2014-07-17 08:07:51 +00:00
'ext': 'flv',
2015-07-14 17:54:13 +00:00
'title': 'U 19-EM: Stimmen zum Spiel gegen Russland',
'upload_date': '20150714',
2014-07-17 08:07:51 +00:00
},
}
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id')
2015-07-14 17:59:21 +00:00
display_id = mobj.group('display_id')
2014-07-17 08:07:51 +00:00
2015-07-14 17:59:21 +00:00
webpage = self._download_webpage(url, display_id)
2014-07-17 08:07:51 +00:00
player_info = self._download_xml(
'http://tv.dfb.de/server/hd_video.php?play=%s' % video_id,
2015-07-14 17:59:21 +00:00
display_id)
2014-07-17 08:07:51 +00:00
video_info = player_info.find('video')
2015-07-14 17:59:21 +00:00
f4m_info = self._download_xml(
self._proto_relative_url(video_info.find('url').text.strip()), display_id)
2014-07-17 08:07:51 +00:00
token_el = f4m_info.find('token')
manifest_url = token_el.attrib['url'] + '?' + 'hdnea=' + token_el.attrib['auth'] + '&hdcore=3.2.0'
2015-07-14 18:01:41 +00:00
formats = self._extract_f4m_formats(manifest_url, display_id)
2014-07-17 08:07:51 +00:00
return {
'id': video_id,
2015-07-14 17:59:21 +00:00
'display_id': display_id,
2014-07-17 08:07:51 +00:00
'title': video_info.find('title').text,
'thumbnail': self._og_search_thumbnail(webpage),
2015-07-14 17:59:21 +00:00
'upload_date': unified_strdate(video_info.find('time_date').text),
2015-07-14 18:01:41 +00:00
'formats': formats,
2014-07-17 08:07:51 +00:00
}