diff --git a/lib/resource/movies.ts b/lib/resource/movies.ts index ed05851..18b33e5 100644 --- a/lib/resource/movies.ts +++ b/lib/resource/movies.ts @@ -1,17 +1,21 @@ export type Movie = { - id: string; - name: string; - description: string; - type: "movie"; - tags: string[]; - meta: { - date: Date; - tmdbId?: number; - keywords?: string[]; - image: string; - thumbnail?: string; - average?: string; - author: string; - rating: number; + _type: "Review"; + tmdbId?: number; + link?: string; + author?: { + _type: "Person"; + name?: string; }; + datePublished?: string; + reviewRating?: { + bestRating?: number; + worstRating?: number; + ratingValue?: number; + }; + reviewBody?: string; + itemReviewed?: { + name?: string; + }; + keywords?: string[]; + image?: string; }; diff --git a/lib/resource/series.ts b/lib/resource/series.ts index eb7a800..b6fc136 100644 --- a/lib/resource/series.ts +++ b/lib/resource/series.ts @@ -1,17 +1,3 @@ -export type Series = { - id: string; - name: string; - description: string; - type: "series"; - tags: string[]; - meta: { - date: Date; - image: string; - author: string; - tmdbId?: number; - rating: number; - average?: string; - thumbnail?: string; - done?: boolean; - }; -}; +import { Movie } from "./movies.ts"; + +export type Series = Movie; diff --git a/routes/api/movies/[name].ts b/routes/api/movies/[name].ts index f59bdc5..4b3e067 100644 --- a/routes/api/movies/[name].ts +++ b/routes/api/movies/[name].ts @@ -42,19 +42,6 @@ export const handler: Handlers = { await createResource(finalPath, poster); } - const metadata = { - tmdbId, - } as Movie["meta"]; - if (releaseDate) { - metadata.date = new Date(releaseDate); - } - if (finalPath) { - metadata.image = finalPath; - } - if (director?.name) { - metadata.author = director.name; - } - const tags: string[] = []; if (movieDetails.genres) { tags.push( @@ -65,12 +52,19 @@ export const handler: Handlers = { } const movie: Movie = { - id: name, - name: name, - type: "movie", - description: "", - tags, - meta: metadata, + _type: "Review", + image: finalPath, + datePublished: releaseDate, + tmdbId, + author: { + _type: "Person", + name: director?.name, + }, + itemReviewed: { + name: name, + }, + reviewBody: "", + keywords: tags, }; await createResource(`movies/${safeFileName(name)}.md`, movie); diff --git a/routes/api/series/[name].ts b/routes/api/series/[name].ts index 7233a66..c062709 100644 --- a/routes/api/series/[name].ts +++ b/routes/api/series/[name].ts @@ -40,17 +40,6 @@ export const handler: Handlers = { await createResource(finalPath, poster); } - const metadata = { tmdbId } as Series["meta"]; - if (releaseDate) { - metadata.date = new Date(releaseDate); - } - if (finalPath) { - metadata.image = finalPath; - } - if (director) { - metadata.author = director.name; - } - const tags: string[] = []; if (seriesDetails.genres) { tags.push( @@ -61,12 +50,19 @@ export const handler: Handlers = { } const series: Series = { - id: name, - name: name, - tags, - type: "series", - description: "", - meta: metadata, + _type: "Review", + image: finalPath, + datePublished: releaseDate, + tmdbId, + author: { + _type: "Person", + name: director?.name, + }, + itemReviewed: { + name: name, + }, + reviewBody: "", + keywords: tags, }; await createResource(`series/${safeFileName(name)}.md`, series);