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.

86 lines
2.8 KiB

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_str
  5. from ..utils import (
  6. float_or_none,
  7. unified_strdate,
  8. )
  9. class DctpTvIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?dctp\.tv/(?:#/)?filme/(?P<id>[^/?#&]+)'
  11. _TEST = {
  12. 'url': 'http://www.dctp.tv/filme/videoinstallation-fuer-eine-kaufhausfassade/',
  13. 'info_dict': {
  14. 'id': '95eaa4f33dad413aa17b4ee613cccc6c',
  15. 'display_id': 'videoinstallation-fuer-eine-kaufhausfassade',
  16. 'ext': 'flv',
  17. 'title': 'Videoinstallation für eine Kaufhausfassade',
  18. 'description': 'Kurzfilm',
  19. 'upload_date': '20110407',
  20. 'thumbnail': r're:^https?://.*\.jpg$',
  21. 'duration': 71.24,
  22. },
  23. 'params': {
  24. # rtmp download
  25. 'skip_download': True,
  26. },
  27. }
  28. def _real_extract(self, url):
  29. display_id = self._match_id(url)
  30. webpage = self._download_webpage(url, display_id)
  31. video_id = self._html_search_meta(
  32. 'DC.identifier', webpage, 'video id',
  33. default=None) or self._search_regex(
  34. r'id=["\']uuid[^>]+>([^<]+)<', webpage, 'video id')
  35. title = self._og_search_title(webpage)
  36. servers = self._download_json(
  37. 'http://www.dctp.tv/streaming_servers/', display_id,
  38. note='Downloading server list', fatal=False)
  39. if servers:
  40. endpoint = next(
  41. server['endpoint']
  42. for server in servers
  43. if isinstance(server.get('endpoint'), compat_str) and
  44. 'cloudfront' in server['endpoint'])
  45. else:
  46. endpoint = 'rtmpe://s2pqqn4u96e4j8.cloudfront.net/cfx/st/'
  47. app = self._search_regex(
  48. r'^rtmpe?://[^/]+/(?P<app>.*)$', endpoint, 'app')
  49. formats = [{
  50. 'url': endpoint,
  51. 'app': app,
  52. 'play_path': 'mp4:%s_dctp_0500_4x3.m4v' % video_id,
  53. 'page_url': url,
  54. 'player_url': 'http://svm-prod-dctptv-static.s3.amazonaws.com/dctptv-relaunch2012-109.swf',
  55. 'ext': 'flv',
  56. }]
  57. description = self._html_search_meta('DC.description', webpage)
  58. upload_date = unified_strdate(
  59. self._html_search_meta('DC.date.created', webpage))
  60. thumbnail = self._og_search_thumbnail(webpage)
  61. duration = float_or_none(self._search_regex(
  62. r'id=["\']duration_in_ms[^+]>(\d+)', webpage, 'duration',
  63. default=None), scale=1000)
  64. return {
  65. 'id': video_id,
  66. 'title': title,
  67. 'formats': formats,
  68. 'display_id': display_id,
  69. 'description': description,
  70. 'upload_date': upload_date,
  71. 'thumbnail': thumbnail,
  72. 'duration': duration,
  73. }