diff options
| author | Fuwn <[email protected]> | 2024-10-05 19:38:02 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-10-05 19:40:08 -0700 |
| commit | 37e76927cc72baad03c2ef200351aafeb4ea1e7e (patch) | |
| tree | f755d58ada1f3a37e3041ef75c231a847bb639b5 /src/graphql/anime/resolvers.ts | |
| parent | fix(feeds): oauth refresh url (diff) | |
| download | due.moe-37e76927cc72baad03c2ef200351aafeb4ea1e7e.tar.xz due.moe-37e76927cc72baad03c2ef200351aafeb4ea1e7e.zip | |
feat(graphql): add subtitles
Diffstat (limited to 'src/graphql/anime/resolvers.ts')
| -rw-r--r-- | src/graphql/anime/resolvers.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/graphql/anime/resolvers.ts b/src/graphql/anime/resolvers.ts new file mode 100644 index 00000000..7d04082d --- /dev/null +++ b/src/graphql/anime/resolvers.ts @@ -0,0 +1,22 @@ +import type { WithIndex } from '../$types'; +import type { Resolvers } from './$types'; + +export const resolvers: WithIndex<Resolvers> = { + Query: { + Anime: async (_, args) => { + const timezone = args.timezone || 'Asia/Tokyo'; + + return { + subtitles: { + timezone, + schedule: Object.fromEntries( + Object.entries( + (await (await fetch(`https://subsplease.org/api/?f=schedule&tz=${timezone}`)).json()) + .schedule + ).map(([key, value]) => [key.toLowerCase(), value]) + ) + } + }; + } + } +}; |