2015-08-09 15:11:23 +02:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
2016-05-07 18:56:31 +02:00
|
|
|
from ..utils import (
|
|
|
|
determine_ext,
|
2019-11-03 22:04:03 +01:00
|
|
|
int_or_none,
|
|
|
|
parse_iso8601,
|
|
|
|
try_get,
|
2016-05-07 18:56:31 +02:00
|
|
|
)
|
2015-08-09 15:11:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
class TelegraafIE(InfoExtractor):
|
2019-11-03 22:04:03 +01:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?telegraaf\.nl/video/(?P<id>\d+)'
|
2015-08-09 15:11:23 +02:00
|
|
|
_TEST = {
|
2019-11-03 22:04:03 +01:00
|
|
|
'url': 'https://www.telegraaf.nl/video/734366489/historisch-scheepswrak-slaat-na-100-jaar-los',
|
2015-08-09 15:11:23 +02:00
|
|
|
'info_dict': {
|
2019-11-03 22:04:03 +01:00
|
|
|
'id': 'gaMItuoSeUg2',
|
2015-08-09 15:11:23 +02:00
|
|
|
'ext': 'mp4',
|
2019-11-03 22:04:03 +01:00
|
|
|
'title': 'Historisch scheepswrak slaat na 100 jaar los',
|
|
|
|
'description': 'md5:6f53b7c4f55596722ac24d6c0ec00cfb',
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg',
|
|
|
|
'duration': 55,
|
|
|
|
'timestamp': 1572805527,
|
|
|
|
'upload_date': '20191103',
|
2015-08-09 15:11:23 +02:00
|
|
|
},
|
2016-05-07 18:56:31 +02:00
|
|
|
'params': {
|
|
|
|
# m3u8 download
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
2015-08-09 15:11:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2019-11-03 22:04:03 +01:00
|
|
|
article_id = self._match_id(url)
|
2015-08-09 15:11:23 +02:00
|
|
|
|
2019-11-03 22:04:03 +01:00
|
|
|
video_id = self._download_json(
|
|
|
|
'https://www.telegraaf.nl/graphql', article_id, query={
|
|
|
|
'query': '''{
|
|
|
|
article(uid: %s) {
|
|
|
|
videos {
|
|
|
|
videoId
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}''' % article_id,
|
|
|
|
})['data']['article']['videos'][0]['videoId']
|
2015-08-09 15:11:23 +02:00
|
|
|
|
2019-11-03 22:04:03 +01:00
|
|
|
item = self._download_json(
|
|
|
|
'https://content.tmgvideo.nl/playlist/item=%s/playlist.json' % video_id,
|
|
|
|
video_id)['items'][0]
|
|
|
|
title = item['title']
|
2016-05-07 18:56:31 +02:00
|
|
|
|
|
|
|
formats = []
|
2019-11-03 22:04:03 +01:00
|
|
|
locations = item.get('locations') or {}
|
2016-05-07 18:56:31 +02:00
|
|
|
for location in locations.get('adaptive', []):
|
2019-11-03 22:04:03 +01:00
|
|
|
manifest_url = location.get('src')
|
|
|
|
if not manifest_url:
|
|
|
|
continue
|
2016-05-07 18:56:31 +02:00
|
|
|
ext = determine_ext(manifest_url)
|
|
|
|
if ext == 'm3u8':
|
|
|
|
formats.extend(self._extract_m3u8_formats(
|
2016-07-24 05:29:26 +02:00
|
|
|
manifest_url, video_id, ext='mp4', m3u8_id='hls', fatal=False))
|
2016-05-07 18:56:31 +02:00
|
|
|
elif ext == 'mpd':
|
2016-07-24 05:29:09 +02:00
|
|
|
formats.extend(self._extract_mpd_formats(
|
|
|
|
manifest_url, video_id, mpd_id='dash', fatal=False))
|
2016-05-07 18:56:31 +02:00
|
|
|
else:
|
|
|
|
self.report_warning('Unknown adaptive format %s' % ext)
|
|
|
|
for location in locations.get('progressive', []):
|
2019-11-03 22:04:03 +01:00
|
|
|
src = try_get(location, lambda x: x['sources'][0]['src'])
|
|
|
|
if not src:
|
|
|
|
continue
|
|
|
|
label = location.get('label')
|
2016-05-07 18:56:31 +02:00
|
|
|
formats.append({
|
2019-11-03 22:04:03 +01:00
|
|
|
'url': src,
|
|
|
|
'width': int_or_none(location.get('width')),
|
|
|
|
'height': int_or_none(location.get('height')),
|
|
|
|
'format_id': 'http' + ('-%s' % label if label else ''),
|
2016-05-07 18:56:31 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
self._sort_formats(formats)
|
2015-08-09 15:11:23 +02:00
|
|
|
|
2016-05-07 18:56:31 +02:00
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'title': title,
|
2019-11-03 22:04:03 +01:00
|
|
|
'description': item.get('description'),
|
2016-05-07 18:56:31 +02:00
|
|
|
'formats': formats,
|
2019-11-03 22:04:03 +01:00
|
|
|
'duration': int_or_none(item.get('duration')),
|
|
|
|
'thumbnail': item.get('poster'),
|
|
|
|
'timestamp': parse_iso8601(item.get('datecreated'), ' '),
|
2016-05-07 18:56:31 +02:00
|
|
|
}
|