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

For Pixiv how do you set the directory to automatically download by artist ID? #2326

Closed Deejay85 closed 1 year ago

Deejay85 commented 2 years ago

I'm trying something I'm sure isn't going to work out at all, but before I spend any more time than I already have in trying to fix the issue, I just need to know if what I'm doing is possible, and if so, how to do it the correct way.

What I'm trying to do is simple enough...get the artist IDs into the correct folder. So far my setup reads like this:

gallery-dl -D "L:\Pixiv\Artists" "https://www.pixiv.net/en/users/2287823"

This works...mostly. The only problem is while I would like for it to end up in the following format:

L:\Pixiv\Artists\user ID\Filename - Title.Extension

what I keep getting instead is to have to keep specifying the directory without the directory being created automatically. I tried going to the filename format, and here is where I'm sure I'm messing up at. So far I have this written down in the config file:

"filename": "user[id]"/"{filename} - {title}.{extension}",

I've tried "./" and "//" where the current "/" command is, but none of it seems to work. As a result I'm not even sure if what I'm doing is even possible or not, or if I have to back up, drop the "/" entirely, and try to edit something else. Anyway, sorry is this is a little confusing, but put simple I need for the User ID to be the root directory in the ./Pixiv/Artist directory, and as for the rest, I should be able to handle it myself (I hope).

AlttiRi commented 2 years ago

Use directory for folders, filename for files:

"directory": ["[gallery-dl]", "[{category}] {user[id]}—{user[name]}"],
"filename": "[{category}] {user[id]}—{id}—{user[name]}—{date:%Y.%m.%d}—{title}—{num}.{extension}",

Note that "directory" is an array:

"directory": [
  "[gallery-dl]",
  "[{category}] {user[id]}—{user[name]}"
],

Example

The root directory:

Sub directory for the artist:

Files in the artist directory:


Files with such name pattern are:

Deejay85 commented 2 years ago

Not to sell myself short, but I'm kind of stupid here when it comes to this. Taking things one step at a time though, there is no way I can set the artist ID as a new folder within the artist directory due to the fact that it has to do with filename format, and not artist name, correct?

As for the directory array, while I don't have a clear understanding of what an array is, if I'm following you correctly, I need to create a new line in the config file, ideally above the filename configuration, correct? I'm not sure how that would work using the -D command, but I'll give it a try since I already tried it with -d, and it didn't go so well. Any idea what I should be typing out for the directory information in the config file though? Normally I thought this kind of directory piping would be done through the command prompt.

Also, as a quick example, here is a copy/paste of one file format that I'm currently trying to replicate.

L:\Pixiv\Artists\32157371\89085195_p3_master1200 - アンバーちゃんの太腿コキ~手袋装備、指を添えて~.jpg

Sorry that I'm not understanding a lot of what you're saying, but I am at least making the attempt to do so.

AlttiRi commented 2 years ago

Okay, just start with the creating and initialising gallery-dl.conf file:

It's slightly edited example based on https://github.com/mikf/gallery-dl/issues/2143#issuecomment-1002192200:

1. Create custom gallery-dl.conf file

  1. Create empty gallery-dl.conf file by running in CMD.exe:
    copy NUL "%USERPROFILE%\gallery-dl.conf"
  2. Open the file with a text editor. Just run in the console:
    "%USERPROFILE%\gallery-dl.conf"
  3. Fill the file with:
{
    "extractor":
    {
        "base-directory": "./",
        "twitter":
        {
            "retweets": "original",
            "videos": true,
            "directory": ["[gallery-dl]", "[{category}] {author[name]}"],
            "filename": "[{category}] {author[name]}—{date:%Y.%m.%d}—{retweet_id|tweet_id}—{filename}.{extension}"
        },
        "pixiv":
        {
            "directory": ["[gallery-dl]", "[{category}] {user[id]}—{user[name]}"],
            "filename": "[{category}] {user[id]}—{id}—{user[name]}—{date:%Y.%m.%d}—{title}—{num}.{extension}"
        }
    }
}
  1. Verify the config is working:
    gallery-dl https://twitter.com/SpaceX/status/1473671809870725121

The result filename should be:

AlttiRi commented 2 years ago

To list the available keys/properties for naming use -K flag.


L:\

"base-directory": "L:",

Pixiv\Artists\32157371

"directory": ["Pixiv", "Artists", "{user[id]}"],

89085195_p3_master1200 - アンバーちゃんの太腿コキ~手袋装備、指を添えて~.jpg

"filename": "{id}_p{num} - {title}.{extension}",

But I highly recommend to use my suggested format. Just believe.

AlttiRi commented 2 years ago

A more complete config for Pixiv:

With translated tags and with the automatic converting ugoira to webm (By default they are downloaded as zip files. And you need to manually use --ugoira-conv, --ugoira-conv-lossless flags for converting.):

        "pixiv":
        {
            "tags": "translated",
            "directory": ["[gallery-dl]", "[{category}] {user[id]}—{user[name]}"],
            "filename": "[{category}] {user[id]}—{id}—{user[name]}—{date:%Y.%m.%d}—{title}—{num}.{extension}",
            "postprocessors": [{
                "name": "ugoira",
                "ffmpeg-args": ["-c:v", "libvpx", "-crf", "4", "-b:v", "5000k"],
                "ffmpeg-twopass": true,
                "keep-files": false
            }]
        }
Deejay85 commented 2 years ago

Took a bit of effort, but I finally understand...part of it. Not really looking forward to it, but I imagine I'm going to have to create a separate instance when downloading tags just so I don't keep having to change a line in a file. Actually, now that I think of it, maybe two separate instances that are Pixiv standalones would work better, with this one being used as a main. Anyway here is the code I used:

            "directory": ["Pixiv", "Artists", "{user[id]}"],
            "filename": "{filename} - {title}.{extension}",

One thing I would like to know though is why is the speed so slow? Do I need to get a Pixiv Plus account to make it go faster, or is that just the limitations of the site? Also, while not much, here is somewhat SFW link of the weirdness that Japan keeps coming up with. All I'm going to say is 1. that's not her breasts you are looking at and 2. don't scroll down to the bottom two images unless you want to see a NSFW version of this that tends to give away why you are not staring at some ridiculously large melons.

https://www.pixiv.net/en/artworks/89399231