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.

57 lines
2.0 KiB

10 years ago
10 years ago
10 years ago
  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import compat_str
  5. class DctpTvIE(InfoExtractor):
  6. _VALID_URL = r'http://www.dctp.tv/(#/)?filme/(?P<id>.+?)/$'
  7. _TEST = {
  8. 'url': 'http://www.dctp.tv/filme/videoinstallation-fuer-eine-kaufhausfassade/',
  9. 'info_dict': {
  10. 'id': '1324',
  11. 'display_id': 'videoinstallation-fuer-eine-kaufhausfassade',
  12. 'ext': 'flv',
  13. 'title': 'Videoinstallation für eine Kaufhausfassade'
  14. }
  15. }
  16. def _real_extract(self, url):
  17. video_id = self._match_id(url)
  18. base_url = 'http://dctp-ivms2-restapi.s3.amazonaws.com/'
  19. version_json = self._download_json(
  20. base_url + 'version.json',
  21. video_id, note='Determining file version')
  22. version = version_json['version_name']
  23. info_json = self._download_json(
  24. '{0}{1}/restapi/slugs/{2}.json'.format(base_url, version, video_id),
  25. video_id, note='Fetching object ID')
  26. object_id = compat_str(info_json['object_id'])
  27. meta_json = self._download_json(
  28. '{0}{1}/restapi/media/{2}.json'.format(base_url, version, object_id),
  29. video_id, note='Downloading metadata')
  30. uuid = meta_json['uuid']
  31. title = meta_json['title']
  32. wide = meta_json['is_wide']
  33. if wide:
  34. ratio = '16x9'
  35. else:
  36. ratio = '4x3'
  37. play_path = 'mp4:{0}_dctp_0500_{1}.m4v'.format(uuid, ratio)
  38. servers_json = self._download_json(
  39. 'http://www.dctp.tv/streaming_servers/',
  40. video_id, note='Downloading server list')
  41. url = servers_json[0]['endpoint']
  42. return {
  43. 'id': object_id,
  44. 'title': title,
  45. 'format': 'rtmp',
  46. 'url': url,
  47. 'play_path': play_path,
  48. 'rtmp_real_time': True,
  49. 'ext': 'flv',
  50. 'display_id': video_id
  51. }