aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Garcia <sarbalap+freshmeat@gmail.com>2009-02-04 21:38:31 +0100
committerRicardo Garcia <sarbalap+freshmeat@gmail.com>2010-10-31 11:23:48 +0100
commit0beeff4b3e208d15869823df65f50be43c282403 (patch)
treea1fae6703f80dee66ae24a2e88dd38bd5b773905
parent64a6f26c5d3720b36a7486dc9883ec74f0e4a3b2 (diff)
Add que -w or --no-overwrites option
-rwxr-xr-xyoutube-dl7
1 files changed, 7 insertions, 0 deletions
diff --git a/youtube-dl b/youtube-dl
index f4f64013d..de6c7a1d1 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
@@ -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:
@@ -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)