feat(search): search by id (#2082)

* feat(search): search by id

This adds the ability to search by ID (starting with TMDb ID).

Since there doesn't seem to be way of searching across movies, tv and persons,
I have to search through all 3 and use the first one in the order: movie -> tv -> person

Searching by ID is triggered using a 'prefix' just like in the *arrs.

* fix: missed some refactoring

* feat(search): use locale language

* feat(search): search using imdb id

* feat(search): search using tvdb id

* fix: alias type import

* fix: missed some refactoring

* fix(search): account for id being a string

* feat(search): account for movies/tvs/persons with the same id

* feat(search): remove non-null assertion

Co-authored-by: Ryan Cohen <ryan@sct.dev>
This commit is contained in:
Danshil Kokil Mungur
2022-01-14 11:52:10 +04:00
committed by GitHub
parent e0b6abe479
commit b31cdbf074
9 changed files with 275 additions and 20 deletions

View File

@@ -10,7 +10,7 @@ import {
TmdbMovieDetails,
TmdbNetwork,
TmdbPersonCombinedCredits,
TmdbPersonDetail,
TmdbPersonDetails,
TmdbProductionCompany,
TmdbRegion,
TmdbSearchMovieResponse,
@@ -122,9 +122,9 @@ class TheMovieDb extends ExternalAPI {
}: {
personId: number;
language?: string;
}): Promise<TmdbPersonDetail> => {
}): Promise<TmdbPersonDetails> => {
try {
const data = await this.get<TmdbPersonDetail>(`/person/${personId}`, {
const data = await this.get<TmdbPersonDetails>(`/person/${personId}`, {
params: { language },
});

View File

@@ -67,6 +67,7 @@ export interface TmdbUpcomingMoviesResponse extends TmdbPaginatedResponse {
export interface TmdbExternalIdResponse {
movie_results: TmdbMovieResult[];
tv_results: TmdbTvResult[];
person_results: TmdbPersonResult[];
}
export interface TmdbCreditCast {
@@ -315,7 +316,7 @@ export interface TmdbKeyword {
name: string;
}
export interface TmdbPersonDetail {
export interface TmdbPersonDetails {
id: number;
name: string;
birthday: string;
@@ -324,7 +325,7 @@ export interface TmdbPersonDetail {
also_known_as?: string[];
gender: number;
biography: string;
popularity: string;
popularity: number;
place_of_birth?: string;
profile_path?: string;
adult: boolean;