Extract playlist metadata

This commit is contained in:
InvalidUsernameException 2024-09-18 20:53:09 +02:00
parent 8c27ce471d
commit 6b6f97f3c9

View File

@ -413,6 +413,13 @@ def _extract_document_id(self, webpage):
matches = re.search(r'docId\s*:\s*[\'"](?P<docid>[^\'"]+)[\'"]', webpage) matches = re.search(r'docId\s*:\s*[\'"](?P<docid>[^\'"]+)[\'"]', webpage)
return matches and matches.group('docid') return matches and matches.group('docid')
def _get_playlist_description(self, page_data):
headline = traverse_obj(page_data, ('shortText', 'headline'))
text = traverse_obj(page_data, ('shortText', 'text'))
if headline is not None and text is not None:
return f'{headline}\n\n{text}'
return headline or text
def _real_extract(self, url): def _real_extract(self, url):
channel_id = self._match_id(url) channel_id = self._match_id(url)
@ -439,8 +446,24 @@ def _real_extract(self, url):
if self._downloader.params.get('noplaylist', False): if self._downloader.params.get('noplaylist', False):
return self.url_result(main_video) return self.url_result(main_video)
else:
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')
return self.playlist_from_matches(
playlist_videos, channel_id, thumbnails = (
self._og_search_title(webpage, fatal=False)) traverse_obj(data, ('document', 'image'))
or traverse_obj(data, ('document', 'teaserBild'))
or traverse_obj(data, ('stageHeader', 'image'))
or {})
thumbnails = [{
'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'))]
return self.playlist_from_matches(
playlist_videos, playlist_id=channel_id,
playlist_title=self._og_search_title(webpage, fatal=False),
description=self._get_playlist_description(data),
thumbnails=thumbnails, ie=ZDFIE.ie_key())