rename 'image-*' & 'chapter-*' options to 'file-*' & 'child-*'

keep support for both names, e.g. file-filter & image-filter,
while prioritizing the new names
This commit is contained in:
Mike Fährmann
2026-02-02 18:01:45 +01:00
parent 153e589dd0
commit 87323fd71e
5 changed files with 74 additions and 42 deletions

View File

@@ -1515,6 +1515,8 @@ Description
Use fallback download URLs when a download fails.
extractor.*.file-range
----------------------
extractor.*.image-range
-----------------------
Type
@@ -1546,19 +1548,23 @@ extractor.*.post-range
Type
``string``
Description
Like `image-range <extractor.*.image-range_>`__,
Like `file-range <extractor.*.file-range_>`__,
but for posts.
extractor.*.child-range
-----------------------
extractor.*.chapter-range
-------------------------
Type
``string``
Description
Like `image-range <extractor.*.image-range_>`__,
Like `file-range <extractor.*.file-range_>`__,
but for child extractors handling manga chapters, external URLs, etc.
extractor.*.file-filter
-----------------------
extractor.*.image-filter
------------------------
Type
@@ -1584,10 +1590,14 @@ Example
* ``"post['id'] > 12345"``
* ``["date >= datetime(2025, 5, 1)", "print(post_id)"]``
Description
Like `image-filter <extractor.*.image-filter_>`__,
Like `file-filter <extractor.*.file-filter_>`__,
but for posts.
Available values are the directory-specific ones listed by ``-K`` or ``-j``.
extractor.*.child-filter
------------------------
extractor.*.chapter-filter
--------------------------
Type
@@ -1597,10 +1607,12 @@ Example
* ``"lang == 'en'"``
* ``["language == 'French'", "10 <= chapter < 20"]``
Description
Like `image-filter <extractor.*.image-filter_>`__,
Like `file-filter <extractor.*.file-filter_>`__,
but for child extractors handling manga chapters, external URLs, etc.
extractor.*.file-unique
-----------------------
extractor.*.image-unique
------------------------
Type
@@ -1608,10 +1620,12 @@ Type
Default
``false``
Description
Ignore image URLs that have been encountered before during the
Ignore file URLs that have been encountered before during the
current extractor run.
extractor.*.child-unique
------------------------
extractor.*.chapter-unique
--------------------------
Type
@@ -1619,7 +1633,7 @@ Type
Default
``false``
Description
Like `image-unique <extractor.*.image-unique_>`__,
Like `file-unique <extractor.*.file-unique_>`__,
but applies to delegated URLs like manga chapters, etc.
@@ -6003,7 +6017,7 @@ Note
It is not possible to filter all subtitles of a specific source type,
while also filtering for additional languages of another source type.
(e.g. any ASR subtitle + fra-FR of any source type)
For this, refer to `extractor.*.image-filter`_.
For this, refer to `extractor.*.file-filter`_.
extractor.tiktok.videos
@@ -6601,8 +6615,8 @@ Note
use the ``/with_replies`` timeline while logged in. For example,
media from Tweets which the user replied to will also be downloaded.
It is possible to exclude unwanted Tweets using `image-filter
<extractor.*.image-filter_>`__.
It is possible to exclude unwanted Tweets using `file-filter
<extractor.*.file-filter_>`__.
extractor.twitter.retries-api
@@ -9976,7 +9990,7 @@ Description
post-processor type, as well as any of its `options <Postprocessor Options_>`__.
It is possible to set a ``"filter"`` Condition_ similar to
`image-filter <extractor.*.image-filter_>`_
`file-filter <extractor.*.file-filter_>`_
to only run a post-processor conditionally.
It is also possible set a ``"whitelist"`` or ``"blacklist"`` to

View File

@@ -44,14 +44,14 @@
"cookies-select": null,
"cookies-update": true,
"image-filter" : null,
"image-range" : null,
"image-unique" : false,
"post-filter" : null,
"post-range" : null,
"chapter-filter": null,
"chapter-range" : null,
"chapter-unique": false,
"file-filter" : null,
"file-range" : null,
"file-unique" : false,
"post-filter" : null,
"post-range" : null,
"child-filter": null,
"child-range" : null,
"child-unique": false,
"keywords" : {},
"keywords-default" : null,

View File

@@ -162,7 +162,7 @@
download. These can be either a constant value,
range, or slice (e.g. '5', '8-20', or '1:24:3')
--post-range RANGE Like '--range', but for posts
--chapter-range RANGE Like '--range', but for child extractors
--child-range RANGE Like '--range', but for child extractors
handling manga chapters, external URLs, etc.
--filter EXPR Python expression controlling which files to
download. Files for which the expression
@@ -171,7 +171,7 @@
Example: --filter "image_width >= 1000 and
rating in ('s', 'q')"
--post-filter EXPR Like '--filter', but for posts
--chapter-filter EXPR Like '--filter', but for child extractors
--child-filter EXPR Like '--filter', but for child extractors
handling manga chapters, external URLs, etc.
## Post-processing Options:

View File

