Giter Club home page Giter Club logo

Comments (2)

Mapaler avatar Mapaler commented on June 24, 2024

tag 的话,在 illust.tags 里 ,参见 illust对象示例
如果你是需要把图片的所有 tag 添加到文件名,将这个数组内字符串提取出来,再合并到一个字符串即可,这里用到了JS 的编程语法。当然你还可以在这个基础上加入标签的排序或者筛选等。

illust.tags.map(o=>o.name).join('、')

图像 8

过滤器,组合多个条件,使用逻辑运算符,请见 逻辑或(||)逻辑与(&&)
先给你分步骤写

let tags = illust.tags.map(o=>o.name); //将 tag 字符串数组存入变量简化语句

tags.includes("博麗霊夢") && tags.includes("霧雨魔理沙") && tags.includes("東風谷早苗"); // tag 需要灵梦、魔理沙、早苗3个同时存在才返回 true
tags.includes("博麗霊夢") || tags.includes("霧雨魔理沙") || tags.includes("東風谷早苗"); // tag 灵梦、魔理沙、早苗中有任意一个就返回 true
(tags.includes("博麗霊夢") || tags.includes("霧雨魔理沙")) && tags.includes("東風谷早苗"); // tag 里有1个灵梦或者魔理沙,并同时有早苗,返回 true
!tags.includes("博麗霊夢") // !是取反,就是not的意思,这表示tag有灵梦时就返回 false

由于我默认设定的是排除过滤器,所以筛选应该是需要排除的图片;而只保留某种图片,则将这种图片的筛选条件取反就行了。
我现在要一定有灵梦和早苗的图,但是一定不要有魔理沙在上面。那么语句应该写为

!(tags.includes("博麗霊夢") && tags.includes("霧雨魔理沙")) || tags.includes("東風谷早苗")

上面的意思是,同时存在灵梦和魔理沙时,先得到 true ,然后取反变为 false ,所以其他只存在单个或者都不存在的情况都会返回 true ,就不会下载图片。另外存在早苗时也返回 true ,所以也不下载。
具体写到过滤器里时,又需要用一些语法进行包装(过滤器这里不要写掩码的括号)

(tags=> !(tags.includes("博麗霊夢") && tags.includes("霧雨魔理沙")) || tags.includes("東風谷早苗") )(illust.tags.map(o=>o.name))

图像 9
你也可以用在外面加上掩码的方式,在文本输出的地方查看逻辑输出结果

from pixivuserbatchdownload.

shitiamtired avatar shitiamtired commented on June 24, 2024

学到了,感谢!

from pixivuserbatchdownload.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.