From cdd3d77d56fd304346c643b8d98b6a1e895fc236 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sun, 17 Oct 2021 18:53:04 +0200 Subject: Support multiple e621 queries, post as unlisted --- src/api/e621/index.ts | 6 ++++-- src/api/mastodon/index.ts | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/api') diff --git a/src/api/e621/index.ts b/src/api/e621/index.ts index 6aa6a35..4748e87 100644 --- a/src/api/e621/index.ts +++ b/src/api/e621/index.ts @@ -27,14 +27,16 @@ export const client = got.extend({ }); export async function randomPost() { - const page = Math.floor(Math.random() * (config.e621.maxPage - 1)) + 1; + const queryIndex = Math.floor(Math.random() * config.e621.queries.length); + const query = config.e621.queries[queryIndex]; + const page = Math.floor(Math.random() * (query.maxPage - 1)) + 1; const response = await client .get("https://e926.net/posts.json", { searchParams: { limit: 75, page, - tags: config.e621.tags.join(" "), + tags: query.tags.join(" "), }, }) .json<{ posts: readonly Post[] }>(); diff --git a/src/api/mastodon/index.ts b/src/api/mastodon/index.ts index 2d8636e..d0de0a0 100644 --- a/src/api/mastodon/index.ts +++ b/src/api/mastodon/index.ts @@ -52,6 +52,7 @@ export async function createStatus( media_ids: [attachmentId], sensitive: true, spoiler_text: spoilerText, + visibility: "unlisted", }, }) .json(); -- cgit v1.2.3-70-g09d2