aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpukkandan <pukkandan@users.noreply.github.com>2020-09-21 20:56:18 +0530
committerpukkandan <pukkandan@gmail.com>2020-11-13 14:19:00 +0530
commitea6e0c2b0d3e83f2f8a7766e07a57a2b5495afcc (patch)
tree8bb8b535426bbccf9ae18be7c0a29dc3805a9e88
parentd052b9a112fb7ae749a829dceba6e3289663a303 (diff)
downloadhypervideo-pre-ea6e0c2b0d3e83f2f8a7766e07a57a2b5495afcc.tar.lz
hypervideo-pre-ea6e0c2b0d3e83f2f8a7766e07a57a2b5495afcc.tar.xz
hypervideo-pre-ea6e0c2b0d3e83f2f8a7766e07a57a2b5495afcc.zip
Add --break-on-existing by @gergesh
Authored-by: Yoav Shai <gergesh@gmail.com>
-rw-r--r--README.md2
-rw-r--r--youtube_dlc/YoutubeDL.py10
-rw-r--r--youtube_dlc/__init__.py1
-rw-r--r--youtube_dlc/options.py4
4 files changed, 15 insertions, 2 deletions
diff --git a/README.md b/README.md
index f884ad067..170c85c48 100644
--- a/README.md
+++ b/README.md
@@ -217,6 +217,8 @@ I will add some memorable short links to the binaries so you can download them e
--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_dlc/YoutubeDL.py b/youtube_dlc/YoutubeDL.py
index dd55ba0f2..1cb1b421a 100644
--- a/youtube_dlc/YoutubeDL.py
+++ b/youtube_dlc/YoutubeDL.py
@@ -210,6 +210,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.
@@ -1038,8 +1040,12 @@ class YoutubeDL(object):
reason = self._match_entry(entry, incomplete=True)
if reason is not None:
- self.to_screen('[download] ' + reason)
- continue
+ if reason.endswith('has already been recorded in the archive') and self.params.get('break_on_existing'):
+ print('[download] tried downloading a file that\'s already in the archive, stopping since --break-on-existing is set.')
+ break
+ else:
+ self.to_screen('[download] ' + reason)
+ continue
entry_result = self.process_ie_result(entry,
download=download,
diff --git a/youtube_dlc/__init__.py b/youtube_dlc/__init__.py
index 105786bc0..7d72ab985 100644
--- a/youtube_dlc/__init__.py
+++ b/youtube_dlc/__init__.py
@@ -405,6 +405,7 @@ def _real_main(argv=None):
'youtube_print_sig_code': opts.youtube_print_sig_code,
'age_limit': opts.age_limit,
'download_archive': download_archive_fn,
+ 'break_on_existing': opts.break_on_existing,
'cookiefile': opts.cookiefile,
'nocheckcertificate': opts.no_check_certificate,
'prefer_insecure': opts.prefer_insecure,
diff --git a/youtube_dlc/options.py b/youtube_dlc/options.py
index 3c8a1305e..9ad8a6ddd 100644
--- a/youtube_dlc/options.py
+++ b/youtube_dlc/options.py
@@ -345,6 +345,10 @@ def parseOpts(overrideArguments=None):
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',
help='Download advertisements as well (experimental)')