2 from __future__ import unicode_literals
4 from .common import InfoExtractor
5 from ..compat import compat_str
14 class DctpTvIE(InfoExtractor):
15 _VALID_URL = r'https?://(?:www\.)?dctp\.tv/(?:#/)?filme/(?P<id>[^/?#&]+)'
18 'url': 'http://www.dctp.tv/filme/videoinstallation-fuer-eine-kaufhausfassade/',
19 'md5': '3ffbd1556c3fe210724d7088fad723e3',
21 'id': '95eaa4f33dad413aa17b4ee613cccc6c',
22 'display_id': 'videoinstallation-fuer-eine-kaufhausfassade',
24 'title': 'Videoinstallation für eine Kaufhausfassade',
25 'description': 'Kurzfilm',
26 'thumbnail': r're:^https?://.*\.jpg$',
28 'timestamp': 1302172322,
29 'upload_date': '20110407',
33 'url': 'http://www.dctp.tv/filme/sind-youtuber-die-besseren-lehrer/',
34 'only_matching': True,
37 _BASE_URL = 'http://dctp-ivms2-restapi.s3.amazonaws.com'
39 def _real_extract(self, url):
40 display_id = self._match_id(url)
42 version = self._download_json(
43 '%s/version.json' % self._BASE_URL, display_id,
44 'Downloading version JSON')
46 restapi_base = '%s/%s/restapi' % (
47 self._BASE_URL, version['version_name'])
49 info = self._download_json(
50 '%s/slugs/%s.json' % (restapi_base, display_id), display_id,
51 'Downloading video info JSON')
53 media = self._download_json(
54 '%s/media/%s.json' % (restapi_base, compat_str(info['object_id'])),
55 display_id, 'Downloading media JSON')
58 title = media['title']
59 is_wide = media.get('is_wide')
62 def add_formats(suffix):
63 templ = 'https://%%s/%s_dctp_%s.m4v' % (uuid, suffix)
65 'format_id': 'hls-' + suffix,
66 'url': templ % 'cdn-segments.dctp.tv' + '/playlist.m3u8',
67 'protocol': 'm3u8_native',
69 'format_id': 's3-' + suffix,
70 'url': templ % 'completed-media.s3.amazonaws.com',
72 'format_id': 'http-' + suffix,
73 'url': templ % 'cdn-media.dctp.tv',
76 add_formats('0500_' + ('16x9' if is_wide else '4x3'))
81 images = media.get('images')
82 if isinstance(images, list):
84 if not isinstance(image, dict):
86 image_url = url_or_none(image.get('url'))
91 'width': int_or_none(image.get('width')),
92 'height': int_or_none(image.get('height')),
97 'display_id': display_id,
99 'alt_title': media.get('subtitle'),
100 'description': media.get('description') or media.get('teaser'),
101 'timestamp': unified_timestamp(media.get('created')),
102 'duration': float_or_none(media.get('duration_in_ms'), scale=1000),
103 'thumbnails': thumbnails,