add '"skip": "terminate"' option

Stops not only the current extractor/job,
but all parent extractors/jobs as well.
This commit is contained in:
Mike Fährmann
2021-05-12 02:22:28 +02:00
parent 4835888acc
commit c693db5b1a
6 changed files with 22 additions and 4 deletions

View File

@@ -249,6 +249,8 @@ def main():
retval |= jobtype(url.value).run()
else:
retval |= jobtype(url).run()
except exception.TerminateExtraction:
pass
except exception.NoExtractorError:
log.error("No suitable extractor found for '%s'", url)
retval |= 64

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2015-2019 Mike Fährmann
# Copyright 2015-2021 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@@ -23,6 +23,7 @@ Exception
+-- FilterError
+-- NoExtractorError
+-- StopExtraction
+-- TerminateExtraction
"""
@@ -109,3 +110,8 @@ class StopExtraction(GalleryDLException):
GalleryDLException.__init__(self)
self.message = message % args if args else message
self.code = 1 if message else 0
class TerminateExtraction(GalleryDLException):
"""Terminate data extraction"""
code = 0

View File

@@ -80,6 +80,8 @@ class Job():
if exc.message:
log.error(exc.message)
self.status |= exc.code
except exception.TerminateExtraction:
raise
except exception.GalleryDLException as exc:
log.error("%s: %s", exc.__class__.__name__, exc)
self.status |= exc.code
@@ -400,6 +402,8 @@ class DownloadJob(Job):
skip, _, smax = skip.partition(":")
if skip == "abort":
self._skipexc = exception.StopExtraction
elif skip == "terminate":
self._skipexc = exception.TerminateExtraction
elif skip == "exit":
self._skipexc = sys.exit
self._skipcnt = 0

View File

@@ -6,4 +6,4 @@
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
__version__ = "1.17.4"
__version__ = "1.17.5-dev"