]>
Commit | Line | Data |
---|---|---|
0865f397 | 1 | from .common import InfoExtractor |
8e01f3ca S |
2 | from ..utils import ( |
3 | float_or_none, | |
acbd0ff5 S |
4 | int_or_none, |
5 | unified_timestamp, | |
3052a30d | 6 | url_or_none, |
8e01f3ca | 7 | ) |
0865f397 | 8 | |
48a1e514 | 9 | |
0865f397 | 10 | class DctpTvIE(InfoExtractor): |
8e01f3ca | 11 | _VALID_URL = r'https?://(?:www\.)?dctp\.tv/(?:#/)?filme/(?P<id>[^/?#&]+)' |
acbd0ff5 S |
12 | _TESTS = [{ |
13 | # 4x3 | |
48a1e514 | 14 | 'url': 'http://www.dctp.tv/filme/videoinstallation-fuer-eine-kaufhausfassade/', |
b2771a28 | 15 | 'md5': '3ffbd1556c3fe210724d7088fad723e3', |
48a1e514 | 16 | 'info_dict': { |
e295618f | 17 | 'id': '95eaa4f33dad413aa17b4ee613cccc6c', |
75a4fc5b | 18 | 'display_id': 'videoinstallation-fuer-eine-kaufhausfassade', |
b2771a28 | 19 | 'ext': 'm4v', |
e295618f YCH |
20 | 'title': 'Videoinstallation für eine Kaufhausfassade', |
21 | 'description': 'Kurzfilm', | |
ec85ded8 | 22 | 'thumbnail': r're:^https?://.*\.jpg$', |
8e01f3ca | 23 | 'duration': 71.24, |
acbd0ff5 S |
24 | 'timestamp': 1302172322, |
25 | 'upload_date': '20110407', | |
8e01f3ca | 26 | }, |
acbd0ff5 S |
27 | }, { |
28 | # 16x9 | |
29 | 'url': 'http://www.dctp.tv/filme/sind-youtuber-die-besseren-lehrer/', | |
30 | 'only_matching': True, | |
31 | }] | |
32 | ||
33 | _BASE_URL = 'http://dctp-ivms2-restapi.s3.amazonaws.com' | |
0865f397 PH |
34 | |
35 | def _real_extract(self, url): | |
8e01f3ca | 36 | display_id = self._match_id(url) |
e295618f | 37 | |
acbd0ff5 | 38 | version = self._download_json( |
add96eb9 | 39 | f'{self._BASE_URL}/version.json', display_id, |
acbd0ff5 S |
40 | 'Downloading version JSON') |
41 | ||
add96eb9 | 42 | restapi_base = '{}/{}/restapi'.format( |
acbd0ff5 | 43 | self._BASE_URL, version['version_name']) |
0865f397 | 44 | |
acbd0ff5 | 45 | info = self._download_json( |
add96eb9 | 46 | f'{restapi_base}/slugs/{display_id}.json', display_id, |
acbd0ff5 | 47 | 'Downloading video info JSON') |
e295618f | 48 | |
acbd0ff5 | 49 | media = self._download_json( |
add96eb9 | 50 | '{}/media/{}.json'.format(restapi_base, str(info['object_id'])), |
acbd0ff5 S |
51 | display_id, 'Downloading media JSON') |
52 | ||
53 | uuid = media['uuid'] | |
54 | title = media['title'] | |
b2771a28 RA |
55 | is_wide = media.get('is_wide') |
56 | formats = [] | |
57 | ||
58 | def add_formats(suffix): | |
add96eb9 | 59 | templ = f'https://%s/{uuid}_dctp_{suffix}.m4v' |
b2771a28 RA |
60 | formats.extend([{ |
61 | 'format_id': 'hls-' + suffix, | |
62 | 'url': templ % 'cdn-segments.dctp.tv' + '/playlist.m3u8', | |
63 | 'protocol': 'm3u8_native', | |
64 | }, { | |
65 | 'format_id': 's3-' + suffix, | |
66 | 'url': templ % 'completed-media.s3.amazonaws.com', | |
67 | }, { | |
68 | 'format_id': 'http-' + suffix, | |
69 | 'url': templ % 'cdn-media.dctp.tv', | |
70 | }]) | |
71 | ||
72 | add_formats('0500_' + ('16x9' if is_wide else '4x3')) | |
73 | if is_wide: | |
74 | add_formats('720p') | |
8e01f3ca | 75 | |
acbd0ff5 S |
76 | thumbnails = [] |
77 | images = media.get('images') | |
78 | if isinstance(images, list): | |
79 | for image in images: | |
80 | if not isinstance(image, dict): | |
81 | continue | |
3052a30d S |
82 | image_url = url_or_none(image.get('url')) |
83 | if not image_url: | |
acbd0ff5 S |
84 | continue |
85 | thumbnails.append({ | |
86 | 'url': image_url, | |
87 | 'width': int_or_none(image.get('width')), | |
88 | 'height': int_or_none(image.get('height')), | |
89 | }) | |
0865f397 PH |
90 | |
91 | return { | |
acbd0ff5 S |
92 | 'id': uuid, |
93 | 'display_id': display_id, | |
0865f397 | 94 | 'title': title, |
acbd0ff5 S |
95 | 'alt_title': media.get('subtitle'), |
96 | 'description': media.get('description') or media.get('teaser'), | |
97 | 'timestamp': unified_timestamp(media.get('created')), | |
98 | 'duration': float_or_none(media.get('duration_in_ms'), scale=1000), | |
99 | 'thumbnails': thumbnails, | |
e295618f | 100 | 'formats': formats, |
0865f397 | 101 | } |