feat(api): add external ids to movie/tv response

pull/100/head
sct 4 years ago
parent 02cbb5b030
commit 4aa74319e0

@ -121,6 +121,17 @@ export interface TmdbCreditCrew {
department: string;
}
export interface TmdbExternalIds {
imdb_id?: string;
freebase_mid?: string;
freebase_id?: string;
tvdb_id?: number;
tvrage_id?: string;
facebook_id?: string;
instagram_id?: string;
twitter_id?: string;
}
export interface TmdbMovieDetails {
id: number;
imdb_id?: string;
@ -164,6 +175,7 @@ export interface TmdbMovieDetails {
cast: TmdbCreditCast[];
crew: TmdbCreditCrew[];
};
external_ids: TmdbExternalIds;
}
export interface TmdbTvEpisodeDetails {
@ -242,6 +254,7 @@ export interface TmdbTvDetails {
cast: TmdbCreditCast[];
crew: TmdbCreditCrew[];
};
external_ids: TmdbExternalIds;
}
class TheMovieDb {
@ -289,7 +302,7 @@ class TheMovieDb {
const response = await this.axios.get<TmdbMovieDetails>(
`/movie/${movieId}`,
{
params: { language, append_to_response: 'credits' },
params: { language, append_to_response: 'credits,external_ids' },
}
);
@ -308,7 +321,7 @@ class TheMovieDb {
}): Promise<TmdbTvDetails> => {
try {
const response = await this.axios.get<TmdbTvDetails>(`/tv/${tvId}`, {
params: { language, append_to_response: 'credits' },
params: { language, append_to_response: 'credits,external_ids' },
});
return response.data;

@ -73,6 +73,13 @@ export class MediaRequest {
@Index()
public mediaId: number;
@Column({ unique: true, nullable: true })
@Index()
public tvdbId: number;
@Column({ nullable: true })
public seasons?: string;
@Column()
public mediaType: 'movie' | 'tv';

@ -7,6 +7,8 @@ import {
Crew,
mapCast,
mapCrew,
ExternalIds,
mapExternalIds,
} from './common';
export interface MovieDetails {
@ -45,6 +47,7 @@ export interface MovieDetails {
crew: Crew[];
};
request?: MediaRequest;
externalIds: ExternalIds;
}
export const mapMovieDetails = (
@ -84,5 +87,6 @@ export const mapMovieDetails = (
cast: movie.credits.cast.map(mapCast),
crew: movie.credits.crew.map(mapCrew),
},
externalIds: mapExternalIds(movie.external_ids),
request,
});

@ -5,6 +5,8 @@ import {
Crew,
mapCast,
mapCrew,
ExternalIds,
mapExternalIds,
} from './common';
import { MediaRequest } from '../entity/MediaRequest';
import {
@ -75,6 +77,7 @@ export interface TvDetails {
cast: Cast[];
crew: Crew[];
};
externalIds: ExternalIds;
request?: MediaRequest;
}
@ -155,5 +158,6 @@ export const mapTvDetails = (
cast: show.credits.cast.map(mapCast),
crew: show.credits.crew.map(mapCrew),
},
externalIds: mapExternalIds(show.external_ids),
request,
});

@ -1,4 +1,8 @@
import { TmdbCreditCast, TmdbCreditCrew } from '../api/themoviedb';
import {
TmdbCreditCast,
TmdbCreditCrew,
TmdbExternalIds,
} from '../api/themoviedb';
export interface ProductionCompany {
id: number;
@ -33,6 +37,17 @@ export interface Crew {
profilePath?: string;
}
export interface ExternalIds {
imdbId?: string;
freebaseMid?: string;
freebaseId?: string;
tvdbId?: number;
tvrageId?: string;
facebookId?: string;
instagramId?: string;
twitterId?: string;
}
export const mapCast = (person: TmdbCreditCast): Cast => ({
castId: person.cast_id,
character: person.character,
@ -53,3 +68,14 @@ export const mapCrew = (person: TmdbCreditCrew): Crew => ({
gender: person.gender,
profilePath: person.profile_path,
});
export const mapExternalIds = (eids: TmdbExternalIds): ExternalIds => ({
facebookId: eids.facebook_id,
freebaseId: eids.freebase_id,
freebaseMid: eids.freebase_mid,
imdbId: eids.imdb_id,
instagramId: eids.instagram_id,
tvdbId: eids.tvdb_id,
tvrageId: eids.tvrage_id,
twitterId: eids.twitter_id,
});

@ -433,6 +433,8 @@ components:
type: array
items:
$ref: '#/components/schemas/Crew'
externalIds:
$ref: '#/components/schemas/ExternalIds'
request:
$ref: '#/components/schemas/MediaRequest'
Episode:
@ -573,6 +575,8 @@ components:
type: array
items:
$ref: '#/components/schemas/Crew'
externalIds:
$ref: '#/components/schemas/ExternalIds'
request:
$ref: '#/components/schemas/MediaRequest'
MediaRequest:
@ -657,6 +661,25 @@ components:
type: string
profilePath:
type: string
ExternalIds:
type: object
properties:
facebookId:
type: string
freebaseId:
type: string
freebaseMid:
type: string
imdbId:
type: string
instagramId:
type: string
tvdbId:
type: string
tvrageId:
type: string
twitterId:
type: string
securitySchemes:
cookieAuth:
@ -1219,6 +1242,16 @@ paths:
mediaId:
type: number
example: 123
tvdbId:
type: number
example: 123
seasons:
type: array
items:
type: number
required:
- mediaType
- mediaId
responses:
'201':
description: Succesfully created the request

Loading…
Cancel
Save