2015-01-28 00:21:04 -07:00
|
|
|
from .common import InfoExtractor
|
2017-10-28 09:58:01 -06:00
|
|
|
from ..utils import (
|
|
|
|
float_or_none,
|
2018-06-28 11:35:05 -06:00
|
|
|
int_or_none,
|
|
|
|
unified_timestamp,
|
2018-07-21 06:08:28 -06:00
|
|
|
url_or_none,
|
2017-10-28 09:58:01 -06:00
|
|
|
)
|
2015-01-28 00:21:04 -07:00
|
|
|
|
2015-01-28 00:59:58 -07:00
|
|
|
|
2015-01-28 00:21:04 -07:00
|
|
|
class DctpTvIE(InfoExtractor):
|
2017-10-28 09:58:01 -06:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?dctp\.tv/(?:#/)?filme/(?P<id>[^/?#&]+)'
|
2018-06-28 11:35:05 -06:00
|
|
|
_TESTS = [{
|
|
|
|
# 4x3
|
2015-01-28 00:59:58 -07:00
|
|
|
'url': 'http://www.dctp.tv/filme/videoinstallation-fuer-eine-kaufhausfassade/',
|
2020-01-07 05:03:32 -07:00
|
|
|
'md5': '3ffbd1556c3fe210724d7088fad723e3',
|
2015-01-28 00:59:58 -07:00
|
|
|
'info_dict': {
|
2016-10-01 01:22:48 -06:00
|
|
|
'id': '95eaa4f33dad413aa17b4ee613cccc6c',
|
2015-01-29 16:35:53 -07:00
|
|
|
'display_id': 'videoinstallation-fuer-eine-kaufhausfassade',
|
2020-01-07 05:03:32 -07:00
|
|
|
'ext': 'm4v',
|
2016-10-01 01:22:48 -06:00
|
|
|
'title': 'Videoinstallation für eine Kaufhausfassade',
|
|
|
|
'description': 'Kurzfilm',
|
2017-01-02 05:08:07 -07:00
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
2017-10-28 09:58:01 -06:00
|
|
|
'duration': 71.24,
|
2018-06-28 11:35:05 -06:00
|
|
|
'timestamp': 1302172322,
|
|
|
|
'upload_date': '20110407',
|
2017-10-28 09:58:01 -06:00
|
|
|
},
|
2018-06-28 11:35:05 -06:00
|
|
|
}, {
|
|
|
|
# 16x9
|
|
|
|
'url': 'http://www.dctp.tv/filme/sind-youtuber-die-besseren-lehrer/',
|
|
|
|
'only_matching': True,
|
|
|
|
}]
|
|
|
|
|
|
|
|
_BASE_URL = 'http://dctp-ivms2-restapi.s3.amazonaws.com'
|
2015-01-28 00:21:04 -07:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2017-10-28 09:58:01 -06:00
|
|
|
display_id = self._match_id(url)
|
2016-10-01 01:22:48 -06:00
|
|
|
|
2018-06-28 11:35:05 -06:00
|
|
|
version = self._download_json(
|
2024-06-11 17:09:58 -06:00
|
|
|
f'{self._BASE_URL}/version.json', display_id,
|
2018-06-28 11:35:05 -06:00
|
|
|
'Downloading version JSON')
|
|
|
|
|
2024-06-11 17:09:58 -06:00
|
|
|
restapi_base = '{}/{}/restapi'.format(
|
2018-06-28 11:35:05 -06:00
|
|
|
self._BASE_URL, version['version_name'])
|
2015-01-28 00:21:04 -07:00
|
|
|
|
2018-06-28 11:35:05 -06:00
|
|
|
info = self._download_json(
|
2024-06-11 17:09:58 -06:00
|
|
|
f'{restapi_base}/slugs/{display_id}.json', display_id,
|
2018-06-28 11:35:05 -06:00
|
|
|
'Downloading video info JSON')
|
2016-10-01 01:22:48 -06:00
|
|
|
|
2018-06-28 11:35:05 -06:00
|
|
|
media = self._download_json(
|
2024-06-11 17:09:58 -06:00
|
|
|
'{}/media/{}.json'.format(restapi_base, str(info['object_id'])),
|
2018-06-28 11:35:05 -06:00
|
|
|
display_id, 'Downloading media JSON')
|
|
|
|
|
|
|
|
uuid = media['uuid']
|
|
|
|
title = media['title']
|
2020-01-07 05:03:32 -07:00
|
|
|
is_wide = media.get('is_wide')
|
|
|
|
formats = []
|
|
|
|
|
|
|
|
def add_formats(suffix):
|
2024-06-11 17:09:58 -06:00
|
|
|
templ = f'https://%s/{uuid}_dctp_{suffix}.m4v'
|
2020-01-07 05:03:32 -07:00
|
|
|
formats.extend([{
|
|
|
|
'format_id': 'hls-' + suffix,
|
|
|
|
'url': templ % 'cdn-segments.dctp.tv' + '/playlist.m3u8',
|
|
|
|
'protocol': 'm3u8_native',
|
|
|
|
}, {
|
|
|
|
'format_id': 's3-' + suffix,
|
|
|
|
'url': templ % 'completed-media.s3.amazonaws.com',
|
|
|
|
}, {
|
|
|
|
'format_id': 'http-' + suffix,
|
|
|
|
'url': templ % 'cdn-media.dctp.tv',
|
|
|
|
}])
|
|
|
|
|
|
|
|
add_formats('0500_' + ('16x9' if is_wide else '4x3'))
|
|
|
|
if is_wide:
|
|
|
|
add_formats('720p')
|
2017-10-28 09:58:01 -06:00
|
|
|
|
2018-06-28 11:35:05 -06:00
|
|
|
thumbnails = []
|
|
|
|
images = media.get('images')
|
|
|
|
if isinstance(images, list):
|
|
|
|
for image in images:
|
|
|
|
if not isinstance(image, dict):
|
|
|
|
continue
|
2018-07-21 06:08:28 -06:00
|
|
|
image_url = url_or_none(image.get('url'))
|
|
|
|
if not image_url:
|
2018-06-28 11:35:05 -06:00
|
|
|
continue
|
|
|
|
thumbnails.append({
|
|
|
|
'url': image_url,
|
|
|
|
'width': int_or_none(image.get('width')),
|
|
|
|
'height': int_or_none(image.get('height')),
|
|
|
|
})
|
2015-01-28 00:21:04 -07:00
|
|
|
|
|
|
|
return {
|
2018-06-28 11:35:05 -06:00
|
|
|
'id': uuid,
|
|
|
|
'display_id': display_id,
|
2015-01-28 00:21:04 -07:00
|
|
|
'title': title,
|
2018-06-28 11:35:05 -06:00
|
|
|
'alt_title': media.get('subtitle'),
|
|
|
|
'description': media.get('description') or media.get('teaser'),
|
|
|
|
'timestamp': unified_timestamp(media.get('created')),
|
|
|
|
'duration': float_or_none(media.get('duration_in_ms'), scale=1000),
|
|
|
|
'thumbnails': thumbnails,
|
2016-10-01 01:22:48 -06:00
|
|
|
'formats': formats,
|
2015-01-28 00:21:04 -07:00
|
|
|
}
|