From 7311fef854632130af5edcae7f6762f0fedbaccb Mon Sep 17 00:00:00 2001 From: Gino Lisignoli Date: Wed, 13 Feb 2013 14:02:31 +1300 Subject: [PATCH] Modified youtube-dl to write new lines with the --newline switch. This enables easier process monitoring when being called with external scripts. --- youtube_dl/FileDownloader.py | 5 ++++- youtube_dl/__init__.py | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/youtube_dl/FileDownloader.py b/youtube_dl/FileDownloader.py index 4f51ed8b03..ca047ba4c7 100644 --- a/youtube_dl/FileDownloader.py +++ b/youtube_dl/FileDownloader.py @@ -305,7 +305,10 @@ def report_progress(self, percent_str, data_len_str, speed_str, eta_str): """Report download progress.""" if self.params.get('noprogress', False): return - self.to_screen(u'\r[download] %s of %s at %s ETA %s' % + if self.params.get('newline', True): + self.to_screen(u'\r[download] %s of %s at %s ETA %s' % + (percent_str, data_len_str, speed_str, eta_str)) + else: self.to_screen(u'\r[download] %s of %s at %s ETA %s' % (percent_str, data_len_str, speed_str, eta_str), skip_eol=True) self.to_cons_title(u'youtube-dl - %s of %s at %s ETA %s' % (percent_str.strip(), data_len_str.strip(), speed_str.strip(), eta_str.strip())) diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index abcb4f1655..38b5fb163a 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -202,6 +202,8 @@ def _find_term_columns(): verbosity.add_option('--get-format', action='store_true', dest='getformat', help='simulate, quiet but print output format', default=False) + verbosity.add_option('--newline', + action='store_true', dest='newline', help='Output progress bar as new lines', default=False) verbosity.add_option('--no-progress', action='store_true', dest='noprogress', help='do not print progress bar', default=False) verbosity.add_option('--console-title', @@ -210,7 +212,6 @@ def _find_term_columns(): verbosity.add_option('-v', '--verbose', action='store_true', dest='verbose', help='print various debugging information', default=False) - filesystem.add_option('-t', '--title', action='store_true', dest='usetitle', help='use title in file name', default=False) filesystem.add_option('--id',