mikf / gallery-dl

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

[Feature Request] Ability to make a chain of multiple conditions and sub-conditions for filters #5639

Open KonoVitoDa opened 4 months ago

KonoVitoDa commented 4 months ago

E.g.: If I'm on Pixiv and want to use a different directory structure just for ugoira, or if I want a new folder to be created if a given tag is present, it'd be really awesome if this could be achieved with something like this:

"directory":
            {
                "type=='ugoira'":
                {
                    "0<=total_bookmarks<=1000": ["Pixiv", "{illust_ai_type!s:?##R2#AI#R1##R0##}", "ugoira", "{rating}", "0-1000 Bookmarks"],
                    "1000<=total_bookmarks": ["Pixiv", "{illust_ai_type!s:?##R2#AI#R1##R0##}", "ugoira", "{rating}", "1000+ Bookmarks"]
                },
                "":
                {
                    "0<=total_bookmarks<=1000": ["Pixiv", "{illust_ai_type!s:?##R2#AI#R1##R0##}", "{rating}", "0-1000 Bookmarks"],
                    "1000<=total_bookmarks": ["Pixiv", "{illust_ai_type!s:?##R2#AI#R1##R0##}", "{rating}", "1000+ Bookmarks"],
                    "'コイカツ' in tags":
                    {
                        "0<=total_bookmarks<=1000": ["Pixiv", "Koikatsu", "{rating}", "0-1000 Bookmarks"],
                        "1000<=total_bookmarks": ["Pixiv", "Koikatsu", "{rating}", "1000+ Bookmarks"]
                    }
                }
            }
mikf commented 4 months ago

It is possible to combine conditions with and and or, and have them all in one big list:

"directory":
{
    "type=='ugoira' and 0<=total_bookmarks<=1000":
        ["Pixiv", "{illust_ai_type!s:?##R2#AI#R1##R0##}", "ugoira", "{rating}", "0-1000 Bookmarks"],
    "type=='ugoira' and 1000<=total_bookmarks":
        ["Pixiv", "{illust_ai_type!s:?##R2#AI#R1##R0##}", "ugoira", "{rating}", "1000+ Bookmarks"],
    "'コイカツ' in tags and 0<=total_bookmarks<=1000":
        ["Pixiv", "Koikatsu", "{rating}", "0-1000 Bookmarks"],
    "'コイカツ' in tags and 1000<=total_bookmarks":
        ["Pixiv", "Koikatsu", "{rating}", "1000+ Bookmarks"],
    "0<=total_bookmarks<=1000":
        ["Pixiv", "{illust_ai_type!s:?##R2#AI#R1##R0##}", "{rating}", "0-1000 Bookmarks"],
    "1000<=total_bookmarks":
        ["Pixiv", "{illust_ai_type!s:?##R2#AI#R1##R0##}", "{rating}", "1000+ Bookmarks"]
}
KonoVitoDa commented 4 months ago

It is possible to combine conditions with and and or, and have them all in one big list:

"directory":
{
    "type=='ugoira' and 0<=total_bookmarks<=1000":
        ["Pixiv", "{illust_ai_type!s:?##R2#AI#R1##R0##}", "ugoira", "{rating}", "0-1000 Bookmarks"],
    "type=='ugoira' and 1000<=total_bookmarks":
        ["Pixiv", "{illust_ai_type!s:?##R2#AI#R1##R0##}", "ugoira", "{rating}", "1000+ Bookmarks"],
    "'コイカツ' in tags and 0<=total_bookmarks<=1000":
        ["Pixiv", "Koikatsu", "{rating}", "0-1000 Bookmarks"],
    "'コイカツ' in tags and 1000<=total_bookmarks":
        ["Pixiv", "Koikatsu", "{rating}", "1000+ Bookmarks"],
    "0<=total_bookmarks<=1000":
        ["Pixiv", "{illust_ai_type!s:?##R2#AI#R1##R0##}", "{rating}", "0-1000 Bookmarks"],
    "1000<=total_bookmarks":
        ["Pixiv", "{illust_ai_type!s:?##R2#AI#R1##R0##}", "{rating}", "1000+ Bookmarks"]
}

Oh, true, this is a good workaround. But I think it would still be better, cleaner and didactic if it worked the way I mentioned, mainly considering that in my case I actually use ten different total_bookmarks ranges.