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.

79 lines
2.7 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import float_or_none
  5. class SpiegeltvIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?spiegel\.tv/(?:#/)?filme/(?P<id>[\-a-z0-9]+)'
  7. _TESTS = [{
  8. 'url': 'http://www.spiegel.tv/filme/flug-mh370/',
  9. 'info_dict': {
  10. 'id': 'flug-mh370',
  11. 'ext': 'm4v',
  12. 'title': 'Flug MH370',
  13. 'description': 'Das Rätsel um die Boeing 777 der Malaysia-Airlines',
  14. 'thumbnail': 're:http://.*\.jpg$',
  15. },
  16. 'params': {
  17. # rtmp download
  18. 'skip_download': True,
  19. }
  20. }, {
  21. 'url': 'http://www.spiegel.tv/#/filme/alleskino-die-wahrheit-ueber-maenner/',
  22. 'only_matching': True,
  23. }]
  24. def _real_extract(self, url):
  25. if '/#/' in url:
  26. url = url.replace('/#/', '/')
  27. video_id = self._match_id(url)
  28. webpage = self._download_webpage(url, video_id)
  29. title = self._html_search_regex(r'<h1.*?>(.*?)</h1>', webpage, 'title')
  30. apihost = 'http://spiegeltv-ivms2-restapi.s3.amazonaws.com'
  31. version_json = self._download_json(
  32. '%s/version.json' % apihost, video_id,
  33. note='Downloading version information')
  34. version_name = version_json['version_name']
  35. slug_json = self._download_json(
  36. '%s/%s/restapi/slugs/%s.json' % (apihost, version_name, video_id),
  37. video_id,
  38. note='Downloading object information')
  39. oid = slug_json['object_id']
  40. media_json = self._download_json(
  41. '%s/%s/restapi/media/%s.json' % (apihost, version_name, oid),
  42. video_id, note='Downloading media information')
  43. uuid = media_json['uuid']
  44. is_wide = media_json['is_wide']
  45. server_json = self._download_json(
  46. 'http://www.spiegel.tv/streaming_servers/', video_id,
  47. note='Downloading server information')
  48. server = server_json[0]['endpoint']
  49. thumbnails = []
  50. for image in media_json['images']:
  51. thumbnails.append({
  52. 'url': image['url'],
  53. 'width': image['width'],
  54. 'height': image['height'],
  55. })
  56. description = media_json['subtitle']
  57. duration = float_or_none(media_json.get('duration_in_ms'), scale=1000)
  58. format = '16x9' if is_wide else '4x3'
  59. url = server + 'mp4:' + uuid + '_spiegeltv_0500_' + format + '.m4v'
  60. return {
  61. 'id': video_id,
  62. 'title': title,
  63. 'url': url,
  64. 'ext': 'm4v',
  65. 'description': description,
  66. 'duration': duration,
  67. 'thumbnails': thumbnails
  68. }