You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.2 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. 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+)'
  8. _TEST = {
  9. 'url': 'http://tv.dfb.de/video/u-19-em-stimmen-zum-spiel-gegen-russland/11633/',
  10. 'md5': 'ac0f98a52a330f700b4b3034ad240649',
  11. 'info_dict': {
  12. 'id': '11633',
  13. 'display_id': 'u-19-em-stimmen-zum-spiel-gegen-russland',
  14. 'ext': 'mp4',
  15. 'title': 'U 19-EM: Stimmen zum Spiel gegen Russland',
  16. 'upload_date': '20150714',
  17. },
  18. }
  19. def _real_extract(self, url):
  20. display_id, video_id = re.match(self._VALID_URL, url).groups()
  21. player_info = self._download_xml(
  22. 'http://tv.dfb.de/server/hd_video.php?play=%s' % video_id,
  23. display_id)
  24. video_info = player_info.find('video')
  25. stream_access_url = self._proto_relative_url(video_info.find('url').text.strip())
  26. formats = []
  27. # see http://tv.dfb.de/player/js/ajax.js for the method to extract m3u8 formats
  28. for sa_url in (stream_access_url, stream_access_url + '&area=&format=iphone'):
  29. stream_access_info = self._download_xml(sa_url, display_id)
  30. token_el = stream_access_info.find('token')
  31. manifest_url = token_el.attrib['url'] + '?' + 'hdnea=' + token_el.attrib['auth']
  32. if '.f4m' in manifest_url:
  33. formats.extend(self._extract_f4m_formats(
  34. manifest_url + '&hdcore=3.2.0',
  35. display_id, f4m_id='hds', fatal=False))
  36. else:
  37. formats.extend(self._extract_m3u8_formats(
  38. manifest_url, display_id, 'mp4',
  39. 'm3u8_native', m3u8_id='hls', fatal=False))
  40. self._sort_formats(formats)
  41. return {
  42. 'id': video_id,
  43. 'display_id': display_id,
  44. 'title': video_info.find('title').text,
  45. 'thumbnail': 'http://tv.dfb.de/images/%s_640x360.jpg' % video_id,
  46. 'upload_date': unified_strdate(video_info.find('time_date').text),
  47. 'formats': formats,
  48. }