mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.9 KiB
Python
87 lines
2.9 KiB
Python
10 years ago
|
from .common import InfoExtractor
|
||
9 years ago
|
from ..utils import (
|
||
|
determine_ext,
|
||
5 years ago
|
int_or_none,
|
||
|
parse_iso8601,
|
||
|
try_get,
|
||
9 years ago
|
)
|
||
10 years ago
|
|
||
|
|
||
|
class TelegraafIE(InfoExtractor):
|
||
5 years ago
|
_VALID_URL = r'https?://(?:www\.)?telegraaf\.nl/video/(?P<id>\d+)'
|
||
10 years ago
|
_TEST = {
|
||
5 years ago
|
'url': 'https://www.telegraaf.nl/video/734366489/historisch-scheepswrak-slaat-na-100-jaar-los',
|
||
10 years ago
|
'info_dict': {
|
||
5 years ago
|
'id': 'gaMItuoSeUg2',
|
||
10 years ago
|
'ext': 'mp4',
|
||
5 years ago
|
'title': 'Historisch scheepswrak slaat na 100 jaar los',
|
||
|
'description': 'md5:6f53b7c4f55596722ac24d6c0ec00cfb',
|
||
|
'thumbnail': r're:^https?://.*\.jpg',
|
||
|
'duration': 55,
|
||
|
'timestamp': 1572805527,
|
||
|
'upload_date': '20191103',
|
||
10 years ago
|
},
|
||
9 years ago
|
'params': {
|
||
|
# m3u8 download
|
||
|
'skip_download': True,
|
||
|
},
|
||
10 years ago
|
}
|
||
|
|
||
|
def _real_extract(self, url):
|
||
5 years ago
|
article_id = self._match_id(url)
|
||
10 years ago
|
|
||
5 years ago
|
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']
|
||
10 years ago
|
|
||
5 years ago
|
item = self._download_json(
|
||
|
'https://content.tmgvideo.nl/playlist/item=%s/playlist.json' % video_id,
|
||
|
video_id)['items'][0]
|
||
|
title = item['title']
|
||
9 years ago
|
|
||
|
formats = []
|
||
5 years ago
|
locations = item.get('locations') or {}
|
||
9 years ago
|
for location in locations.get('adaptive', []):
|
||
5 years ago
|
manifest_url = location.get('src')
|
||
|
if not manifest_url:
|
||
|
continue
|
||
9 years ago
|
ext = determine_ext(manifest_url)
|
||
|
if ext == 'm3u8':
|
||
|
formats.extend(self._extract_m3u8_formats(
|
||
9 years ago
|
manifest_url, video_id, ext='mp4', m3u8_id='hls', fatal=False))
|
||
9 years ago
|
elif ext == 'mpd':
|
||
9 years ago
|
formats.extend(self._extract_mpd_formats(
|
||
|
manifest_url, video_id, mpd_id='dash', fatal=False))
|
||
9 years ago
|
else:
|
||
|
self.report_warning('Unknown adaptive format %s' % ext)
|
||
|
for location in locations.get('progressive', []):
|
||
5 years ago
|
src = try_get(location, lambda x: x['sources'][0]['src'])
|
||
|
if not src:
|
||
|
continue
|
||
|
label = location.get('label')
|
||
9 years ago
|
formats.append({
|
||
5 years ago
|
'url': src,
|
||
|
'width': int_or_none(location.get('width')),
|
||
|
'height': int_or_none(location.get('height')),
|
||
|
'format_id': 'http' + ('-%s' % label if label else ''),
|
||
9 years ago
|
})
|
||
|
|
||
|
self._sort_formats(formats)
|
||
10 years ago
|
|
||
9 years ago
|
return {
|
||
|
'id': video_id,
|
||
|
'title': title,
|
||
5 years ago
|
'description': item.get('description'),
|
||
9 years ago
|
'formats': formats,
|
||
5 years ago
|
'duration': int_or_none(item.get('duration')),
|
||
|
'thumbnail': item.get('poster'),
|
||
|
'timestamp': parse_iso8601(item.get('datecreated'), ' '),
|
||
9 years ago
|
}
|