A feature-rich command-line audio/video downloader
Add `only_once` param for `report_warning` Related: https://github.com/yt-dlp/yt-dlp/pull/488#discussion_r667527297
pukkandanc84aeac6b569
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.pyindex 9da607b17c..3dfab69b2d 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 = Trueself._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'):passelif 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 = Trueif filename == '-' or not filename:return filename