From a13a1d170f9e58692380f237410b69eccff010c3 Mon Sep 17 00:00:00 2001 From: Maxence Ardouin Date: Sun, 22 Apr 2012 19:25:25 +0200 Subject: [PATCH] Added display of video file size information. Info will be displayed even with --skip-download option --- youtube-dl | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/youtube-dl b/youtube-dl index 375c93e74..e08665086 100755 --- a/youtube-dl +++ b/youtube-dl @@ -850,27 +850,26 @@ class FileDownloader(object): self.trouble(u'ERROR: Cannot write metadata to JSON file ' + infofn) return - if not self.params.get('skip_download', False): - if self.params.get('nooverwrites', False) and os.path.exists(_encodeFilename(filename)): - success = True - else: - try: - success = self._do_download(filename, info_dict) - except (OSError, IOError), err: - raise UnavailableVideoError - except (urllib2.URLError, httplib.HTTPException, socket.error), err: - self.trouble(u'ERROR: unable to download video data: %s' % str(err)) - return - except (ContentTooShortError, ), err: - self.trouble(u'ERROR: content too short (expected %s bytes and served %s)' % (err.expected, err.downloaded)) - return - - if success: - try: - self.post_process(filename, info_dict) - except (PostProcessingError), err: - self.trouble(u'ERROR: postprocessing: %s' % str(err)) - return + if self.params.get('nooverwrites', False) and os.path.exists(_encodeFilename(filename)): + success = True + else: + try: + success = self._do_download(filename, info_dict) + except (OSError, IOError), err: + raise UnavailableVideoError + except (urllib2.URLError, httplib.HTTPException, socket.error), err: + self.trouble(u'ERROR: unable to download video data: %s' % str(err)) + return + except (ContentTooShortError, ), err: + self.trouble(u'ERROR: content too short (expected %s bytes and served %s)' % (err.expected, err.downloaded)) + return + + if success: + try: + self.post_process(filename, info_dict) + except (PostProcessingError), err: + self.trouble(u'ERROR: postprocessing: %s' % str(err)) + return def download(self, url_list): """Download a given list of URLs.""" @@ -1039,6 +1038,9 @@ class FileDownloader(object): return False data_len = data.info().get('Content-length', None) + print '[youtube] File size: ' + data_len + ' bytes' + if self.params.get('skip_download', False): + return True; if data_len is not None: data_len = long(data_len) + resume_len data_len_str = self.format_bytes(data_len)