aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/YoutubeDL.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2021-07-21 01:35:35 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2021-07-21 01:39:58 +0530
commitc84aeac6b5695e7e1ac629d17fc51eb68ab91bae (patch)
tree9946204776d6021df4e10b7260002a676af0fb34 /yt_dlp/YoutubeDL.py
parent50fed816dd5ae970d69d8997eb854d475ed91ede (diff)
downloadhypervideo-pre-c84aeac6b5695e7e1ac629d17fc51eb68ab91bae.tar.lz
hypervideo-pre-c84aeac6b5695e7e1ac629d17fc51eb68ab91bae.tar.xz
hypervideo-pre-c84aeac6b5695e7e1ac629d17fc51eb68ab91bae.zip
Add `only_once` param for `report_warning`
Related: https://github.com/yt-dlp/yt-dlp/pull/488#discussion_r667527297
Diffstat (limited to 'yt_dlp/YoutubeDL.py')
-rw-r--r--yt_dlp/YoutubeDL.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index 9da607b17..3dfab69b2 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -450,7 +450,7 @@ class YoutubeDL(object):
params = None
_ies = []
_pps = {'pre_process': [], 'before_dl': [], 'after_move': [], 'post_process': []}
- __prepare_filename_warned = False
+ _reported_warnings = set()
_first_webpage_request = True
_download_retcode = None
_num_downloads = None
@@ -465,7 +465,7 @@ class YoutubeDL(object):
self._ies = []
self._ies_instances = {}
self._pps = {'pre_process': [], 'before_dl': [], 'after_move': [], 'post_process': []}
- self.__prepare_filename_warned = False
+ self._reported_warnings = set()
self._first_webpage_request = True
self._post_hooks = []
self._progress_hooks = []
@@ -755,11 +755,15 @@ class YoutubeDL(object):
self.to_stdout(
message, skip_eol, quiet=self.params.get('quiet', False))
- def report_warning(self, message):
+ def report_warning(self, message, only_once=False):
'''
Print the message to stderr, it will be prefixed with 'WARNING:'
If stderr is a tty file the 'WARNING:' will be colored
'''
+ if only_once:
+ if message in self._reported_warnings:
+ return
+ self._reported_warnings.add(message)
if self.params.get('logger') is not None:
self.params['logger'].warning(message)
else:
@@ -1017,13 +1021,13 @@ class YoutubeDL(object):
filename = self._prepare_filename(info_dict, dir_type or 'default')
- if warn and not self.__prepare_filename_warned:
+ if warn:
if not self.params.get('paths'):
pass
elif filename == '-':
- self.report_warning('--paths is ignored when an outputting to stdout')
+ self.report_warning('--paths is ignored when an outputting to stdout', only_once=True)
elif os.path.isabs(filename):
- self.report_warning('--paths is ignored since an absolute path is given in output template')
+ self.report_warning('--paths is ignored since an absolute path is given in output template', only_once=True)
self.__prepare_filename_warned = True
if filename == '-' or not filename:
return filename