1
0
Fork 0

Added stuff so you can search safe or not, and excluded images from being uploaded to git

This commit is contained in:
grumbulon 2022-04-02 21:39:29 -04:00
parent 8129565180
commit 8acc2a04bf
2 changed files with 21 additions and 8 deletions

5
.gitignore vendored
View File

@ -117,4 +117,7 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
.vscode/*
.vscode/*
#merde
img/*

View File

@ -11,21 +11,31 @@ function search() {
console.log(err);
return;
}
//Get list of posts for the tag(s)
request(
`https://${config.booru}.donmai.us/posts.json?tags=${config.tags}&z=1`,
{ json: true },
(err, res, body) => {
if (config.rating === "safe") {
let queryUrl = `https://${config.booru}.donmai.us/posts.json?tags=${config.tags}+rating:${config.rating}&z=1`;
request(queryUrl, { json: true }, (err, res, body) => {
if (err) {
return console.log(err);
}
const randPost = Math.floor(Math.random() * body.length);
const postID = body[randPost].id;
getPost(postID);
}
);
});
} else {
let queryUrl = `https://${config.booru}.donmai.us/posts.json?tags=${config.tags}&z=1`;
request(queryUrl, { json: true }, (err, res, body) => {
if (err) {
return console.log(err);
}
const randPost = Math.floor(Math.random() * body.length);
const postID = body[randPost].id;
getPost(postID);
});
}
});
}
function getPost(postID) {
parseConfig.readConfig(configFile, (err, config) => {
if (err) {