X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=youtube-dl;h=323897a9c336882a86a74e006e37100748d06cfd;hb=5121ef207112040fdf58e889393071aeb51cf4f2;hp=f4f64013dce2551f680bce3b23a62ae3f8e13260;hpb=64a6f26c5d3720b36a7486dc9883ec74f0e4a3b2;p=youtube-dl.git diff --git a/youtube-dl b/youtube-dl index f4f64013d..323897a9c 100755 --- a/youtube-dl +++ b/youtube-dl @@ -89,6 +89,7 @@ class FileDownloader(object): outtmpl: Template for output names. ignoreerrors: Do not stop on download errors. ratelimit: Download speed limit, in bytes/sec. + nooverwrites: Prevent overwriting files. """ _params = None @@ -143,7 +144,7 @@ class FileDownloader(object): return '--:--' return '%02d:%02d' % (eta_mins, eta_secs) - @staticmethod + @staticmethod def calc_speed(start, now, bytes): dif = now - start if bytes == 0 or dif < 0.001: # One millisecond @@ -286,6 +287,9 @@ class FileDownloader(object): except (ValueError, KeyError), err: retcode = self.trouble('ERROR: invalid output template or system charset: %s' % str(err)) continue + if self._params['nooverwrites'] and os.path.exists(filename): + self.to_stderr('WARNING: file exists: %s; skipping' % filename) + continue try: self.pmkdir(filename) except (OSError, IOError), err: @@ -937,7 +941,7 @@ if __name__ == '__main__': # Parse command line parser = optparse.OptionParser( usage='Usage: %prog [options] url...', - version='2009.01.31', + version='2009.02.07', conflict_handler='resolve', ) parser.add_option('-h', '--help', @@ -976,6 +980,8 @@ if __name__ == '__main__': dest='ratelimit', metavar='L', help='download rate limit (e.g. 50k or 44.6m)') parser.add_option('-a', '--batch-file', dest='batchfile', metavar='F', help='file containing URLs to download') + parser.add_option('-w', '--no-overwrites', + action='store_true', dest='nooverwrites', help='do not overwrite files', default=False) (opts, args) = parser.parse_args() # Batch file verification @@ -1031,6 +1037,7 @@ if __name__ == '__main__': or u'%(id)s.%(ext)s'), 'ignoreerrors': opts.ignoreerrors, 'ratelimit': opts.ratelimit, + 'nooverwrites': opts.nooverwrites, }) fd.add_info_extractor(youtube_search_ie) fd.add_info_extractor(youtube_pl_ie)