1
Fork 0

dl-e621: support downloading posts by ID or MD5

This commit is contained in:
Conduitry 2022-06-16 20:11:38 -04:00
parent d472b8e360
commit dd05ab91b3
1 changed files with 5 additions and 0 deletions

View File

@ -4,6 +4,11 @@ import { dl, get } from './_shared.js';
await dl( await dl(
async function*(query) { async function*(query) {
if (/^[0-9]+$/.test(query)) {
query = `id:${query}`;
} else if (/^[0-9a-f]{32}$/i.test(query)) {
query = `md5:${query}`;
}
for (let page = null, posts; !posts || posts.length === 320; page = `b${posts[319]?.id}`) { for (let page = null, posts; !posts || posts.length === 320; page = `b${posts[319]?.id}`) {
posts = (await (await get('https://e621.net/posts.json', { limit: 320, page, tags: query })).json()).posts; posts = (await (await get('https://e621.net/posts.json', { limit: 320, page, tags: query })).json()).posts;
yield posts.map(post => ({ yield posts.map(post => ({