diff --git a/gallery_dl/__init__.py b/gallery_dl/__init__.py index e698de62..7fb9ba09 100644 --- a/gallery_dl/__init__.py +++ b/gallery_dl/__init__.py @@ -275,6 +275,8 @@ def main(): jobtype = job.KeywordJob elif args.list_data: jobtype = job.DataJob + elif args.simulate: + jobtype = job.SimulationJob else: jobtype = job.DownloadJob diff --git a/gallery_dl/job.py b/gallery_dl/job.py index 61755f3a..c89743ee 100644 --- a/gallery_dl/job.py +++ b/gallery_dl/job.py @@ -209,7 +209,7 @@ class DownloadJob(Job): def handle_queue(self, url, keywords): try: - DownloadJob(url, self).run() + self.__class__(url, self).run() except exception.NoExtractorError: self._write_unsupported(url) @@ -227,6 +227,18 @@ class DownloadJob(Job): return instance +class SimulationJob(DownloadJob): + """Simulate the extraction process without downloading anything""" + + def handle_url(self, url, keywords, fallback=None): + self.pathfmt.set_keywords(keywords) + self.out.skip(self.pathfmt.path) + if self.sleep: + time.sleep(self.sleep) + if self.archive: + self.archive.add(keywords) + + class KeywordJob(Job): """Print available keywords""" diff --git a/gallery_dl/option.py b/gallery_dl/option.py index 03d5b263..45a4a99f 100644 --- a/gallery_dl/option.py +++ b/gallery_dl/option.py @@ -113,6 +113,10 @@ def build_parser(): "-j", "--dump-json", dest="list_data", action="store_true", help="Print JSON information", ) + output.add_argument( + "-s", "--simulate", dest="simulate", action="store_true", + help="Simulate data extraction; do not download anything", + ) output.add_argument( "-K", "--list-keywords", dest="list_keywords", action="store_true", help=("Print a list of available keywords and example values "