feat: YouTube Movie/TV Trailers (#454)

* feat: Get Youtube trailers from TMDB API and show on Movie/TV details page

* docs(overseerr-api.yml): remove youtube trailer URL (unused) from OAS
This commit is contained in:
Jayesh
2020-12-24 22:41:32 +11:00
committed by GitHub
parent 329a814a8f
commit e88dc83aeb
9 changed files with 143 additions and 6 deletions

View File

@@ -2,8 +2,12 @@ import {
TmdbCreditCast,
TmdbCreditCrew,
TmdbExternalIds,
TmdbVideo,
TmdbVideoResult,
} from '../api/themoviedb';
import { Video } from '../models/Movie';
export interface ProductionCompany {
id: number;
logoPath?: string;
@@ -84,3 +88,18 @@ export const mapExternalIds = (eids: TmdbExternalIds): ExternalIds => ({
tvrageId: eids.tvrage_id,
twitterId: eids.twitter_id,
});
export const mapVideos = (videoResult: TmdbVideoResult): Video[] =>
videoResult?.results.map(({ key, name, size, type, site }: TmdbVideo) => ({
site,
key,
name,
size,
type,
url: siteUrlCreator(site, key),
}));
const siteUrlCreator = (site: Video['site'], key: string): string =>
({
YouTube: `https://www.youtube.com/watch?v=${key}/`,
}[site]);