Closed Kavolc closed 1 year ago
You need to set options for both reddit and imgur for something like this, e.g.
{
"imgur":
{
"image":
{
"directory": {
"'_reddit_' in locals() and extension in ('mp4', 'webm')": ["+Clips"],
"'_reddit_' in locals() and extension in ('gif', 'apng')": ["+Gifs"],
"'_reddit_' in locals()" : [],
"extension in ('mp4', 'webm')" : ["Imgur", "Anims"],
"" : ["Imgur", "Pics"]
},
"filename": {
"'_reddit_' in locals()" : "{_reddit_[title][:180]!t:?/_/R /_/}{_reddit_[id]}.{extension}",
"not locals().get('title')" : "{id}.{extension}",
"" : "{title!t:R /_/}_{description!t:?/_/}{id}.{extension}"
}
},
"album":
{
"directory": {
"extension in ('mp4', 'webm')": ["Imgur", "{album[title]!t:?/_/R /_/}{album[id]}", "Clips"],
"extension in ('gif', 'apng')": ["Imgur", "{album[title]!t:?/_/R /_/}{album[id]}", "Anims"],
"" : ["Imgur", "{album[title]!t:?/_/R /_/}{album[id]}"]
},
"filename": {
"'_reddit_' in locals()" : "{_reddit_[title][:180]!t:?/_/R /_/}{_reddit_[id]}.{extension}",
"not locals().get('title')" : "{num:>04}_{album[id]}_{id}.{extension}",
"" : "{num:>04}_{title!t:R /_/}_{description!t:?/_/}{id}.{extension}"
}
},
"gallery":
{
"directory": {
"extension in ('mp4', 'webm')": ["Imgur", "{album[title]!t:?/_/R /_/}{album[id]}", "Clips"],
"extension in ('gif', 'apng')": ["Imgur", "{album[title]!t:?/_/R /_/}{album[id]}", "Anims"],
"" : ["Imgur", "{album[title]!t:?/_/R /_/}{album[id]}"]
},
"filename": {
"'_reddit_' in locals()" : "{_reddit_[title][:180]!t:?/_/R /_/}{_reddit_[id]}.{extension}",
"not locals().get('title')" : "{num:>04}_{album[id]}_{id}.{extension}",
"" : "{num:>04}_{title!t:R /_/}_{description!t:?/_/}{id}.{extension}"
}
},
"user":
{
"archive-format": "{user}_{id}",
"directory": {
"extension in ('mp4', 'webm')": ["Imgur", "Users", "{album[title]!t:?/_/R /_/}{album[id]}", "Clips"],
"" : ["Imgur", "Users", "{album[title]!t:?/_/R /_/}{album[id]}"]
},
"filename": {
"'_reddit_' in locals()" : "{_reddit_[title][:180]!t:?/_/R /_/}{_reddit_[id]}.{extension}",
"not locals().get('title')": "{num:>04}_{album[id]}_{id}.{extension}",
"" : "{num:>04}_{title!t:R /_/}_{description!t:?/_/}{id}.{extension}"
}
},
"archive": "~/gallery-dl.archive.imgur.db",
"mp4": true,
"skip": true
},
"reddit":
{
"subreddit":
{
"directory": ["Reddit", "Subreddits", "{subreddit}"],
"filename": "{title[:180]!t:?/_/R /_/R&/and/}{id}{num:?_//>02}.{extension}"
},
"user":
{
"directory": ["Reddit", "Users", "{author}"],
"filename": "{title[:180]!t:?/_/R /_/R&/and/}{id}{num:?_//>02}.{extension}"
},
"archive": "~/gallery-dl.archive.reddit.db",
"parent-directory": true,
"parent-metadata": "_reddit_",
"client-id": "<your cliend ID here>",
"refresh-token": "<your refresh token here>",
"blacklist": ["twitter", "instagram"],
"postprocessors": ["nonpicsort"]
}
}
Hi @Hrxn Thank you for answering this. Its making me understand how this works a bit better and rethink my own directory structure.
Questions:
Can I ask what "{title[:180]!t:?//R //R&/and/}{id}{num:?_//>02}.{extension}" is doing please? It doesn't look like regex. I gather [:180] limits the length to 180, but the rest is unclear.
"'reddit' in locals()": "{reddit[title][:180]!t:?//R //}{reddit[id]}.{extension}" - does the "reddit[title]" tell it to take the title from the "locals()", that is the output of gallery-dl -K
Secondly, how do you know to arrange the json like this? Is it from knowing the codebase? Or am I missing something in the documentation?
Perhaps the are other questions explaining this?
Thank you for your time.
https://github.com/mikf/gallery-dl/blob/master/docs/formatting.md
Thank you so much!
I taking a closer look at: gallery-dl/gallery-dl-example.conf at master · mikf/gallery-dl https://github.com/mikf/gallery-dl/blob/master/docs/gallery-dl-example.conf
... and can see the locals() and structure examples!
Thank you @rautamiekka
How can I download posts from a 'r/subreddit' and make the files go to "/gallery-dl/reddit/subreddit/"
And download posts from a 'u/user' and make files go to "/reddit/username/"
When I try to download from a r/subreddit and the post is hosted on imgur for example, files are saved on "gallery-dl/reddit/subreddit/imgur/" and filenames are different than those hosted on reddit using -K.
When I try to download from an u/user, there are post on several subreddits and each subreddit make their own folder like"gallery-dl/reddit/user/subreddit"
And last, how can set up filenames for u/user to be
"filename":"{category} {username} {id} {num}.{extension}
While filename for subreddits being
"filename":"{category} {subreddit} {id} {num}.{extension}
User example: --NSFW-- https://www.reddit.com/user/mister_checkers/
Subreddit example: --NSFW-- https://www.reddit.com/r/JeffMilton/
My config is basically empty:
}, "reddit": { "refresh-token":"###########", "directory":["reddit","{subreddit}"], "id":"child-id", "_p_":{"id":"parent-id"}, "filename":"{category} {subreddit} {id} {num}.{extension}" },
Im on android using termux.