Save OMDb details and posters locally

This commit is contained in:
SirBlob committed 2026-11-01 22:58:56 -05:00
1 parent 1f7e88f117
commit 4f78883f0b
6 files changed
+239 -7

No files matched your search

+7 -2
View File
@@ -1,21 +1,26 @@
import { about } from '#lib/content';
import { getAniListProfile } from '#lib/server/anilist';
import { getMediaDetails } from '#lib/server/omdb';
import { storedDetailsFor } from '#lib/media/stored';
import { getListeningProfile } from '#lib/server/lastfm/profile';
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async () => {
const mediaUrls = [...about.shows, ...about.movies].map((item) => item.url);
const anilistUsername = about.anilistUsername;
const storedDetails = storedDetailsFor(mediaUrls);
const unsavedUrls = mediaUrls.filter((url) => !storedDetails[url]);
const [anime, manga, mediaDetails, listening] = await Promise.all([
const [anime, manga, fetchedDetails, listening] = await Promise.all([
anilistUsername ? getAniListProfile(anilistUsername, 'ANIME') : null,
anilistUsername ? getAniListProfile(anilistUsername, 'MANGA') : null,
getMediaDetails(mediaUrls),
unsavedUrls.length ? getMediaDetails(unsavedUrls) : {},
about.lastfmUsername ? getListeningProfile(about.lastfmUsername) : null
]);
const hasManga = !!manga?.statusCounts.some((item) => item.count > 0);
const mediaDetails = { ...fetchedDetails, ...storedDetails };
return { anime, manga: hasManga ? manga : null, mediaDetails, listening };
};