1
Fork 0

batch-allthefallen: improve multiple tag handling

This commit is contained in:
Conduitry 2024-03-24 09:31:20 -04:00
parent e0f8446d1f
commit c3eb4512cf
2 changed files with 3 additions and 3 deletions

View file

@ -6,8 +6,8 @@ import { get_files } from './lib/sites/allthefallen.js';
const batch = await traverse('.');
for (const query of batch.tags) {
for await (const { url, filename, mtime } of get_files(query)) {
batch.process(url, filename, [query], mtime);
for await (const { url, filename, tags, mtime } of get_files(query)) {
batch.process(url, filename, tags, mtime);
}
}

View file

@ -4,7 +4,7 @@ export async function* get_files(query) {
for (let page = 1, posts; !posts || posts.length === 100; page++) {
posts = await (await fetch_retry(`https://booru.allthefallen.moe/posts.json?limit=100&page=${page}&tags=${encodeURIComponent(query)}`)).json();
for (const post of posts) {
yield { url: post.file_url, filename: `${post.id}-${post.md5}.${post.media_asset.file_ext}`, mtime: post.created_at };
yield { url: post.file_url, filename: `${post.id}-${post.md5}.${post.media_asset.file_ext}`, tags: post.tag_string.split(' '), mtime: post.created_at };
}
}
}