From fdceeb43ced3c5f6ff58dae2cadbb30f031f42ce Mon Sep 17 00:00:00 2001 From: Yoav Shai Date: Thu, 18 Oct 2018 17:12:37 +0300 Subject: [PATCH] Add break on existing option --- README.md | 2 ++ youtube_dl/YoutubeDL.py | 8 +++++++- youtube_dl/options.py | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fdd115c9b..a49067cfd 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,8 @@ Alternatively, refer to the [developer instructions](#developer-instructions) fo --download-archive FILE Download only videos not listed in the archive file. Record the IDs of all 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 (experimental) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 38ba43a97..68279e0fd 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -205,6 +205,8 @@ class YoutubeDL(object): download_archive: File name of a file where all downloads are recorded. Videos already present in the file are not downloaded 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. nocheckcertificate:Do not verify SSL certificates prefer_insecure: Use HTTP instead of HTTPS to retrieve information. @@ -993,7 +995,11 @@ class YoutubeDL(object): } 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) continue diff --git a/youtube_dl/options.py b/youtube_dl/options.py index e7d8e8910..5e382755f 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -344,6 +344,10 @@ def parseOpts(overrideArguments=None): '--download-archive', metavar='FILE', dest='download_archive', 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( '--include-ads', dest='include_ads', action='store_true',