mikf / gallery-dl

Command-line program to download image galleries and collections from several image hosting sites
GNU General Public License v2.0
11.7k stars 953 forks source link

How to get the frame delay and file from Danbooru #603

Closed ghost closed 4 years ago

ghost commented 4 years ago

If I do: $ gallery-dl --write-metadata --ignore-config https://danbooru.donmai.us/posts/3717969

The .json will have the delay listed with the file:

...
    "pixiv_ugoira_frame_data": {
        "content_type": "image/jpeg",
        "data": [
            {
                "delay": 60,
                "file": "000000.jpg"
            },
            {
                "delay": 60,
                "file": "000001.jpg"
            },
            {
                "delay": 60,
                "file": "000002.jpg"
            },
            {
                "delay": 60,
                "file": "000003.jpg"
            },
            {
                "delay": 60,
                "file": "000004.jpg"
            },
...

But if I try and use the custom mode, with the following config.json:

{
    "downloader":
    {
        "part-directory": "/tmp/.download/",
        "rate": "1M",
        "retries": 5,
        "timeout": 8.5
    },

    "extractor":
    {
        "base-directory": "./",
        "sleep": 3,

        "danbooru":
        {
            "filename": "{filename}.{extension}",
            "directory": ["{search_tags}_(danbooru)"],
            "postprocessors":
            [
                {
                    "name": "metadata",
                    "mode": "custom",
                    "extension": "txt",
                    "format": "Delay: {pixiv_ugoira_frame_data[data][:][delay]}\nFilename: {pixiv_ugoira_frame_data[data][:][file]}\n"
                }
            ]
        }
    }
}

My file looks like:

Delay: None
Filename: None

So my question is how do I get the custom format to look like the --write-metadata format.

mikf commented 4 years ago

It's not possible to split duration and filename info like that. You'll have to write your own script that parses the JSON from --write-metadata and writes the data in a format you want.

What do you want to do with a list of delays/filenames?

ghost commented 4 years ago

It's not possible to split duration and filename info like that. You'll have to write your own script that parses the JSON from --write-metadata and writes the data in a format you want.

Ah I see.

What do you want to do with a list of delays/filenames?

This was just a condensed version as I tried to get the frames to show. I was doing a "mode": "custom" with a specific format but based off what you said I think I'll just use the json mode. It shouldn't really matter since I'm using grep (jq maybe?) to parse the files anyway.

Thanks for taking the time to explain it.