feat: watch history

This commit is contained in:
Adrian Castro
2024-03-27 12:31:16 +01:00
parent fa2425c183
commit 8c8ad47581
5 changed files with 107 additions and 73 deletions

View File

@@ -1,6 +1,7 @@
import type { ScrapeMedia } from "@movie-web/provider-utils";
import { fetchMediaDetails, fetchSeasonDetails } from "@movie-web/tmdb";
import type { ItemData } from "~/components/item/item";
import type { PlayerMeta } from "~/stores/player/slices/video";
export const convertMetaToScrapeMedia = (meta: PlayerMeta): ScrapeMedia => {
@@ -27,6 +28,28 @@ export const convertMetaToScrapeMedia = (meta: PlayerMeta): ScrapeMedia => {
throw new Error("Invalid meta type");
};
export const convertMetaToItemData = (meta: PlayerMeta): ItemData => {
if (meta.type === "movie") {
return {
id: meta.tmdbId,
title: meta.title,
year: meta.releaseYear,
type: meta.type,
posterUrl: meta.poster ?? "",
};
}
if (meta.type === "show") {
return {
id: meta.tmdbId,
title: meta.title,
year: meta.releaseYear,
type: "tv",
posterUrl: meta.poster ?? "",
};
}
throw new Error("Invalid media type");
};
export const getNextEpisode = async (
meta: PlayerMeta,
): Promise<PlayerMeta | undefined> => {