1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-10-29 21:57:50 +00:00

[extractor] Add convinience function _yes_playlist

This commit is contained in:
pukkandan
2022-01-23 23:24:24 +05:30
parent 1f13021eca
commit f40ee5e9a0
12 changed files with 49 additions and 87 deletions

View File

@@ -3710,6 +3710,22 @@ class InfoExtractor(object):
return [] if default is NO_DEFAULT else default
return list(val) if casesense else [x.lower() for x in val]
def _yes_playlist(self, playlist_id, video_id, smuggled_data=None, *, playlist_label='playlist', video_label='video'):
if not playlist_id or not video_id:
return not video_id
no_playlist = (smuggled_data or {}).get('force_noplaylist')
if no_playlist is not None:
return not no_playlist
video_id = '' if video_id is True else f' {video_id}'
playlist_id = '' if playlist_id is True else f' {playlist_id}'
if self.get_param('noplaylist'):
self.to_screen(f'Downloading just the {video_label}{video_id} because of --no-playlist')
return False
self.to_screen(f'Downloading {playlist_label}{playlist_id} - add --no-playlist to download just the {video_label}{video_id}')
return True
class SearchInfoExtractor(InfoExtractor):
"""