feat(frontend/api): cast included with movie request and cast list on detail page

This commit is contained in:
sct
2020-09-17 06:35:25 +00:00
parent 6398e3645a
commit 04252f88bb
8 changed files with 235 additions and 11 deletions

View File

@@ -99,6 +99,27 @@ interface TmdbSearchTvResponse extends TmdbPaginatedResponse {
results: TmdbTvResult[];
}
export interface TmdbCreditCast {
cast_id: number;
character: string;
credit_id: string;
gender?: number;
id: number;
name: string;
order: number;
profile_path?: string;
}
export interface TmdbCreditCrew {
credit_id: string;
gender?: number;
id: number;
name: string;
profile_path?: string;
job: string;
department: string;
}
export interface TmdbMovieDetails {
id: number;
imdb_id?: string;
@@ -138,6 +159,10 @@ export interface TmdbMovieDetails {
video: boolean;
vote_average: number;
vote_count: number;
credits: {
cast: TmdbCreditCast[];
crew: TmdbCreditCrew[];
};
}
export interface TmdbTvEpisodeDetails {
@@ -258,7 +283,7 @@ class TheMovieDb {
const response = await this.axios.get<TmdbMovieDetails>(
`/movie/${movieId}`,
{
params: { language },
params: { language, append_to_response: 'credits' },
}
);

View File

@@ -1,7 +1,32 @@
import { TmdbMovieDetails } from '../api/themoviedb';
import {
TmdbMovieDetails,
TmdbCreditCast,
TmdbCreditCrew,
} from '../api/themoviedb';
import { MediaRequest } from '../entity/MediaRequest';
import { ProductionCompany, Genre } from './common';
export interface Cast {
id: number;
castId: number;
character: string;
creditId: string;
gender?: number;
name: string;
order: number;
profilePath?: string;
}
export interface Crew {
id: number;
creditId: string;
department: string;
gender?: number;
job: string;
name: string;
profilePath?: string;
}
export interface MovieDetails {
id: number;
imdbId?: string;
@@ -33,9 +58,34 @@ export interface MovieDetails {
video: boolean;
voteAverage: number;
voteCount: number;
credits: {
cast: Cast[];
crew: Crew[];
};
request?: MediaRequest;
}
const mapCast = (person: TmdbCreditCast): Cast => ({
castId: person.cast_id,
character: person.character,
creditId: person.credit_id,
id: person.id,
name: person.name,
order: person.order,
gender: person.gender,
profilePath: person.profile_path,
});
const mapCrew = (person: TmdbCreditCrew): Crew => ({
creditId: person.credit_id,
department: person.department,
id: person.id,
job: person.job,
name: person.name,
gender: person.gender,
profilePath: person.profile_path,
});
export const mapMovieDetails = (
movie: TmdbMovieDetails,
request?: MediaRequest
@@ -69,5 +119,9 @@ export const mapMovieDetails = (
posterPath: movie.poster_path,
runtime: movie.runtime,
tagline: movie.tagline,
credits: {
cast: movie.credits.cast.map(mapCast),
crew: movie.credits.crew.map(mapCrew),
},
request,
});

View File

@@ -419,6 +419,17 @@ components:
type: number
voteCount:
type: number
credits:
type: object
properties:
cast:
type: array
items:
$ref: '#/components/schemas/Cast'
crew:
type: array
items:
$ref: '#/components/schemas/Crew'
request:
$ref: '#/components/schemas/MediaRequest'
Episode:
@@ -590,6 +601,48 @@ components:
- mediaId
- mediaType
- status
Cast:
type: object
properties:
id:
type: number
example: 123
castId:
type: number
example: 1
character:
type: string
example: Some Character Name
creditId:
type: string
gender:
type: number
name:
type: string
example: Some Persons Name
order:
type: number
profilePath:
type: string
Crew:
type: object
properties:
id:
type: number
example: 123
creditId:
type: string
gender:
type: number
name:
type: string
example: Some Persons Name
job:
type: string
department:
type: string
profilePath:
type: string
securitySchemes:
cookieAuth: