diff --git a/README.md b/README.md index f884ad067..f54dc362d 100644 --- a/README.md +++ b/README.md @@ -339,6 +339,10 @@ I will add some memorable short links to the binaries so you can download them e playlist information in a single line. --print-json Be quiet and print the video information as JSON (video is still being downloaded). + --force-write-archive Force download archive entries to be written + as far as no errors occur, even if -s or + another simulation switch is used. + (Same as --force-download-archive) --newline Output progress bar as new lines --no-progress Do not print progress bar --console-title Display progress in console titlebar diff --git a/test/parameters.json b/test/parameters.json index 7bf59c25f..84b5de4e3 100644 --- a/test/parameters.json +++ b/test/parameters.json @@ -7,6 +7,7 @@ "forcethumbnail": false, "forcetitle": false, "forceurl": false, + "force_write_download_archive": false, "format": "best", "ignoreerrors": false, "listformats": null, diff --git a/youtube_dlc/YoutubeDL.py b/youtube_dlc/YoutubeDL.py index dd55ba0f2..e720924c8 100644 --- a/youtube_dlc/YoutubeDL.py +++ b/youtube_dlc/YoutubeDL.py @@ -161,6 +161,8 @@ class YoutubeDL(object): forcejson: Force printing info_dict as JSON. dump_single_json: Force printing the info_dict of the whole playlist (or video) as a single JSON line. + force_write_download_archive: Force writing download archive regardless of + 'skip_download' or 'simulate'. simulate: Do not download the video files. format: Video format code. See options.py for more information. outtmpl: Template for output names. @@ -1805,8 +1807,11 @@ class YoutubeDL(object): # Forced printings self.__forced_printings(info_dict, filename, incomplete=False) - # Do nothing else if in simulate mode if self.params.get('simulate', False): + if self.params.get('force_write_download_archive', False): + self.record_download_archive(info_dict) + + # Do nothing else if in simulate mode return if filename is None: @@ -2086,7 +2091,10 @@ class YoutubeDL(object): except (PostProcessingError) as err: self.report_error('postprocessing: %s' % str(err)) return - self.record_download_archive(info_dict) + must_record_download_archive = True + + if must_record_download_archive or self.params.get('force_write_download_archive', False): + self.record_download_archive(info_dict) def download(self, url_list): """Download a given list of URLs.""" diff --git a/youtube_dlc/__init__.py b/youtube_dlc/__init__.py index 105786bc0..1d37b53f1 100644 --- a/youtube_dlc/__init__.py +++ b/youtube_dlc/__init__.py @@ -344,6 +344,7 @@ def _real_main(argv=None): 'forceformat': opts.getformat, 'forcejson': opts.dumpjson or opts.print_json, 'dump_single_json': opts.dump_single_json, + 'force_write_download_archive': opts.force_write_download_archive, 'simulate': opts.simulate or any_getting, 'skip_download': opts.skip_download, 'format': opts.format, diff --git a/youtube_dlc/options.py b/youtube_dlc/options.py index 3c8a1305e..a0309c012 100644 --- a/youtube_dlc/options.py +++ b/youtube_dlc/options.py @@ -645,8 +645,13 @@ def parseOpts(overrideArguments=None): verbosity.add_option( '--print-json', action='store_true', dest='print_json', default=False, - help='Be quiet and print the video information as JSON (video is still being downloaded).', - ) + help='Be quiet and print the video information as JSON (video is still being downloaded).') + verbosity.add_option( + '--force-write-download-archive', '--force-write-archive', '--force-download-archive', + action='store_true', dest='force_write_download_archive', default=False, + help=( + 'Force download archive entries to be written as far as no errors occur,' + 'even if -s or another simulation switch is used.')) verbosity.add_option( '--newline', action='store_true', dest='progress_with_newline', default=False,