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.

80 lines
2.5 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
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class SpiegeltvIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?spiegel\.tv/filme/(?P<id>[\-a-z0-9]+)'
  7. _TEST = {
  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. def _real_extract(self, url):
  22. mobj = re.match(self._VALID_URL, url)
  23. video_id = mobj.group('id')
  24. webpage = self._download_webpage(url, video_id)
  25. title = self._html_search_regex(r'<h1.*?>(.*?)</h1>', webpage, 'title')
  26. apihost = 'http://spiegeltv-ivms2-restapi.s3.amazonaws.com'
  27. version_json = self._download_json(
  28. '%s/version.json' % apihost, video_id,
  29. note='Downloading version information')
  30. version_name = version_json['version_name']
  31. slug_json = self._download_json(
  32. '%s/%s/restapi/slugs/%s.json' % (apihost, version_name, video_id),
  33. video_id,
  34. note='Downloading object information')
  35. oid = slug_json['object_id']
  36. media_json = self._download_json(
  37. '%s/%s/restapi/media/%s.json' % (apihost, version_name, oid),
  38. video_id, note='Downloading media information')
  39. uuid = media_json['uuid']
  40. is_wide = media_json['is_wide']
  41. server_json = self._download_json(
  42. 'http://www.spiegel.tv/streaming_servers/', video_id,
  43. note='Downloading server information')
  44. server = server_json[0]['endpoint']
  45. thumbnails = []
  46. for image in media_json['images']:
  47. thumbnails.append({
  48. 'url': image['url'],
  49. 'width': image['width'],
  50. 'height': image['height'],
  51. })
  52. description = media_json['subtitle']
  53. duration = media_json['duration_in_ms'] / 1000.
  54. if is_wide:
  55. format = '16x9'
  56. else:
  57. format = '4x3'
  58. url = server + 'mp4:' + uuid + '_spiegeltv_0500_' + format + '.m4v'
  59. return {
  60. 'id': video_id,
  61. 'title': title,
  62. 'url': url,
  63. 'ext': 'm4v',
  64. 'description': description,
  65. 'duration': duration,
  66. 'thumbnails': thumbnails
  67. }