logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

tonline.py (2093B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import int_or_none
  5. class TOnlineIE(InfoExtractor):
  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. 'http://www.t-online.de/tv/id_%s/tid_json_video' % video_id, 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_id = []
  29. for field_key in ('type', 'profile'):
  30. field_value = asset.get(field_key)
  31. if field_value:
  32. formats_id.append(field_value)
  33. formats.append({
  34. 'format_id': '-'.join(formats_id),
  35. 'url': asset_source,
  36. })
  37. thumbnails = []
  38. for image in video_data.get('images', []):
  39. image_source = image.get('source')
  40. if not image_source:
  41. continue
  42. thumbnails.append({
  43. 'url': image_source,
  44. })
  45. return {
  46. 'id': video_id,
  47. 'title': title,
  48. 'description': video_data.get('description'),
  49. 'duration': int_or_none(video_data.get('duration')),
  50. 'thumbnails': thumbnails,
  51. 'formats': formats,
  52. }