Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve Reddit subcategory when redgifs runs as child extractor #6982

Closed
trych opened this issue Feb 12, 2025 · 2 comments
Closed

Retrieve Reddit subcategory when redgifs runs as child extractor #6982

trych opened this issue Feb 12, 2025 · 2 comments

Comments

@trych
Copy link

trych commented Feb 12, 2025

Hi there!

I have this config setup:

{
    "extractor": {

        "reddit":
        {
            "subreddit": {
              "directory": ["Reddit", "r_{subreddit}"],
              "filename": "{author}_{title[:180]!t:R /_/}{num:?_//>02}_{id}.{extension}"
            },
            "user": {
              "directory": ["Reddit", "u_{author}"],
              "filename": "{title[:180]!t:R /_/}{num:?_//>02}_{id}.{extension}"
            },

            "#": "transfer metadata to any child extractor as '_reddit_'",
            "parent-metadata": "_reddit_",
        },

        "redgifs": {
            "image": {
                "directory": {
                    "'_reddit_' in locals() and '_reddit_[subcategory]' == 'subreddit'": ["Reddit", "r_{_reddit_[subreddit]}"],
                    "'_reddit_' in locals()": ["Reddit", "u_{_reddit_[author]}"],
                    ""                      : ["Redgifs", "Clips", "Unsorted"]
                }
            },
            "filename": {
                "'_reddit_' in locals()": "{_reddit_[title][:180]!t:?/_/R /_/}{_reddit_[id]}_redgifs.{extension}",
                ""                      : "{filename}.{extension}"
            },
            "format": ["hd", "sd", "gif"],
            "fallback": true,
            "skip": true
        }
    }
}

I would love to have files saved in Reddit/r_subreddit/ when I download a subreddit (instead of a user profile), but this only works for the extractor itself and not for the redgifs child extractor.

How would I need to change this directory condition to actually figure out if I am downloading a subreddit or not?

"'_reddit_' in locals() and '_reddit_[subcategory]' == 'subreddit'"

Currently all redgif files end up in Reddit/u_username/.
Thanks!

@trych trych changed the title Retrieve Reddit subcategory when redgif runs as child extractor Retrieve Reddit subcategory when redgifs runs as child extractor Feb 12, 2025
@mikf
Copy link
Owner

mikf commented Feb 12, 2025

'_reddit_[subcategory]' == 'subreddit'

This compares the strings "_reddit_[subcategory]" and "subreddit". To access the actual subcategory value, you should not put _reddit_[subcategory] in quotes but only the subcategory part:

"'_reddit_' in locals() and _reddit_['subcategory'] == 'subreddit'"

Also, you can use reddit>redgifs as config section to not have to check for '_reddit_' in locals():

        "reddit>redgifs": {
            "image": {
                "directory": {
                    "_reddit_['subcategory'] == 'subreddit'": ["Reddit", "r_{_reddit_[subreddit]}"],
                    "": ["Reddit", "u_{_reddit_[author]}"]
                }
            }
        },
        "redgifs": {
            "image": {
                "directory": ["Redgifs", "Clips", "Unsorted"]
            }
        }

@trych
Copy link
Author

trych commented Feb 12, 2025

@mikf Thank you so much. I thought I had tried literally every possible combination of single quotes and other variants on that conditional statement. Apparently not, though. Works really well, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants