aboutsummaryrefslogtreecommitdiff
path: root/src/graphql/anime/resolvers.ts
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-10-05 19:38:02 -0700
committerFuwn <[email protected]>2024-10-05 19:40:08 -0700
commit37e76927cc72baad03c2ef200351aafeb4ea1e7e (patch)
treef755d58ada1f3a37e3041ef75c231a847bb639b5 /src/graphql/anime/resolvers.ts
parentfix(feeds): oauth refresh url (diff)
downloaddue.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.ts22
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])
+ )
+ }
+ };
+ }
+ }
+};