diff --git a/youtube-dl b/youtube-dl index 7eaafdcd5..f89c544cc 100755 --- a/youtube-dl +++ b/youtube-dl @@ -179,12 +179,15 @@ class FileDownloader(object): def to_stdout(self, message, skip_eol=False): """Print message to stdout if not in quiet mode.""" if not self._params.get('quiet', False): - sys.stdout.write('%s%s' % (message, ['\n', ''][skip_eol])) + if skip_eol: + print message, + else: + print message sys.stdout.flush() def to_stderr(self, message): """Print message to stderr.""" - sys.stderr.write('%s\n' % message) + print >>sys.stderr, message def fixed_template(self): """Checks if the output template is fixed.""" @@ -220,16 +223,16 @@ class FileDownloader(object): def report_destination(self, filename): """Report destination filename.""" - self.to_stdout('[download] Destination: %s' % filename) + self.to_stdout(u'[download] Destination: %s' % filename) def report_progress(self, percent_str, data_len_str, speed_str, eta_str): """Report download progress.""" - self.to_stdout('\r[download] %s of %s at %s ETA %s' % + self.to_stdout(u'\r[download] %s of %s at %s ETA %s' % (percent_str, data_len_str, speed_str, eta_str), skip_eol=True) def report_finish(self): """Report download finished.""" - self.to_stdout('') + self.to_stdout(u'') def download(self, url_list): """Download a given list of URLs.""" @@ -386,7 +389,7 @@ class InfoExtractor(object): def to_stderr(self, message): """Print message to stderr.""" - sys.stderr.write('%s\n' % message) + print >>sys.stderr, message def _real_initialize(self): """Real initialization process. Redefine in subclasses.""" @@ -410,23 +413,23 @@ class YoutubeIE(InfoExtractor): def report_login(self): """Report attempt to log in.""" - self.to_stdout('[youtube] Logging in') + self.to_stdout(u'[youtube] Logging in') def report_age_confirmation(self): """Report attempt to confirm age.""" - self.to_stdout('[youtube] Confirming age') + self.to_stdout(u'[youtube] Confirming age') def report_webpage_download(self, video_id): """Report attempt to download webpage.""" - self.to_stdout('[youtube] %s: Downloading video webpage' % video_id) + self.to_stdout(u'[youtube] %s: Downloading video webpage' % video_id) def report_information_extraction(self, video_id): """Report attempt to extract video information.""" - self.to_stdout('[youtube] %s: Extracting video information' % video_id) + self.to_stdout(u'[youtube] %s: Extracting video information' % video_id) def report_video_url(self, video_id, video_real_url): """Report extracted video URL.""" - self.to_stdout('[youtube] %s: URL: %s' % (video_id, video_real_url)) + self.to_stdout(u'[youtube] %s: URL: %s' % (video_id, video_real_url)) def _real_initialize(self): if self._downloader is None: @@ -449,7 +452,7 @@ class YoutubeIE(InfoExtractor): else: raise netrc.NetrcParseError('No authenticators for %s' % self._NETRC_MACHINE) except (IOError, netrc.NetrcParseError), err: - self.to_stderr('WARNING: parsing .netrc: %s' % str(err)) + self.to_stderr(u'WARNING: parsing .netrc: %s' % str(err)) return # No authentication to be performed @@ -469,10 +472,10 @@ class YoutubeIE(InfoExtractor): self.report_login() login_results = urllib2.urlopen(request).read() if re.search(r'(?i)