Skip to content

Bulk asynchronous downloader for multiple file hosts

feat: add `--filename-regex-exclude` option

NTFSvolumedd444c9eaee4
diff --git a/cyberdrop_dl/config/default.yaml b/cyberdrop_dl/config/default.yaml
index bb189e559..47abe1025 100644
--- a/cyberdrop_dl/config/default.yaml
+++ b/cyberdrop_dl/config/default.yaml
@@ -89,6 +89,7 @@ filters:
max: null
min: null
filename_regex: null
+ filename_regex_exclude: null
files:
audio: true
images: true
diff --git a/cyberdrop_dl/config/filters.py b/cyberdrop_dl/config/filters.py
index da6797366..93c9224bf 100644
--- a/cyberdrop_dl/config/filters.py
+++ b/cyberdrop_dl/config/filters.py
@@ -154,6 +154,9 @@ class Filters(ConfigGroup):
filename_regex: FalsyAsNone[re.Pattern[str]] = None
"Only download files that match this regex"
+ filename_regex_exclude: FalsyAsNone[re.Pattern[str]] = None
+ "Do NOT download files that match this regex"
+
only_hosts: set[NonEmptyStr] = Field(default_factory=set)
"Only scrape/download from these domains"
diff --git a/cyberdrop_dl/config/schema.json b/cyberdrop_dl/config/schema.json
index 48ad3a82f..d9e0449da 100644
--- a/cyberdrop_dl/config/schema.json
+++ b/cyberdrop_dl/config/schema.json
@@ -424,6 +424,10 @@
"$ref": "#/$defs/FalsyAsNone_Pattern_str__",
"default": null
},
+ "filename_regex_exclude": {
+ "$ref": "#/$defs/FalsyAsNone_Pattern_str__",
+ "default": null
+ },
"only_hosts": {
"items": {
"$ref": "#/$defs/NonEmptyStr"
diff --git a/cyberdrop_dl/crawlers/crawler.py b/cyberdrop_dl/crawlers/crawler.py
index e246aa38b..cfe8b1eaf 100644
--- a/cyberdrop_dl/crawlers/crawler.py
+++ b/cyberdrop_dl/crawlers/crawler.py
@@ -1166,7 +1166,15 @@ def _should_skip_by_config(media_item: MediaItem, config: Config) -> bool:
if (regex := filters.filename_regex) and not regex.search(media_item.filename):
logger.info(
- "Download skipped %s due to filename regex filter. Filename '%s' does not match config regex",
+ "Download skipped %s due to filename regex filter. Filename '%s' does not match regex",
+ media_item.url,
+ media_item.filename,
+ )
+ return True
+
+ if (regex := filters.filename_regex_exclude) and regex.search(media_item.filename):
+ logger.info(
+ "Download skipped %s due to filename regex exclude filter. Filename '%s' matched config regex",
media_item.url,
media_item.filename,
)
diff --git a/docs/reference/config/filters.md b/docs/reference/config/filters.md
index e8dbfdf60..5a7d0c3db 100644
--- a/docs/reference/config/filters.md
+++ b/docs/reference/config/filters.md
@@ -30,13 +30,26 @@ filters:
| ----------------------- | ------- |
| `NonEmptyStr` or `null` | `null` |
-Only download files if their filename match this regex expression
+Only download files if their filename matches this regular expression
```yaml
filters:
filename_regex: null
```
+# `filename_regex_exclude`
+
+| Type | Default |
+| ----------------------- | ------- |
+| `NonEmptyStr` or `null` | `null` |
+
+Do NOT download files if their filename matches this regular expression
+
+```yaml
+filters:
+ filename_regex_exclude: null
+```
+
# `only_hosts`
| Type | Default | Additional Info |