]> jfr.im git - yt-dlp.git/commitdiff
Merge pull request #187 from pukkandan/break-on-existing
authorTom-Oliver Heidel <redacted>
Mon, 16 Nov 2020 22:00:44 +0000 (23:00 +0100)
committerGitHub <redacted>
Mon, 16 Nov 2020 22:00:44 +0000 (23:00 +0100)
Stop download after encountering video in archive

README.md
youtube_dlc/YoutubeDL.py
youtube_dlc/__init__.py
youtube_dlc/options.py

index f884ad067eaa66a3bdb04b311dcc0f2e21b80c37..170c85c489656bd92d604de11f50e6c920935a70 100644 (file)
--- a/README.md
+++ b/README.md
@@ -217,6 +217,8 @@ ## Video Selection:
     --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)
 
index c85cbd88faf0e30b4c43768c197c7e05d6b55d8b..bf02192eb4df19266082bedae5051139e374cb3b 100644 (file)
@@ -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.
@@ -1048,8 +1050,12 @@ def report_download(num_entries):
 
                 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,
index 105786bc059e8e45054c7ef85c57ea1652c91542..7d72ab98533d96ed1f7c34a1433a7b44f604cfe9 100644 (file)
@@ -405,6 +405,7 @@ def parse_retries(retries):
         '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,
index 3c8a1305e7476d6d6ae7cc4fde74a02316bc8518..9ad8a6dddea6b2807be5f2de781bba021e3fc8a5 100644 (file)
@@ -344,6 +344,10 @@ def _comma_separated_values_options_callback(option, opt_str, value, parser):
         '--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',