Skip to content

Commit

Permalink
Fix preload_download_archive writing verbose message to stdout
Browse files Browse the repository at this point in the history
* And move it after all deprecated warnings
  • Loading branch information
pukkandan committed May 3, 2021
1 parent 1815d10 commit 4cd0a70
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions yt_dlp/YoutubeDL.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 4cd0a70

Please sign in to comment.