feat: cache marka api responses
This commit is contained in:
@@ -39,15 +39,16 @@ const POST = async (
|
||||
const movieCredits = !movie.content?.author &&
|
||||
await tmdb.getMovieCredits(tmdbId);
|
||||
|
||||
const releaseDate = movieDetails.release_date;
|
||||
if (releaseDate && !movie.content?.datePublished) {
|
||||
movie.content = movie.content || {};
|
||||
movie.content.datePublished = formatDate(new Date(releaseDate));
|
||||
}
|
||||
const director = movieCredits &&
|
||||
movieCredits?.crew?.filter?.((person) => person.job === "Director")[0];
|
||||
|
||||
movie.content ??= {
|
||||
_type: "Review",
|
||||
};
|
||||
|
||||
movie.content.datePublished ??= formatDate(movieDetails.release_date);
|
||||
|
||||
if (director && !movie.content?.author) {
|
||||
movie.content = movie.content || {};
|
||||
movie.content.author = {
|
||||
_type: "Person",
|
||||
name: director.name,
|
||||
@@ -65,18 +66,15 @@ const POST = async (
|
||||
];
|
||||
}
|
||||
|
||||
if (!movie.name) {
|
||||
movie.name = tmdbId;
|
||||
}
|
||||
movie.content.tmdbId ??= tmdbId;
|
||||
|
||||
let finalPath = "";
|
||||
const posterPath = movieDetails.poster_path;
|
||||
if (posterPath && !movie.content?.image) {
|
||||
if (posterPath && !movie.content.image) {
|
||||
const poster = await tmdb.getMoviePoster(posterPath);
|
||||
const extension = fileExtension(posterPath);
|
||||
finalPath = `movies/images/${safeFileName(name)}_cover.${extension}`;
|
||||
await createResource(finalPath, poster);
|
||||
movie.content = movie.content || {};
|
||||
movie.content.image = finalPath;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user