mikf / gallery-dl

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

Use keys from one service in another service's custom filenames? #637

Closed webl0p closed 1 year ago

webl0p commented 4 years ago

Is it possible to use keywords from one extractor in the customized filename for another extractor?

For example, when running gallery-dl on a Reddit account, can you append the Reddit account name to the filenames of any Imgur and Gfycat files that are also downloaded? I've been able to add the "author" keyword to the filenames hosted on Reddit with no trouble, but haven't found a way to also add the same value to files from other services referenced by that account.

mikf commented 4 years ago

That's not possible at the moment, but you could use the parent-directory option to at least put those Imgur and Gfycat files into the Reddit directory they originated from.

master-leonardo commented 4 years ago

@mikf I was going to open a new issue but i believe this is exactly what i was looking for. I noticed that when downloading reddit profiles, any imgur/gfycat links go to a different folder. I would like to save all images/videos from said profile to one single reddit folder. You mention parent-directory but i just can't seem to make it work. could you please provide an example. Thank you. Not sure if it would help, but i've been using ripme for reddit, it saves all to a reddit user folder. Maybe you could check the code? It's been a while since they last updated.

Hrxn commented 4 years ago

Here's an example: First you need to make sure to use gallery-dl with a config file. (If you haven't already, here's how)

For reddit, the reddit part of the config file is relevant, obviously. In the example, this part here:

        "reddit":
        {
            "refresh-token": null,
            "comments": 0,
            "morecomments": false,
            "date-min": 0,
            "date-max": 253402210800,
            "date-format": "%Y-%m-%dT%H:%M:%S",
            "id-min": "0",
            "id-max": "zik0zj",
            "recursion": 0,
            "videos": true,
            "user-agent": "Python:gallery-dl:0.8.4 (by /u/mikf1)"
        },

Now, only the parent-directory option needs to be added, like this:

        "reddit":
        {
            "refresh-token": null,
            "comments": 0,
            "morecomments": false,
            "date-min": 0,
            "date-max": 253402210800,
            "date-format": "%Y-%m-%dT%H:%M:%S",
            "id-min": "0",
            "id-max": "zik0zj",
            "recursion": 0,
            "videos": true,
            "user-agent": "Python:gallery-dl:0.8.4 (by /u/mikf1)",
            "parent-directory": true
        },
allendema commented 1 year ago
        "reddit": {
            "parent-skip": true,
            "parent-directory": true,
            "category-transfer": false,
            "parent-metadata": "parent",
            "whitelist": ["imgur", "redgifs", "gfycat"],
           "#": "OTHER"
          }

also add the same value to files from other services ["imgur", "redgifs", "gfycat"]


 "imgur": {
            "mp4": true,
            "#": "https://github.com/mikf/gallery-dl/issues/827#issuecomment-903173214",
            "directory": {
                "'parent' in locals()": []
                },

            "filename": {
                "'parent' in locals()": "{parent[date]:%Y_%m_%d}_{parent[subreddit]|parent[author]}_{parent[title][:20]!t:R /_/}_{parent[id]}.{extension}"
                 },

            "archive": "archives/imgur/imgur.archive"

        }