artist alley json dump
This commit is contained in:
parent
0c9d779782
commit
8df935347c
2 changed files with 42 additions and 0 deletions
41
caar/get.ts
Normal file
41
caar/get.ts
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
// TODO: types (don't even sweat validation)
|
||||||
|
// TODO: do sweat error handling
|
||||||
|
type Cursor = { refSnowflake: string; offset: number; sortOrder: string };
|
||||||
|
|
||||||
|
export const get = (
|
||||||
|
cursor?: Cursor,
|
||||||
|
): Promise<{ listings: any[]; nextCursor: Cursor | undefined }> =>
|
||||||
|
fetch(
|
||||||
|
`https://cohost.org/api/v1/trpc/artistAlley.getListingsForDisplay?batch=1&input=${
|
||||||
|
encodeURI(
|
||||||
|
JSON.stringify({
|
||||||
|
"0": {
|
||||||
|
adultDisplayMode: "include",
|
||||||
|
categories: [],
|
||||||
|
categoryMatch: "all",
|
||||||
|
sortOrder: "newest",
|
||||||
|
cursor,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}`,
|
||||||
|
).then(async (r) => {
|
||||||
|
const json = (await r.json())[0];
|
||||||
|
if (json.error) throw json.error;
|
||||||
|
|
||||||
|
const j = json.result.data;
|
||||||
|
return {
|
||||||
|
listings: j.listings.map((l: any) => ({
|
||||||
|
...l,
|
||||||
|
author: j.relevantProjects[l.projectId],
|
||||||
|
})),
|
||||||
|
nextCursor: j.nextCursor,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
export const get_all = async (cursor?: Cursor): Promise<any[]> => {
|
||||||
|
const { listings, nextCursor } = await get(cursor);
|
||||||
|
return nextCursor ? [...listings, ...(await get_all(nextCursor))] : listings;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (import.meta.main) console.log(await get_all());
|
1
name.txt
Normal file
1
name.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Cohost Artist Alley Repository
|
Loading…
Reference in a new issue