From 37e76927cc72baad03c2ef200351aafeb4ea1e7e Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sat, 5 Oct 2024 19:38:02 -0700 Subject: feat(graphql): add subtitles --- src/graphql/anime/resolvers.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/graphql/anime/resolvers.ts (limited to 'src/graphql/anime/resolvers.ts') 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 = { + 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]) + ) + } + }; + } + } +}; -- cgit v1.2.3