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.

110 lines
3.9 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import compat_urllib_parse_urlparse
  5. from ..utils import (
  6. determine_ext,
  7. float_or_none,
  8. )
  9. class SpiegeltvIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?spiegel\.tv/(?:#/)?filme/(?P<id>[\-a-z0-9]+)'
  11. _TESTS = [{
  12. 'url': 'http://www.spiegel.tv/filme/flug-mh370/',
  13. 'info_dict': {
  14. 'id': 'flug-mh370',
  15. 'ext': 'm4v',
  16. 'title': 'Flug MH370',
  17. 'description': 'Das Rätsel um die Boeing 777 der Malaysia-Airlines',
  18. 'thumbnail': 're:http://.*\.jpg$',
  19. },
  20. 'params': {
  21. # m3u8 download
  22. 'skip_download': True,
  23. }
  24. }, {
  25. 'url': 'http://www.spiegel.tv/#/filme/alleskino-die-wahrheit-ueber-maenner/',
  26. 'only_matching': True,
  27. }]
  28. def _real_extract(self, url):
  29. if '/#/' in url:
  30. url = url.replace('/#/', '/')
  31. video_id = self._match_id(url)
  32. webpage = self._download_webpage(url, video_id)
  33. title = self._html_search_regex(r'<h1.*?>(.*?)</h1>', webpage, 'title')
  34. apihost = 'http://spiegeltv-ivms2-restapi.s3.amazonaws.com'
  35. version_json = self._download_json(
  36. '%s/version.json' % apihost, video_id,
  37. note='Downloading version information')
  38. version_name = version_json['version_name']
  39. slug_json = self._download_json(
  40. '%s/%s/restapi/slugs/%s.json' % (apihost, version_name, video_id),
  41. video_id,
  42. note='Downloading object information')
  43. oid = slug_json['object_id']
  44. media_json = self._download_json(
  45. '%s/%s/restapi/media/%s.json' % (apihost, version_name, oid),
  46. video_id, note='Downloading media information')
  47. uuid = media_json['uuid']
  48. is_wide = media_json['is_wide']
  49. server_json = self._download_json(
  50. 'http://spiegeltv-prod-static.s3.amazonaws.com/projectConfigs/projectConfig.json',
  51. video_id, note='Downloading server information')
  52. format = '16x9' if is_wide else '4x3'
  53. formats = []
  54. for streamingserver in server_json['streamingserver']:
  55. endpoint = streamingserver.get('endpoint')
  56. if not endpoint:
  57. continue
  58. play_path = 'mp4:%s_spiegeltv_0500_%s.m4v' % (uuid, format)
  59. if endpoint.startswith('rtmp'):
  60. formats.append({
  61. 'url': endpoint,
  62. 'format_id': 'rtmp',
  63. 'app': compat_urllib_parse_urlparse(endpoint).path[1:],
  64. 'play_path': play_path,
  65. 'player_path': 'http://prod-static.spiegel.tv/frontend-076.swf',
  66. 'ext': 'flv',
  67. 'rtmp_live': True,
  68. })
  69. elif determine_ext(endpoint) == 'm3u8':
  70. m3u8_formats = self._extract_m3u8_formats(
  71. endpoint.replace('[video]', play_path),
  72. video_id, 'm4v',
  73. preference=1, # Prefer hls since it allows to workaround georestriction
  74. m3u8_id='hls', fatal=False)
  75. if m3u8_formats is not False:
  76. formats.extend(m3u8_formats)
  77. else:
  78. formats.append({
  79. 'url': endpoint,
  80. })
  81. thumbnails = []
  82. for image in media_json['images']:
  83. thumbnails.append({
  84. 'url': image['url'],
  85. 'width': image['width'],
  86. 'height': image['height'],
  87. })
  88. description = media_json['subtitle']
  89. duration = float_or_none(media_json.get('duration_in_ms'), scale=1000)
  90. return {
  91. 'id': video_id,
  92. 'title': title,
  93. 'description': description,
  94. 'duration': duration,
  95. 'thumbnails': thumbnails,
  96. 'formats': formats,
  97. }