Add break on existing option

This commit is contained in:
Yoav Shai 2018-10-18 17:12:37 +03:00
parent b99b0bcfa0
commit fdceeb43ce
3 changed files with 13 additions and 1 deletions

View File

@ -176,6 +176,8 @@ Alternatively, refer to the [developer instructions](#developer-instructions) fo
--download-archive FILE Download only videos not listed in the --download-archive FILE Download only videos not listed in the
archive file. Record the IDs of all archive file. Record the IDs of all
downloaded videos in it. downloaded videos in it.
--break-on-existing Stop the download process after attempting
to download a file that's in the archive.
--include-ads Download advertisements as well --include-ads Download advertisements as well
(experimental) (experimental)

View File

@ -205,6 +205,8 @@ class YoutubeDL(object):
download_archive: File name of a file where all downloads are recorded. download_archive: File name of a file where all downloads are recorded.
Videos already present in the file are not downloaded Videos already present in the file are not downloaded
again. again.
break_on_existing: Stop the download process after attempting to download a file that's
in the archive.
cookiefile: File name where cookies should be read from and dumped to. cookiefile: File name where cookies should be read from and dumped to.
nocheckcertificate:Do not verify SSL certificates nocheckcertificate:Do not verify SSL certificates
prefer_insecure: Use HTTP instead of HTTPS to retrieve information. prefer_insecure: Use HTTP instead of HTTPS to retrieve information.
@ -993,7 +995,11 @@ class YoutubeDL(object):
} }
reason = self._match_entry(entry, incomplete=True) reason = self._match_entry(entry, incomplete=True)
if reason is not None: if reason.endswith('has already been recorded in archive') and self.params.get('break_on_existing'):
self.to_screen('[download] stopping downloading because ' + reason)
break
elif reason is not None:
self.to_screen('[download] ' + reason) self.to_screen('[download] ' + reason)
continue continue

View File

@ -344,6 +344,10 @@ def parseOpts(overrideArguments=None):
'--download-archive', metavar='FILE', '--download-archive', metavar='FILE',
dest='download_archive', dest='download_archive',
help='Download only videos not listed in the archive file. Record the IDs of all downloaded videos in it.') help='Download only videos not listed in the archive file. Record the IDs of all downloaded videos in it.')
selection.add_option(
'--break-on-existing',
action='store_true', dest='break_on_existing', default=False,
help="Stop the download process after attempting to download a file that's in the archive.")
selection.add_option( selection.add_option(
'--include-ads', '--include-ads',
dest='include_ads', action='store_true', dest='include_ads', action='store_true',