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

Reddit - help setting up reddit config filee #3682

Closed Kavolc closed 1 year ago

Kavolc commented 1 year ago

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.

Hrxn commented 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"]
    }

}
AphelionHalcyon32 commented 1 year ago

Hi @Hrxn Thank you for answering this. Its making me understand how this works a bit better and rethink my own directory structure.

Questions:

Perhaps the are other questions explaining this?

Thank you for your time.

rautamiekka commented 1 year ago

https://github.com/mikf/gallery-dl/blob/master/docs/formatting.md

AphelionHalcyon32 commented 1 year ago

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