Open cenodis opened 5 months ago
The syntax is wrong, it should be like this to work:
{
"extractor": {
"directory": ["{media[id][0:2]}", "{media[id][2:4]}"],
"filename": "{media[id]}.{extension}"
}
}
Give it a try.
Sorry, the brackets seem to have gotten lost in a copy paste somewhere. My config file has proper bracketing but still doesn't work and the result path looks like this:
.../None/None/01876e39-c51c-16ec-6677-94bdaf5c247d.png
When you check the keywords with gallery-dl -K "URL"
, does media['id']
appears in the section "Keywords for directory names:"? If so, it should work. Care to share an example to test?
It doesnt. You can try with any mastodon account like so:
gallery-dl -K 'https://mastodon.social/@Mastodon'
The problem isn't the metadata, its that gallery-dl seems to create directories independent of the files (and therefore metadata about files is not available during directory creation). Hence my question:
Is there any way to make the directory config work on a per-file basis?
Then I think the only way would be to use a post-processor to create the folders and move the just-downloaded file there, tbh.
{
"extractor": {
"directory": ["temp-dir"],
"filename": "{media[id]}.{extension}",
"postprocessor": ["move-files"]
},
"postprocessor": {
"move-files": {
"name": "exec",
"event": "after",
"command": ["script.sh", "{_path}", "{media[id][0:2]}/{media[id][2:4]}/"]
},
}
}
And the script should be something like this (making example in Bash):
#!/bin/bash
filepath="$1"
target="$2"
mkdir --parents "$target"
mv --force "$filepath" "$target"
Probably will require some adjustments but that's the gist of it.
I am trying to download media from websites that allow reposting/reblogging of content, thereby duplicating that media across multiple accounts (think twitter, mastodon, etc). To better organize this I'm trying to consolidate all the media files into a directory independent of accounts. Because said directory fills up fairly quickly I would like to further subdivide it based on the filename.
For example the file:
example_file.png
would be stored like this:
.../ex/am/example_file.png
Ideally I would like to have a configuration like this:
This doesn't work however. It seems that the directory is being created before the file is actually known and the "media" field is completely absent. Is there any way to make the
directory
config work on a per-file basis?