diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-01-23 23:24:24 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-01-24 01:07:14 +0530 |
commit | f40ee5e9a0014b308cc83d8d3a0e24a123239eb4 (patch) | |
tree | a9ce83f69e44d1a63344b115e380f01286012ea1 /yt_dlp/extractor/common.py | |
parent | 1f13021eca0ecc5a6bd34ffd5bf69aa5a8cb8a5a (diff) |
[extractor] Add convinience function `_yes_playlist`
Diffstat (limited to 'yt_dlp/extractor/common.py')
-rw-r--r-- | yt_dlp/extractor/common.py | 16 |
1 files changed, 16 insertions, 0 deletions
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): """ |