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.

77 lines
2.6 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. compat_urllib_request,
  7. parse_iso8601,
  8. )
  9. class SportDeutschlandIE(InfoExtractor):
  10. _VALID_URL = r'https?://sportdeutschland\.tv/(?P<sport>[^/?#]+)/(?P<id>[^?#/]+)(?:$|[?#])'
  11. _TEST = {
  12. 'url': 'http://sportdeutschland.tv/badminton/live-li-ning-badminton-weltmeisterschaft-2014-kopenhagen',
  13. 'info_dict': {
  14. 'id': 'live-li-ning-badminton-weltmeisterschaft-2014-kopenhagen',
  15. 'ext': 'mp4',
  16. 'title': 'LIVE: Li-Ning Badminton Weltmeisterschaft 2014 Kopenhagen',
  17. 'categories': ['Badminton'],
  18. 'view_count': int,
  19. 'thumbnail': 're:^https?://.*\.jpg',
  20. 'description': 're:^Die Badminton-WM 2014 aus Kopenhagen LIVE',
  21. 'timestamp': 1409043600,
  22. 'upload_date': '20140826',
  23. },
  24. 'params': {
  25. 'skip_download': 'Live stream',
  26. },
  27. }
  28. def _real_extract(self, url):
  29. mobj = re.match(self._VALID_URL, url)
  30. video_id = mobj.group('id')
  31. sport_id = mobj.group('sport')
  32. api_url = 'http://splink.tv/api/permalinks/%s/%s' % (
  33. sport_id, video_id)
  34. req = compat_urllib_request.Request(api_url, headers={
  35. 'Accept': 'application/vnd.vidibus.v2.html+json',
  36. 'Referer': url,
  37. })
  38. data = self._download_json(req, video_id)
  39. categories = list(data.get('section', {}).get('tags', {}).values())
  40. asset = data['asset']
  41. smil_url = asset['video']
  42. m3u8_url = smil_url.replace('.smil', '.m3u8')
  43. formats = self._extract_m3u8_formats(m3u8_url, video_id, ext='mp4')
  44. smil_doc = self._download_xml(
  45. smil_url, video_id, note='Downloading SMIL metadata')
  46. base_url = smil_doc.find('./head/meta').attrib['base']
  47. formats.extend([{
  48. 'format_id': 'rmtp',
  49. 'url': base_url,
  50. 'play_path': n.attrib['src'],
  51. 'ext': 'flv',
  52. 'preference': -100,
  53. 'format_note': 'Seems to fail at example stream',
  54. } for n in smil_doc.findall('./body/video')])
  55. self._sort_formats(formats)
  56. return {
  57. 'id': video_id,
  58. 'formats': formats,
  59. 'title': asset['title'],
  60. 'thumbnail': asset.get('image'),
  61. 'description': asset.get('teaser'),
  62. 'categories': categories,
  63. 'view_count': asset.get('views'),
  64. 'rtmp_live': asset['live'],
  65. 'timestamp': parse_iso8601(asset.get('date')),
  66. }