tonline.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. from .common import InfoExtractor
  2. from ..utils import int_or_none, join_nonempty
  3. class TOnlineIE(InfoExtractor):
  4. _WORKING = False
  5. _ENABLED = None # XXX: pass through to GenericIE
  6. IE_NAME = 't-online.de'
  7. _VALID_URL = r'https?://(?:www\.)?t-online\.de/tv/(?:[^/]+/)*id_(?P<id>\d+)'
  8. _TEST = {
  9. 'url': 'http://www.t-online.de/tv/sport/fussball/id_79166266/drittes-remis-zidane-es-muss-etwas-passieren-.html',
  10. 'md5': '7d94dbdde5f9d77c5accc73c39632c29',
  11. 'info_dict': {
  12. 'id': '79166266',
  13. 'ext': 'mp4',
  14. 'title': 'Drittes Remis! Zidane: "Es muss etwas passieren"',
  15. 'description': 'Es läuft nicht rund bei Real Madrid. Das 1:1 gegen den SD Eibar war das dritte Unentschieden in Folge in der Liga.',
  16. },
  17. }
  18. def _real_extract(self, url):
  19. video_id = self._match_id(url)
  20. video_data = self._download_json(
  21. f'http://www.t-online.de/tv/id_{video_id}/tid_json_video', video_id)
  22. title = video_data['subtitle']
  23. formats = []
  24. for asset in video_data.get('assets', []):
  25. asset_source = asset.get('source') or asset.get('source2')
  26. if not asset_source:
  27. continue
  28. formats.append({
  29. 'format_id': join_nonempty('type', 'profile', from_dict=asset),
  30. 'url': asset_source,
  31. })
  32. thumbnails = []
  33. for image in video_data.get('images', []):
  34. image_source = image.get('source')
  35. if not image_source:
  36. continue
  37. thumbnails.append({
  38. 'url': image_source,
  39. })
  40. return {
  41. 'id': video_id,
  42. 'title': title,
  43. 'description': video_data.get('description'),
  44. 'duration': int_or_none(video_data.get('duration')),
  45. 'thumbnails': thumbnails,
  46. 'formats': formats,
  47. }