diff --git a/docs/configuration.rst b/docs/configuration.rst index 77da72b0..b2115b45 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -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 `__, + Like `file-range `__, but for posts. +extractor.*.child-range +----------------------- extractor.*.chapter-range ------------------------- Type ``string`` Description - Like `image-range `__, + Like `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 `__, + Like `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 `__, + Like `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 `__, + Like `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 - `__. + It is possible to exclude unwanted Tweets using `file-filter + `__. extractor.twitter.retries-api @@ -9976,7 +9990,7 @@ Description post-processor type, as well as any of its `options `__. It is possible to set a ``"filter"`` Condition_ similar to - `image-filter `_ + `file-filter `_ to only run a post-processor conditionally. It is also possible set a ``"whitelist"`` or ``"blacklist"`` to diff --git a/docs/gallery-dl.conf b/docs/gallery-dl.conf index cecc66ac..826cd77f 100644 --- a/docs/gallery-dl.conf +++ b/docs/gallery-dl.conf @@ -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, diff --git a/docs/options.md b/docs/options.md index 1326ae62..8f71d06d 100644 --- a/docs/options.md +++ b/docs/options.md @@ -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: diff --git a/gallery_dl/job.py b/gallery_dl/job.py index d5a6f28c..57d7d0c2 100644 --- a/gallery_dl/job.py +++ b/gallery_dl/job.py @@ -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) diff --git a/gallery_dl/option.py b/gallery_dl/option.py index 0a564de6..81e063d2 100644 --- a/gallery_dl/option.py +++ b/gallery_dl/option.py @@ -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",