chore: update public repo

This commit is contained in:
desu-bot 2025-02-19 02:30:26 +00:00
parent c118bcbfc3
commit f02ccb6029
No known key found for this signature in database
12 changed files with 510 additions and 2 deletions

View file

@ -0,0 +1,30 @@
import { asyncPool } from '@fuman/utils'
import Database from 'better-sqlite3'
import { counterIter, ffetchShiki } from './utils.ts'
const db = new Database('assets/shikimori.db')
db.exec(`
create table if not exists bans (
id integer primary key,
data text not null
);
`)
const insertQuery = db.prepare('insert into bans (id, data) values (?, ?) on conflict (id) do update set data = excluded.data')
const counter = counterIter(1)
await asyncPool(counter.iter, async (page) => {
if (page % 100 === 0) {
console.log('currently at page %d', page)
}
const data = await ffetchShiki(`/api/bans?page=${page}`).json<any>()
if (!data.length) {
counter.end()
return
}
for (const ban of data) {
insertQuery.run(ban.id, JSON.stringify(ban))
}
}, { limit: 64 })