From 4cd0a709aa4cd388cae0795070bfdf26e97ec18c Mon Sep 17 00:00:00 2001 From: pukkandan Date: Mon, 3 May 2021 16:01:20 +0530 Subject: [PATCH] Fix `preload_download_archive` writing verbose message to `stdout` * And move it after all deprecated warnings --- yt_dlp/YoutubeDL.py | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 1532171e0..56ebc5067 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -462,35 +462,14 @@ def __init__(self, params=None, auto_init=True): } self.params.update(params) self.cache = Cache(self) - self.archive = set() - - """Preload the archive, if any is specified""" - def preload_download_archive(self): - fn = self.params.get('download_archive') - if fn is None: - return False - try: - with locked_file(fn, 'r', encoding='utf-8') as archive_file: - for line in archive_file: - self.archive.add(line.strip()) - except IOError as ioe: - if ioe.errno != errno.ENOENT: - raise - return False - return True def check_deprecated(param, option, suggestion): if self.params.get(param) is not None: self.report_warning( - '%s is deprecated. Use %s instead.' % (option, suggestion)) + '%s is deprecated. Use %s instead' % (option, suggestion)) return True return False - if self.params.get('verbose'): - self.to_stdout('[debug] Loading archive file %r' % self.params.get('download_archive')) - - preload_download_archive(self) - if check_deprecated('cn_verification_proxy', '--cn-verification-proxy', '--geo-verification-proxy'): if self.params.get('geo_verification_proxy') is None: self.params['geo_verification_proxy'] = self.params['cn_verification_proxy'] @@ -548,6 +527,25 @@ def check_deprecated(param, option, suggestion): self._setup_opener() + """Preload the archive, if any is specified""" + def preload_download_archive(fn): + if fn is None: + return False + if self.params.get('verbose'): + self._write_string('[debug] Loading archive file %r\n' % fn) + try: + with locked_file(fn, 'r', encoding='utf-8') as archive_file: + for line in archive_file: + self.archive.add(line.strip()) + except IOError as ioe: + if ioe.errno != errno.ENOENT: + raise + return False + return True + + self.archive = set() + preload_download_archive(self.params.get('download_archive')) + if auto_init: self.print_debug_header() self.add_default_info_extractors()