Fix `preload_download_archive` writing verbose message to `stdout`

* And move it after all deprecated warnings
This commit is contained in:
pukkandan 2021-05-03 16:01:20 +05:30
parent 1815d1028b
commit 4cd0a709aa
No known key found for this signature in database
GPG Key ID: 0F00D95A001F4698
1 changed files with 20 additions and 22 deletions

View File

@ -462,35 +462,14 @@ class YoutubeDL(object):
}
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 @@ class YoutubeDL(object):
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()