f0ckv2/debug/autotagger.mjs

61 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2022-05-05 14:02:17 +00:00
import db from "../src/inc/sql.mjs";
import lib from "../src/inc/lib.mjs";
2021-12-26 16:24:42 +00:00
(async () => {
const _args = process.argv.slice(2);
const _from = +_args[0];
2022-05-05 14:03:38 +00:00
const _to = _from + 500;
2021-12-26 16:24:42 +00:00
2022-05-05 14:02:17 +00:00
const f0cks = await db`
select *
from items
where
id not in (select item_id from tags_assign group by item_id) and
mime like 'image/%' and
id between ${_from} and ${_to}
`;
2021-12-26 16:24:42 +00:00
2022-05-05 14:02:17 +00:00
console.time('blah');
2021-12-26 16:24:42 +00:00
for(let f of f0cks) {
2022-05-05 14:02:17 +00:00
const tmp = await lib.detectNSFW(f.dest);
console.log(
'https://f0ck.me/' + f.id,
tmp.isNSFW,
tmp.score.toFixed(2),
{
sexy: tmp.scores.sexy.toFixed(2),
porn: tmp.scores.porn.toFixed(2),
hentai: tmp.scores.hentai.toFixed(2),
neutral: tmp.scores.neutral.toFixed(2)
}
);
await db`
insert into "tags_assign" ${
db({
item_id: f.id,
tag_id: tmp.nsfw ? 2 : 1,
2022-05-14 10:59:35 +00:00
user_id: 1
2022-05-05 14:02:17 +00:00
})
}
`;
if(tmp.hentai >= .7) {
await db`
insert into "tags_assign" ${
db({
item_id: f.id,
2022-05-14 10:59:35 +00:00
tag_id: 4, // hentai
user_id: 1 // autotagger
2022-05-05 14:02:17 +00:00
})
}
`;
2021-12-26 16:24:42 +00:00
}
2022-05-05 14:02:17 +00:00
2021-12-26 16:24:42 +00:00
};
2022-05-05 14:02:17 +00:00
console.timeEnd('blah');
process.exit();
2021-12-26 16:24:42 +00:00
})();