From f40ee5e9a0014b308cc83d8d3a0e24a123239eb4 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Sun, 23 Jan 2022 23:24:24 +0530 Subject: [extractor] Add convinience function `_yes_playlist` --- yt_dlp/extractor/common.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'yt_dlp/extractor/common.py') diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py index 74114e355..77e358bbe 100644 --- a/yt_dlp/extractor/common.py +++ b/yt_dlp/extractor/common.py @@ -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): """ -- cgit v1.2.3