From 71680feab992c8bc7b9cafce1870250e0a36ef32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 6 Feb 2026 08:37:23 +0100 Subject: [PATCH] =?UTF-8?q?[actions]=20implement=20'flag=20=E2=80=A6=20=3D?= =?UTF-8?q?=20skip'=20(#8960)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/configuration.rst | 2 +- gallery_dl/actions.py | 8 +++++++- gallery_dl/downloader/http.py | 10 ++++------ gallery_dl/job.py | 9 +++++++++ gallery_dl/util.py | 2 ++ 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index a6982394..07398b01 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -10173,7 +10173,7 @@ Description | Expected syntax is ``[ = ]`` (e.g. ``post = stop``) | ```` can be one of ``file``, ``post``, ``child``, ``download`` - | ```` can be one of ``stop``, ``abort``, ``terminate``, ``restart`` (default ``stop``) + | ```` can be one of ``stop``, ``abort``, ``terminate``, ``restart``, ``skip`` (default ``stop``) ``wait``: | Sleep for a given Duration_ or | wait until Enter is pressed when no argument was given. diff --git a/gallery_dl/actions.py b/gallery_dl/actions.py index 1e4626a1..f3b962cc 100644 --- a/gallery_dl/actions.py +++ b/gallery_dl/actions.py @@ -231,7 +231,13 @@ def action_flag(opts): r"(?i)(file|post|child|download)(?:\s*[= ]\s*(.+))?" ).match(opts).groups() flag = flag.upper() - value = "stop" if value is None else value.lower() + + if value is None: + value = "stop" + elif value == "skip": + value = "stop" if flag == "DOWNLOAD" else False + else: + value = value.lower() def _flag(args): util.FLAGS.__dict__[flag] = value diff --git a/gallery_dl/downloader/http.py b/gallery_dl/downloader/http.py index 4f380fb4..ee821b53 100644 --- a/gallery_dl/downloader/http.py +++ b/gallery_dl/downloader/http.py @@ -385,10 +385,9 @@ class HttpDownloader(DownloaderBase): def receive(self, fp, content, bytes_total, bytes_start): write = fp.write for data in content: - write(data) - if FLAGS.DOWNLOAD is not None: - FLAGS.process("DOWNLOAD") + return FLAGS.process("DOWNLOAD") + write(data) def _receive_rate(self, fp, content, bytes_total, bytes_start): rate = self.rate() if self.rate else None @@ -399,14 +398,13 @@ class HttpDownloader(DownloaderBase): time_start = time.monotonic() for data in content: + if FLAGS.DOWNLOAD is not None: + return FLAGS.process("DOWNLOAD") time_elapsed = time.monotonic() - time_start bytes_downloaded += len(data) write(data) - if FLAGS.DOWNLOAD is not None: - FLAGS.process("DOWNLOAD") - if progress is not None: if time_elapsed > progress: self.out.progress( diff --git a/gallery_dl/job.py b/gallery_dl/job.py index 51b32da2..e79e30a1 100644 --- a/gallery_dl/job.py +++ b/gallery_dl/job.py @@ -224,12 +224,18 @@ class Job(): elif process is None: continue + elif FLAGS.POST is False: + FLAGS.POST = process = None + continue elif msg == Message.Url: if self.metadata_url: kwdict[self.metadata_url] = url self.update_kwdict(kwdict) if self.pred_url(url, kwdict): + if FLAGS.FILE is False: + FLAGS.FILE = None + continue self.handle_url(url, kwdict) if FLAGS.FILE is not None: FLAGS.process("FILE") @@ -239,6 +245,9 @@ class Job(): if self.metadata_url: kwdict[self.metadata_url] = url if self.pred_queue(url, kwdict): + if FLAGS.CHILD is False: + FLAGS.CHILD = None + continue self.handle_queue(url, kwdict) if FLAGS.CHILD is not None: FLAGS.process("CHILD") diff --git a/gallery_dl/util.py b/gallery_dl/util.py index fe9a9e78..20575ada 100644 --- a/gallery_dl/util.py +++ b/gallery_dl/util.py @@ -677,6 +677,8 @@ class Flags(): def process(self, flag): value = self.__dict__[flag] + if value is False: # flag was set to "skip" + return "skip" self.__dict__[flag] = None if value == "abort":