mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-29 16:07:40 +01:00
fix movie metadata
This commit is contained in:
parent
c4afc37217
commit
20c4b14799
2 changed files with 39 additions and 19 deletions
|
@ -43,6 +43,41 @@ export interface DetailedMeta {
|
|||
tmdbId?: string;
|
||||
}
|
||||
|
||||
export function fromatTMDBMetaResult(
|
||||
details: TMDBShowData | TMDBMovieData,
|
||||
type: MWMediaType
|
||||
): TMDBMediaResult | undefined {
|
||||
let tmdbmeta;
|
||||
if (type === MWMediaType.MOVIE) {
|
||||
tmdbmeta = {
|
||||
id: details.id,
|
||||
title: (details as TMDBMovieData).title,
|
||||
object_type: mediaTypeToTMDB(type),
|
||||
poster: (details as TMDBMovieData).poster_path ?? undefined,
|
||||
original_release_year: Number(
|
||||
(details as TMDBMovieData).release_date?.split("-")[0]
|
||||
),
|
||||
};
|
||||
}
|
||||
if (type === MWMediaType.SERIES) {
|
||||
tmdbmeta = {
|
||||
id: details.id,
|
||||
title: (details as TMDBShowData).name,
|
||||
object_type: mediaTypeToTMDB(type),
|
||||
seasons: (details as TMDBShowData).seasons.map((v) => ({
|
||||
id: v.id,
|
||||
season_number: v.season_number,
|
||||
title: v.name,
|
||||
})),
|
||||
poster: (details as TMDBMovieData).poster_path ?? undefined,
|
||||
original_release_year: Number(
|
||||
(details as TMDBShowData).first_air_date?.split("-")[0]
|
||||
),
|
||||
};
|
||||
}
|
||||
return tmdbmeta;
|
||||
}
|
||||
|
||||
export async function getMetaFromId(
|
||||
type: MWMediaType,
|
||||
id: string,
|
||||
|
@ -79,25 +114,8 @@ export async function getMetaFromId(
|
|||
}
|
||||
}
|
||||
|
||||
const tmdbmeta: TMDBMediaResult = {
|
||||
id: details.id,
|
||||
title:
|
||||
type === MWMediaType.MOVIE
|
||||
? (details as TMDBMovieData).title
|
||||
: (details as TMDBShowData).name,
|
||||
object_type: mediaTypeToTMDB(type),
|
||||
seasons: (details as TMDBShowData).seasons.map((v) => ({
|
||||
id: v.id,
|
||||
season_number: v.season_number,
|
||||
title: v.name,
|
||||
})),
|
||||
poster: (details as TMDBMovieData).poster_path ?? undefined,
|
||||
original_release_year:
|
||||
type === MWMediaType.MOVIE
|
||||
? Number((details as TMDBMovieData).release_date?.split("-")[0])
|
||||
: Number((details as TMDBShowData).first_air_date?.split("-")[0]),
|
||||
};
|
||||
|
||||
const tmdbmeta = fromatTMDBMetaResult(details, type);
|
||||
if (!tmdbmeta) return null;
|
||||
const meta = formatTMDBMeta(tmdbmeta, seasonData);
|
||||
if (!meta) return null;
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@ export async function searchForMedia(query: MWQuery): Promise<MWMediaMeta[]> {
|
|||
})
|
||||
);
|
||||
|
||||
console.log(results[0]);
|
||||
|
||||
cache.set(query, results, 3600);
|
||||
return results;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue