[downloader] Fix `quiet` and `to_stderr`

pull/310/head
pukkandan 4 years ago
parent 3158150cb7
commit 848887eb7a
No known key found for this signature in database
GPG Key ID: 0F00D95A001F4698

@ -642,16 +642,18 @@ class YoutubeDL(object):
def to_screen(self, message, skip_eol=False): def to_screen(self, message, skip_eol=False):
"""Print message to stdout if not in quiet mode.""" """Print message to stdout if not in quiet mode."""
return self.to_stdout(message, skip_eol, check_quiet=True) return self.to_stdout(
message, skip_eol,
quiet=self.params.get('quiet', False))
def _write_string(self, s, out=None): def _write_string(self, s, out=None):
write_string(s, out=out, encoding=self.params.get('encoding')) write_string(s, out=out, encoding=self.params.get('encoding'))
def to_stdout(self, message, skip_eol=False, check_quiet=False): def to_stdout(self, message, skip_eol=False, quiet=False):
"""Print message to stdout if not in quiet mode.""" """Print message to stdout if not in quiet mode."""
if self.params.get('logger'): if self.params.get('logger'):
self.params['logger'].debug(message) self.params['logger'].debug(message)
elif not check_quiet or not self.params.get('quiet', False): elif not quiet:
message = self._bidi_workaround(message) message = self._bidi_workaround(message)
terminator = ['\n', ''][skip_eol] terminator = ['\n', ''][skip_eol]
output = message + terminator output = message + terminator

@ -147,10 +147,10 @@ class FileDownloader(object):
return int(round(number * multiplier)) return int(round(number * multiplier))
def to_screen(self, *args, **kargs): def to_screen(self, *args, **kargs):
self.ydl.to_screen(*args, **kargs) self.ydl.to_stdout(*args, quiet=self.params.get('quiet'), **kargs)
def to_stderr(self, message): def to_stderr(self, message):
self.ydl.to_screen(message) self.ydl.to_stderr(message)
def to_console_title(self, message): def to_console_title(self, message):
self.ydl.to_console_title(message) self.ydl.to_console_title(message)

Loading…
Cancel
Save