Bionus / imgbrd-grabber

Very customizable imageboard/booru downloader with powerful filenaming features.
https://www.bionus.org/imgbrd-grabber/
Apache License 2.0
2.59k stars 220 forks source link

Logical operators or exceptions #3122

Open kifchan opened 8 months ago

kifchan commented 8 months ago

Problem: For example site danbooru, i want download tag animal_ears except images contained boys wihout girls. If i add tag -1boy thats mean even if image contain 1girl this will be dropped.

But I don't know a nice solution =\ something like: animal_ears (-1boy -2boys -multyply_boys except 1girl 2girls multiple_girls)

ProtagNeptune commented 8 months ago

Did you look at the Search documentation? You should use Post-filters for that.

Search: animal_ears Post-filtering: !("1boy"|"2boys"|"multiple_boys")&("1girl"|"2girls"|"multiple_girls")

image

kifchan commented 8 months ago

Did you look at the Search documentation? You should use Post-filters for that.

There's nothing in the documentation about this

kifchan commented 8 months ago

About your example, if file contain 1girl and 1boy, still doesnt work i guess (or i did something wrong), i want to skip only files where only boys. And if file not contain 1girl and 1boy i also want download it

kifchan commented 8 months ago

I'll try to put it another way. I want download any files and exclude files with "1boy" BUT, if "1boy" file also contain "1girl" tag, then this should be free to download

ProtagNeptune commented 8 months ago

I'll try to put it another way. I want download any files and exclude files with "1boy" BUT, if "1boy" file also contain "1girl" tag, then this should be free to download

Try that? 🤔 !("1boy"|"2boys"|"multiple_boys")&("1girl"|"2girls"|"multiple_girls")|("1girl"|"2girls"|"multiple_girls")

FalconSN commented 8 months ago

If you want everything that contains at least one of 1girl, 2girls and multiple_girls tags, then you can simply use ("1girl"|"2girls"|"multiple_girls") and not say anything about boy tags. I don't know how operators work in Grabber, but if it's as @ProtagNeptune said, then this should work. If you want also the images without girl tags, then add |!("1boy"|"2boys"|"multiple_boys") to the rightside of expression above, without space. Should be like this: ("1girl"|"2girls"|"multiple_girls")|!("1boy"|"2boys"|"multiple_boys") Assuming | is the or operator, this will prioritize images with girl tags, if not found then ignore images with boy tags.

ProtagNeptune commented 8 months ago

If you want everything that contains at least one of 1girl, 2girls and multiple_girls tags, then you can simply use ("1girl"|"2girls"|"multiple_girls") and not say anything about boy tags. I don't know how operators work in Grabber, but if it's as @ProtagNeptune said, then this should work.

Yeah, that is definitely easier.

If you want also the images without girl tags, then add |!("1boy"|"2boys"|"multiple_boys") to the rightside of expression above, without space.

The ! inverts the statement so |!("1boy"|"2boys"|"multiple_boys") will remove every image containing the boy tags.

Assuming | is the or operator, this will prioritize images with girl tags, if not found then ignore images with boy tags.

Yeah, you can find that in the Filename documentation at the If-then-else conditions.

kifchan commented 8 months ago

I'll try to put it another way. I want download any files and exclude files with "1boy" BUT, if "1boy" file also contain "1girl" tag, then this should be free to download

Try that? 🤔 !("1boy"|"2boys"|"multiple_boys")&("1girl"|"2girls"|"multiple_girls")|("1girl"|"2girls"|"multiple_girls")

Thx, this work better, but it won't load any pictures like i said before, this one without 1boy and 1 girl was ignored https://gelbooru.com/index.php?page=post&s=view&id=9811903

Assuming | is the or operator, this will prioritize images with girl tags, if not found then ignore images with boy tags.

Yeah, you can find that in the Filename documentation at the If-then-else conditions.

Great conditions already exist here :D thank you for link

ProtagNeptune commented 8 months ago

I'll try to put it another way. I want download any files and exclude files with "1boy" BUT, if "1boy" file also contain "1girl" tag, then this should be free to download

Try that? 🤔 !("1boy"|"2boys"|"multiple_boys")&("1girl"|"2girls"|"multiple_girls")|("1girl"|"2girls"|"multiple_girls")

Thx, this work better, but it won't load any pictures like i said before, this one without 1boy and 1 girl was ignored https://gelbooru.com/index.php?page=post&s=view&id=9811903

Try that? 🤔 !("1boy"|"2boys"|"multiple_boys")&("1girl"|"2girls"|"multiple_girls")|!("1boy"|"2boys"|"multiple_boys")&!("1girl"|"2girls"|"multiple_girls")|("1girl"|"2girls"|"multiple_girls")

This should read as something like:

  1. If not ("1boy" or "2boys"or "multiple_boys") and If ("1girl" or "2girls" or "multiple_girls").
  2. Else If not ("1boy" or "2boys"or "multiple_boys") and If not ("1girl" or "2girls" or "multiple_girls").
  3. Else If ("1girl" or "2girls" or "multiple_girls").

But I might be overcomplicating it a bit, I think... 😅

kifchan commented 8 months ago

Try that? 🤔 !("1boy"|"2boys"|"multiple_boys")&("1girl"|"2girls"|"multiple_girls")|!("1boy"|"2boys"|"multiple_boys")&!("1girl"|"2girls"|"multiple_girls")|("1girl"|"2girls"|"multiple_girls")

Seems like this one work ^_^

ProtagNeptune commented 8 months ago

Seems like this one work ^_^

So for a complete answer here ya go:

To both get images without the boy tags and without the girl tags: !("1boy"|"2boys"|"multiple_boys")&!("1girl"|"2girls"|"multiple_girls")

To both get images with the boy tags and with the girl tags: ("1boy"|"2boys"|"multiple_boys")&("1girl"|"2girls"|"multiple_girls")

To get images without the boy tags: !("1boy"|"2boys"|"multiple_boys")

To get images with the girl tags: ("1girl"|"2girls"|"multiple_girls")

So: !("1boy"|"2boys"|"multiple_boys")&!("1girl"|"2girls"|"multiple_girls")|("1boy"|"2boys"|"multiple_boys")&("1girl"|"2girls"|"multiple_girls")|!("1boy"|"2boys"|"multiple_boys")|("1girl"|"2girls"|"multiple_girls")

That's about it. 🤔

FalconSN commented 8 months ago

The ! inverts the statement so |!("1boy"|"2boys"|"multiple_boys") will remove every image containing the boy tags.

Only if first expression evaluates to false, that is no girl tags found.

For example site danbooru, i want download tag animal_ears except images contained boys wihout girls.

ProtagNeptune commented 8 months ago

The ! inverts the statement so |!("1boy"|"2boys"|"multiple_boys") will remove every image containing the boy tags.

Only if first expression evaluates to false, that is no girl tags found.

True, I edited my previous comment to reflect that. 🫡