|
@@ -4,21 +4,25 @@ from __future__ import unicode_literals
|
|
from .common import InfoExtractor
|
|
from .common import InfoExtractor
|
|
from ..utils import (
|
|
from ..utils import (
|
|
determine_ext,
|
|
determine_ext,
|
|
- remove_end,
|
|
|
|
|
|
+ int_or_none,
|
|
|
|
+ parse_iso8601,
|
|
|
|
+ try_get,
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
class TelegraafIE(InfoExtractor):
|
|
class TelegraafIE(InfoExtractor):
|
|
- _VALID_URL = r'https?://(?:www\.)?telegraaf\.nl/tv/(?:[^/]+/)+(?P<id>\d+)/[^/]+\.html'
|
|
|
|
|
|
+ _VALID_URL = r'https?://(?:www\.)?telegraaf\.nl/video/(?P<id>\d+)'
|
|
_TEST = {
|
|
_TEST = {
|
|
- 'url': 'http://www.telegraaf.nl/tv/nieuws/binnenland/24353229/__Tikibad_ontruimd_wegens_brand__.html',
|
|
|
|
|
|
+ 'url': 'https://www.telegraaf.nl/video/734366489/historisch-scheepswrak-slaat-na-100-jaar-los',
|
|
'info_dict': {
|
|
'info_dict': {
|
|
- 'id': '24353229',
|
|
|
|
|
|
+ 'id': 'gaMItuoSeUg2',
|
|
'ext': 'mp4',
|
|
'ext': 'mp4',
|
|
- 'title': 'Tikibad ontruimd wegens brand',
|
|
|
|
- 'description': 'md5:05ca046ff47b931f9b04855015e163a4',
|
|
|
|
- 'thumbnail': r're:^https?://.*\.jpg$',
|
|
|
|
- 'duration': 33,
|
|
|
|
|
|
+ 'title': 'Historisch scheepswrak slaat na 100 jaar los',
|
|
|
|
+ 'description': 'md5:6f53b7c4f55596722ac24d6c0ec00cfb',
|
|
|
|
+ 'thumbnail': r're:^https?://.*\.jpg',
|
|
|
|
+ 'duration': 55,
|
|
|
|
+ 'timestamp': 1572805527,
|
|
|
|
+ 'upload_date': '20191103',
|
|
},
|
|
},
|
|
'params': {
|
|
'params': {
|
|
# m3u8 download
|
|
# m3u8 download
|
|
@@ -27,23 +31,30 @@ class TelegraafIE(InfoExtractor):
|
|
}
|
|
}
|
|
|
|
|
|
def _real_extract(self, url):
|
|
def _real_extract(self, url):
|
|
- video_id = self._match_id(url)
|
|
|
|
|
|
+ article_id = self._match_id(url)
|
|
|
|
|
|
- webpage = self._download_webpage(url, video_id)
|
|
|
|
|
|
+ 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']
|
|
|
|
|
|
- player_url = self._html_search_regex(
|
|
|
|
- r'<iframe[^>]+src="([^"]+")', webpage, 'player URL')
|
|
|
|
- player_page = self._download_webpage(
|
|
|
|
- player_url, video_id, note='Download player webpage')
|
|
|
|
- playlist_url = self._search_regex(
|
|
|
|
- r'playlist\s*:\s*"([^"]+)"', player_page, 'playlist URL')
|
|
|
|
- playlist_data = self._download_json(playlist_url, video_id)
|
|
|
|
|
|
+ item = self._download_json(
|
|
|
|
+ 'https://content.tmgvideo.nl/playlist/item=%s/playlist.json' % video_id,
|
|
|
|
+ video_id)['items'][0]
|
|
|
|
+ title = item['title']
|
|
|
|
|
|
- item = playlist_data['items'][0]
|
|
|
|
formats = []
|
|
formats = []
|
|
- locations = item['locations']
|
|
|
|
|
|
+ locations = item.get('locations') or {}
|
|
for location in locations.get('adaptive', []):
|
|
for location in locations.get('adaptive', []):
|
|
- manifest_url = location['src']
|
|
|
|
|
|
+ manifest_url = location.get('src')
|
|
|
|
+ if not manifest_url:
|
|
|
|
+ continue
|
|
ext = determine_ext(manifest_url)
|
|
ext = determine_ext(manifest_url)
|
|
if ext == 'm3u8':
|
|
if ext == 'm3u8':
|
|
formats.extend(self._extract_m3u8_formats(
|
|
formats.extend(self._extract_m3u8_formats(
|
|
@@ -54,25 +65,25 @@ class TelegraafIE(InfoExtractor):
|
|
else:
|
|
else:
|
|
self.report_warning('Unknown adaptive format %s' % ext)
|
|
self.report_warning('Unknown adaptive format %s' % ext)
|
|
for location in locations.get('progressive', []):
|
|
for location in locations.get('progressive', []):
|
|
|
|
+ src = try_get(location, lambda x: x['sources'][0]['src'])
|
|
|
|
+ if not src:
|
|
|
|
+ continue
|
|
|
|
+ label = location.get('label')
|
|
formats.append({
|
|
formats.append({
|
|
- 'url': location['sources'][0]['src'],
|
|
|
|
- 'width': location.get('width'),
|
|
|
|
- 'height': location.get('height'),
|
|
|
|
- 'format_id': 'http-%s' % location['label'],
|
|
|
|
|
|
+ 'url': src,
|
|
|
|
+ 'width': int_or_none(location.get('width')),
|
|
|
|
+ 'height': int_or_none(location.get('height')),
|
|
|
|
+ 'format_id': 'http' + ('-%s' % label if label else ''),
|
|
})
|
|
})
|
|
|
|
|
|
self._sort_formats(formats)
|
|
self._sort_formats(formats)
|
|
|
|
|
|
- title = remove_end(self._og_search_title(webpage), ' - VIDEO')
|
|
|
|
- description = self._og_search_description(webpage)
|
|
|
|
- duration = item.get('duration')
|
|
|
|
- thumbnail = item.get('poster')
|
|
|
|
-
|
|
|
|
return {
|
|
return {
|
|
'id': video_id,
|
|
'id': video_id,
|
|
'title': title,
|
|
'title': title,
|
|
- 'description': description,
|
|
|
|
|
|
+ 'description': item.get('description'),
|
|
'formats': formats,
|
|
'formats': formats,
|
|
- 'duration': duration,
|
|
|
|
- 'thumbnail': thumbnail,
|
|
|
|
|
|
+ 'duration': int_or_none(item.get('duration')),
|
|
|
|
+ 'thumbnail': item.get('poster'),
|
|
|
|
+ 'timestamp': parse_iso8601(item.get('datecreated'), ' '),
|
|
}
|
|
}
|