mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-05 02:19:36 +02:00
Add only_once
param for report_warning
Related: https://github.com/yt-dlp/yt-dlp/pull/488#discussion_r667527297
This commit is contained in:
parent
50fed816dd
commit
c84aeac6b5
@ -450,7 +450,7 @@ class YoutubeDL(object):
|
|||||||
params = None
|
params = None
|
||||||
_ies = []
|
_ies = []
|
||||||
_pps = {'pre_process': [], 'before_dl': [], 'after_move': [], 'post_process': []}
|
_pps = {'pre_process': [], 'before_dl': [], 'after_move': [], 'post_process': []}
|
||||||
__prepare_filename_warned = False
|
_reported_warnings = set()
|
||||||
_first_webpage_request = True
|
_first_webpage_request = True
|
||||||
_download_retcode = None
|
_download_retcode = None
|
||||||
_num_downloads = None
|
_num_downloads = None
|
||||||
@ -465,7 +465,7 @@ def __init__(self, params=None, auto_init=True):
|
|||||||
self._ies = []
|
self._ies = []
|
||||||
self._ies_instances = {}
|
self._ies_instances = {}
|
||||||
self._pps = {'pre_process': [], 'before_dl': [], 'after_move': [], 'post_process': []}
|
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._first_webpage_request = True
|
||||||
self._post_hooks = []
|
self._post_hooks = []
|
||||||
self._progress_hooks = []
|
self._progress_hooks = []
|
||||||
@ -755,11 +755,15 @@ def to_screen(self, message, skip_eol=False):
|
|||||||
self.to_stdout(
|
self.to_stdout(
|
||||||
message, skip_eol, quiet=self.params.get('quiet', False))
|
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:'
|
Print the message to stderr, it will be prefixed with 'WARNING:'
|
||||||
If stderr is a tty file the 'WARNING:' will be colored
|
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:
|
if self.params.get('logger') is not None:
|
||||||
self.params['logger'].warning(message)
|
self.params['logger'].warning(message)
|
||||||
else:
|
else:
|
||||||
@ -1017,13 +1021,13 @@ def prepare_filename(self, info_dict, dir_type='', warn=False):
|
|||||||
|
|
||||||
filename = self._prepare_filename(info_dict, dir_type or 'default')
|
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'):
|
if not self.params.get('paths'):
|
||||||
pass
|
pass
|
||||||
elif filename == '-':
|
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):
|
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
|
self.__prepare_filename_warned = True
|
||||||
if filename == '-' or not filename:
|
if filename == '-' or not filename:
|
||||||
return filename
|
return filename
|
||||||
|
Loading…
Reference in New Issue
Block a user