mirror of
https://github.com/movie-web/movie-web.git
synced 2024-12-27 08:21:51 +01:00
fix movie metadata
This commit is contained in:
parent
763de37e9e
commit
0e9263b619
@ -43,6 +43,41 @@ export interface DetailedMeta {
|
|||||||
tmdbId?: string;
|
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(
|
export async function getMetaFromId(
|
||||||
type: MWMediaType,
|
type: MWMediaType,
|
||||||
id: string,
|
id: string,
|
||||||
@ -79,25 +114,8 @@ export async function getMetaFromId(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const tmdbmeta: TMDBMediaResult = {
|
const tmdbmeta = fromatTMDBMetaResult(details, type);
|
||||||
id: details.id,
|
if (!tmdbmeta) return null;
|
||||||
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 meta = formatTMDBMeta(tmdbmeta, seasonData);
|
const meta = formatTMDBMeta(tmdbmeta, seasonData);
|
||||||
if (!meta) return null;
|
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);
|
cache.set(query, results, 3600);
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user