@@ -270,34 +270,39 @@ class Job():
def _init(self):
self.extractor.initialize()
self.pred_url = self._prepare_predicates("image", True)
self.pred_post = self._prepare_predicates("post", False)
self.pred_queue = self._prepare_predicates("chapter", False)
self.pred_url = self._prepare_predicates(
"file", "image", True)
self.pred_post = self._prepare_predicates(
"post", None, False)
self.pred_queue = self._prepare_predicates(
"child", "chapter", False)
init = self.extractor.config("init", False)
if init and init != "lazy":
self.initialize()
def _prepare_predicates(self, target, skip):
def _prepare_predicates(self, target, alt=None, skip=None):
predicates = []
extr = self.extractor
if extr.config(target + "-unique"):
if extr.config(target + "-unique") or \
alt is not None and extr.config(alt + "-unique"):
predicates.append(util.predicate_unique())
if pfilter := extr.config(target + "-filter"):
if (pfilter := extr.config(target + "-filter")) or \
alt is not None and (pfilter := extr.config(alt + "-filter")):
try:
predicates.append(util.predicate_filter(pfilter, target))
except (SyntaxError, ValueError, TypeError) as exc:
extr.log.warning(exc)
if prange := extr.config(target + "-range"):
if (prange := extr.config(target + "-range")) or \
alt is not None and (prange := extr.config(alt + "-range")):
try:
skip = extr.skip if skip and not pfilter else None
predicates.append(util.predicate_range(prange, skip))
except ValueError as exc:
extr.log.warning(
"invalid %s range: %s", target, exc)
extr.log.warning("invalid %s range: %s", target, exc)
return util.predicate_build(predicates)

View File

@@ -235,6 +235,7 @@ def _parse_option(opt):
def build_parser():
"""Build and configure an ArgumentParser object"""
SUPPRESS = argparse.SUPPRESS
parser = argparse.ArgumentParser(
formatter_class=Formatter,
add_help=False,
@@ -318,7 +319,7 @@ def build_parser():
input.add_argument(
"urls",
metavar="URL", nargs="*",
help=argparse.SUPPRESS,
help=SUPPRESS,
)
input.add_argument(
"-i", "--input-file",
@@ -620,7 +621,7 @@ def build_parser():
configuration.add_argument(
"--ignore-config",
dest="config_load", action="store_false",
help=argparse.SUPPRESS,
help=SUPPRESS,
)
authentication = parser.add_argument_group("Authentication Options")
@@ -698,7 +699,7 @@ def build_parser():
)
selection.add_argument(
"--range",
dest="image-range", metavar="RANGE", action=ConfigAction,
dest="file-range", metavar="RANGE", action=ConfigAction,
help=("Index range(s) specifying which files to download. "
"These can be either a constant value, range, or slice "
"(e.g. '5', '8-20', or '1:24:3')"),
@@ -709,14 +710,14 @@ def build_parser():
help=("Like '--range', but for posts"),
)
selection.add_argument(
"--chapter-range",
dest="chapter-range", metavar="RANGE", action=ConfigAction,
"--child-range",
dest="child-range", metavar="RANGE", action=ConfigAction,
help=("Like '--range', but for child extractors handling "
"manga chapters, external URLs, etc."),
)
selection.add_argument(
"--filter",
dest="image-filter", metavar="EXPR", action=ConfigAction,
dest="file-filter", metavar="EXPR", action=ConfigAction,
help=("Python expression controlling which files to download. "
"Files for which the expression evaluates to False are ignored. "
"Available keys are the filename-specific ones listed by '-K'. "
@@ -729,11 +730,23 @@ def build_parser():
help=("Like '--filter', but for posts"),
)
selection.add_argument(
"--chapter-filter",
dest="chapter-filter", metavar="EXPR", action=ConfigAction,
"--child-filter",
dest="child-filter", metavar="EXPR", action=ConfigAction,
help=("Like '--filter', but for child extractors handling "
"manga chapters, external URLs, etc."),
)
selection.add_argument(
"--file-range", "--image-range",
dest="file-range", action=ConfigAction, help=SUPPRESS)
selection.add_argument(
"--chapter-range",
dest="child-range", action=ConfigAction, help=SUPPRESS)
selection.add_argument(
"--file-filter", "--image-filter",
dest="file-filter", action=ConfigAction, help=SUPPRESS)
selection.add_argument(
"--chapter-filter",
dest="child-filter", action=ConfigAction, help=SUPPRESS)
infojson = {
"name" : "metadata",
@@ -773,7 +786,7 @@ def build_parser():
"--write-infojson",
dest="postprocessors",
action="append_const", const=infojson,
help=argparse.SUPPRESS,
help=SUPPRESS,
)
postprocessor.add_argument(
"--write-tags",
@@ -806,7 +819,7 @@ def build_parser():
"--mtime-from-date",
dest="postprocessors", nargs=0, action=MtimeAction,
const="date|status[date]",
help=argparse.SUPPRESS,
help=SUPPRESS,
)
postprocessor.add_argument(
"--rename",
@@ -830,18 +843,18 @@ def build_parser():
postprocessor.add_argument(
"--ugoira-conv",
dest="postprocessors", nargs=0, action=UgoiraAction, const="vp8",
help=argparse.SUPPRESS,
help=SUPPRESS,
)
postprocessor.add_argument(
"--ugoira-conv-lossless",
dest="postprocessors", nargs=0, action=UgoiraAction,
const="vp9-lossless",
help=argparse.SUPPRESS,
help=SUPPRESS,
)
postprocessor.add_argument(
"--ugoira-conv-copy",
dest="postprocessors", nargs=0, action=UgoiraAction, const="copy",
help=argparse.SUPPRESS,
help=SUPPRESS,
)
postprocessor.add_argument(
"--exec",