Skip to content

Commit

Permalink
Adding new field to TMDB Movie API Call to get the Original Title fro…
Browse files Browse the repository at this point in the history
…m TMDB

For Movie entry display "Original Title" beside the Title when it exist and is different
Useful for non English movies with an existing title in local language
  • Loading branch information
evoblicec committed May 6, 2020
1 parent eb8b5a4 commit d9c18fd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/core/entry/cards/Movie.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const MovieCard: FC<Props> = ({ entry, className, children }) => {
runtime = 0,
genres = [],
description = '',
originalname,
quality,
rating,
votes,
Expand All @@ -57,7 +58,9 @@ const MovieCard: FC<Props> = ({ entry, className, children }) => {
>
<div css={titleArea}>
<Typography css={selectableType} variant="h5" component="h2" color="textPrimary">
{movieName} ({movieYear})
{movieName}
{originalname !== movieName && ' - '}
{originalname !== movieName && originalname} ({movieYear})
</Typography>
<LinkDropdown options={options} />
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/core/entry/fields/movies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export enum MovieFieldNames {
Url = 'url',
Runtime = 'runtime',
ID = 'movieId',
Originalname = 'originalname',
}

export const enum IMDBFields {
Expand Down Expand Up @@ -43,6 +44,7 @@ export const enum TMDBFields {
Runtime = 'tmdbRuntime',
ID = 'tmdbId',
Description = 'tmdbOverview',
Originalname = 'tmdbOriginalName',
}

// NOTE: Thes are in order of priority so if all fields are present, the first one in
Expand All @@ -59,6 +61,7 @@ export const movieFieldList = [
[MovieFieldNames.Runtime]: TMDBFields.Runtime,
[MovieFieldNames.ID]: TMDBFields.ID,
[MovieFieldNames.Description]: TMDBFields.Description,
[MovieFieldNames.Originalname]: TMDBFields.Originalname,
},
// Trakt
{
Expand Down Expand Up @@ -93,6 +96,7 @@ interface MovieGetters {
[MovieFieldNames.Url]: string;
[MovieFieldNames.Runtime]: number;
[MovieFieldNames.ID]: string | number;
[MovieFieldNames.Originalname]: string;
}

export type RawMovieFields = Fields<MovieFieldNames, typeof movieFieldList, MovieGetters> & {
Expand Down
5 changes: 4 additions & 1 deletion src/core/entry/lookup/movies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ interface TMDBMovie {
homepage: string;
imdbId: string;
name: string;
originalName: string;
year: number;
runtime: number;
overview: string;
Expand All @@ -41,13 +42,15 @@ interface TMDBMovie {

const tmdbToFields = (movie: TMDBMovie): RawMovieFields => ({
movieName: movie.name,
// movieName: movie.originalName,
movieYear: movie.year,
[TMDBFields.Originalname]: movie.originalName,
[TMDBFields.Genres]: movie.genres,
[TMDBFields.Posters]: movie.posters?.map(({ urls }) => urls.original),
[TMDBFields.Backdrops]: movie.backdrops?.map(({ urls }) => urls.original),
[TMDBFields.Rating]: movie.rating,
[TMDBFields.Votes]: movie.votes,
[TMDBFields.Url]: movie.homepage,
[TMDBFields.Url]: movie.imdbId,
[TMDBFields.Runtime]: movie.runtime,
[TMDBFields.ID]: movie.id,
[TMDBFields.Description]: movie.overview,
Expand Down

0 comments on commit d9c18fd

Please sign in to comment.