feat: add initial recommendation data

This commit is contained in:
2023-09-08 13:33:29 +02:00
parent 517b1ba23d
commit cc112b7554
19 changed files with 289 additions and 170 deletions

View File

@ -11,6 +11,7 @@ import {
NotFoundError,
} from "@lib/errors.ts";
import * as cache from "@lib/cache/cache.ts";
import { createRecommendationResource } from "@lib/recommendation.ts";
const POST = async (
req: Request,
@ -42,8 +43,9 @@ const POST = async (
movie.meta.date = new Date(releaseDate);
}
const director =
movieCredits?.crew?.filter?.((person) => person.job === "Director")[0];
const director = movieCredits?.crew?.filter?.((person) =>
person.job === "Director"
)[0];
if (director && !movie.meta.author) {
movie.meta.author = director.name;
}
@ -57,6 +59,10 @@ const POST = async (
];
}
if (!movie.meta.tmdbId) {
movie.meta.tmdbId = tmdbId;
}
let finalPath = "";
const posterPath = movieDetails.poster_path;
if (posterPath && !movie.meta.image) {
@ -72,6 +78,8 @@ const POST = async (
cache.del(`documents:Media:movies:${name}.md`);
createRecommendationResource(movie, movieDetails.overview);
return json(movie);
};