diff --git a/docs/configuration.rst b/docs/configuration.rst index bf7e2c52..fd990f1b 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -7484,6 +7484,22 @@ Description or by `extractor.modules`_. +extractor.category-map +---------------------- +Type + ``object`` (`category` -> `category`) +Default + .. code:: json + + { + "coomerparty": "coomer", + "kemonoparty": "kemono", + "koharu" : "schalenetwork" + } +Description + A JSON ``object`` mapping category names to their replacements. + + globals ------- Type diff --git a/docs/gallery-dl.conf b/docs/gallery-dl.conf index 764a2ab1..c1483325 100644 --- a/docs/gallery-dl.conf +++ b/docs/gallery-dl.conf @@ -79,6 +79,11 @@ "actions": [], "input" : null, "netrc" : false, + "category-map": { + "coomerparty": "coomer", + "kemonoparty": "kemono", + "koharu" : "schalenetwork" + }, "extension-map": { "jpeg": "jpg", "jpe" : "jpg", diff --git a/gallery_dl/__init__.py b/gallery_dl/__init__.py index 97e702e0..0004c791 100644 --- a/gallery_dl/__init__.py +++ b/gallery_dl/__init__.py @@ -188,6 +188,17 @@ def main(): ujob = update.UpdateJob(extr) return ujob.run() + # category remapping + cmap = config.interpolate(("extractor",), "category-map") + if cmap is None: + cmap = { + "coomerparty": "coomer", + "kemonoparty": "kemono", + "koharu" : "schalenetwork", + } + if cmap: + config.rename_categories(cmap) + # extractor modules modules = config.get(("extractor",), "modules") if modules is not None: diff --git a/gallery_dl/config.py b/gallery_dl/config.py index 92e55d3f..7b971990 100644 --- a/gallery_dl/config.py +++ b/gallery_dl/config.py @@ -162,6 +162,16 @@ def status(): stdout_write(fmt(path, status)) +def rename_categories(cmap): + opts = _config.get("extractor") + if not opts: + return + + for old, new in cmap.items(): + if old in opts and new not in opts: + opts[new] = opts[old] + + def load(files=None, strict=False, loads=util.json_loads): """Load JSON configuration files""" for pathfmt in files or _default_configs: