mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-02 14:37:21 +00:00
Extract video entry info
This commit is contained in:
parent
6b6f97f3c9
commit
44f8f59c88
|
@ -420,6 +420,25 @@ def _get_playlist_description(self, page_data):
|
||||||
return f'{headline}\n\n{text}'
|
return f'{headline}\n\n{text}'
|
||||||
return headline or text
|
return headline or text
|
||||||
|
|
||||||
|
def _convert_thumbnails(self, thumbnails):
|
||||||
|
return [{
|
||||||
|
'id': key,
|
||||||
|
'url': thumbnail_info['url'],
|
||||||
|
'width': int_or_none(thumbnail_info.get('width')),
|
||||||
|
'height': int_or_none(thumbnail_info.get('height')),
|
||||||
|
} for key, thumbnail_info in thumbnails.items() if url_or_none(thumbnail_info.get('url'))]
|
||||||
|
|
||||||
|
def _teaser_to_url_result(self, teaser):
|
||||||
|
return self.url_result(
|
||||||
|
teaser['sharingUrl'], ie=ZDFIE.ie_key(),
|
||||||
|
id=teaser.get('id'), title=teaser.get('titel', ''),
|
||||||
|
thumbnails=self._convert_thumbnails(teaser.get('teaserBild', {})),
|
||||||
|
description=teaser.get('beschreibung'),
|
||||||
|
duration=float_or_none(teaser.get('length')),
|
||||||
|
media_type=teaser.get('currentVideoType') or teaser.get('contentType'),
|
||||||
|
season_number=int_or_none(teaser.get('seasonNumber')),
|
||||||
|
episode_number=int_or_none(teaser.get('episodeNumber')))
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
channel_id = self._match_id(url)
|
channel_id = self._match_id(url)
|
||||||
|
|
||||||
|
@ -437,15 +456,15 @@ def _real_extract(self, url):
|
||||||
for cluster in data['cluster']:
|
for cluster in data['cluster']:
|
||||||
for teaser in cluster['teaser']:
|
for teaser in cluster['teaser']:
|
||||||
if cluster['type'] == 'teaserContent' and teaser['type'] == 'video':
|
if cluster['type'] == 'teaserContent' and teaser['type'] == 'video':
|
||||||
main_video = main_video or teaser['sharingUrl']
|
main_video = main_video or teaser
|
||||||
elif cluster['type'] == 'teaser' and teaser['type'] == 'video':
|
elif cluster['type'] == 'teaser' and teaser['type'] == 'video':
|
||||||
if teaser['brandId'] != document_id:
|
if teaser['brandId'] != document_id:
|
||||||
# These are unrelated 'You might also like' videos, filter them out
|
# These are unrelated 'You might also like' videos, filter them out
|
||||||
continue
|
continue
|
||||||
playlist_videos.append(teaser['sharingUrl'])
|
playlist_videos.append(teaser)
|
||||||
|
|
||||||
if self._downloader.params.get('noplaylist', False):
|
if self._downloader.params.get('noplaylist', False):
|
||||||
return self.url_result(main_video)
|
return self._teaser_to_url_result(main_video) if main_video else None
|
||||||
|
|
||||||
self.to_screen(f'Downloading playlist {channel_id} - add --no-playlist to download just the main video')
|
self.to_screen(f'Downloading playlist {channel_id} - add --no-playlist to download just the main video')
|
||||||
|
|
||||||
|
@ -455,15 +474,9 @@ def _real_extract(self, url):
|
||||||
or traverse_obj(data, ('stageHeader', 'image'))
|
or traverse_obj(data, ('stageHeader', 'image'))
|
||||||
or {})
|
or {})
|
||||||
|
|
||||||
thumbnails = [{
|
return self.playlist_result(
|
||||||
'id': key,
|
(self._teaser_to_url_result(video) for video in playlist_videos),
|
||||||
'url': thumbnail_info['url'],
|
playlist_id=channel_id,
|
||||||
'width': int_or_none(thumbnail_info.get('width')),
|
|
||||||
'height': int_or_none(thumbnail_info.get('height')),
|
|
||||||
} for key, thumbnail_info in thumbnails.items() if url_or_none(thumbnail_info.get('url'))]
|
|
||||||
|
|
||||||
return self.playlist_from_matches(
|
|
||||||
playlist_videos, playlist_id=channel_id,
|
|
||||||
playlist_title=self._og_search_title(webpage, fatal=False),
|
playlist_title=self._og_search_title(webpage, fatal=False),
|
||||||
description=self._get_playlist_description(data),
|
description=self._get_playlist_description(data),
|
||||||
thumbnails=thumbnails, ie=ZDFIE.ie_key())
|
thumbnails=self._convert_thumbnails(thumbnails))
|
||||||
|
|
Loading…
Reference in a new issue