dl-e621: support downloading posts by ID or MD5
This commit is contained in:
parent
d472b8e360
commit
dd05ab91b3
|
@ -4,6 +4,11 @@ import { dl, get } from './_shared.js';
|
|||
|
||||
await dl(
|
||||
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}`) {
|
||||
posts = (await (await get('https://e621.net/posts.json', { limit: 320, page, tags: query })).json()).posts;
|
||||
yield posts.map(post => ({
|
||||
|
|
Loading…
Reference in New Issue