29
server/models/Collection.ts
Normal file
29
server/models/Collection.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { TmdbCollection } from '../api/themoviedb';
|
||||
import Media from '../entity/Media';
|
||||
import { mapMovieResult, MovieResult } from './Search';
|
||||
|
||||
export interface Collection {
|
||||
id: number;
|
||||
name: string;
|
||||
overview?: string;
|
||||
posterPath?: string;
|
||||
backdropPath?: string;
|
||||
parts: MovieResult[];
|
||||
}
|
||||
|
||||
export const mapCollection = (
|
||||
collection: TmdbCollection,
|
||||
media: Media[]
|
||||
): Collection => ({
|
||||
id: collection.id,
|
||||
name: collection.name,
|
||||
overview: collection.overview,
|
||||
posterPath: collection.poster_path,
|
||||
backdropPath: collection.backdrop_path,
|
||||
parts: collection.parts.map((part) =>
|
||||
mapMovieResult(
|
||||
part,
|
||||
media?.find((req) => req.tmdbId === part.id)
|
||||
)
|
||||
),
|
||||
});
|
||||
@@ -46,6 +46,12 @@ export interface MovieDetails {
|
||||
cast: Cast[];
|
||||
crew: Crew[];
|
||||
};
|
||||
collection?: {
|
||||
id: number;
|
||||
name: string;
|
||||
posterPath?: string;
|
||||
backdropPath?: string;
|
||||
};
|
||||
mediaInfo?: Media;
|
||||
externalIds: ExternalIds;
|
||||
}
|
||||
@@ -87,6 +93,14 @@ export const mapMovieDetails = (
|
||||
cast: movie.credits.cast.map(mapCast),
|
||||
crew: movie.credits.crew.map(mapCrew),
|
||||
},
|
||||
collection: movie.belongs_to_collection
|
||||
? {
|
||||
id: movie.belongs_to_collection.id,
|
||||
name: movie.belongs_to_collection.name,
|
||||
posterPath: movie.belongs_to_collection.poster_path,
|
||||
backdropPath: movie.belongs_to_collection.backdrop_path,
|
||||
}
|
||||
: undefined,
|
||||
externalIds: mapExternalIds(movie.external_ids),
|
||||
mediaInfo: media,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user