Skip to content

Config File Outline

HRXN edited this page Aug 25, 2023 · 26 revisions

The structure of the gallery-dl configuration file

Configuration files for gallery-dl use a JSON-based file format.

First steps

  • If you're not familiar with it: Configuration file introduction, from gallery-dl's official README.
  • Handling a JSON file: The JSON format is actually very simple.
    • Every somewhat decent text editor, no matter your operating system, should be able to handle it. You don't need explicit support for JSON, but having JSON syntax highlighting etc. definitely helps a lot.
  • "My local text editor sucks!": There is an online (in-browser) version of the cross-platform editor VS Code.
    • https://vscode.dev/
    • Simply open a new file there (Main Menu (upper left corner), select File > New File; or use the New Text File button in Explorer View, right next to OPEN EDITORS), if you paste some JSON text into the editor it should automatically detect it and set the Language Mode accordingly.
      • If not: Set the Language Mode to JSON by hand: Either click on the field in the lower right corner, that says Plain Text by default to change this, OR use the command menu (Ctrl+Shift+P), choose Change Language Mode (should be right at the top, usually. If not, simply type "lang"), confirm with Enter, choose JSON, confirm with Enter again, et voilà, you are ready to go!
      • VSCode in JSON mode will automatically detect all syntax issues and problems, making the creation of a valid JSON config file very easy!
  • Alternatively, use the more complicated way and check your config with online tools to validate a JSON text: Too many to list all, probably. But some examples:

Examples to demonstrate the layout of a config file

Empty config file, just showing the different sections
{
    "extractor":
    {

    },

    "downloader":
    {

    },

    "output":
    {

    },

    "postprocessor":
    {

    }

}
All Sections, including some basic options
{
    "extractor":
    {
        "base-directory": "~/gallery-dl/",
        "archive": "~/gallery-dl/archive.sqlite3",

        "keywords": {"bkey": "", "ckey": ""},
        "keywords-default": "",

        "path-restrict": {
            "\\": "",
            "/" : "",
            "|" : "",
            ":" : "",
            "*" : "",
            "?" : "",
            "\"": "",
            "<" : "",
            ">" : ""
        },

        "postprocessors": [
            {
                "name": "metadata",
                "mode": "tags",
                "whitelist": ["danbooru", "moebooru", "sankaku"]
            }
        ],




        "#": "All Extractor settings belong here"





    },

    "downloader":
    {

    },

    "output":
    {

    },

    "postprocessor":
    {

    }

}
Explanations for the options listed above:
The options of gallery-dl can be specified on multiple levels of the configuration tree:
Base level: extractor.<option-name>
Category level: extractor.<category>.<option-name>
Subcategory level: extractor.<category>.<subcategory>.<option-name>