dfb.py 2.1 KB

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