reduce casts

This commit is contained in:
adrifcastr 2023-06-21 12:47:09 +02:00
parent 33b67f32b1
commit 9495a3bf41

View File

@ -49,30 +49,28 @@ export function formatTMDBMetaResult(
): TMDBMediaResult { ): TMDBMediaResult {
let tmdbmeta; let tmdbmeta;
if (type === MWMediaType.MOVIE) { if (type === MWMediaType.MOVIE) {
const movie = details as TMDBMovieData;
tmdbmeta = { tmdbmeta = {
id: details.id, id: details.id,
title: (details as TMDBMovieData).title, title: movie.title,
object_type: mediaTypeToTMDB(type), object_type: mediaTypeToTMDB(type),
poster: (details as TMDBMovieData).poster_path ?? undefined, poster: movie.poster_path ?? undefined,
original_release_year: Number( original_release_year: Number(movie.release_date?.split("-")[0]),
(details as TMDBMovieData).release_date?.split("-")[0]
),
}; };
} }
if (type === MWMediaType.SERIES) { if (type === MWMediaType.SERIES) {
const show = details as TMDBShowData;
tmdbmeta = { tmdbmeta = {
id: details.id, id: details.id,
title: (details as TMDBShowData).name, title: show.name,
object_type: mediaTypeToTMDB(type), object_type: mediaTypeToTMDB(type),
seasons: (details as TMDBShowData).seasons.map((v) => ({ seasons: show.seasons.map((v) => ({
id: v.id, id: v.id,
season_number: v.season_number, season_number: v.season_number,
title: v.name, title: v.name,
})), })),
poster: (details as TMDBMovieData).poster_path ?? undefined, poster: (details as TMDBMovieData).poster_path ?? undefined,
original_release_year: Number( original_release_year: Number(show.first_air_date?.split("-")[0]),
(details as TMDBShowData).first_air_date?.split("-")[0]
),
}; };
} }