Compare commits
9 Commits
blakejoy-p
...
chore/add-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1146ca8ad2 | ||
|
|
6a68e9973b | ||
|
|
ad2b27ca72 | ||
|
|
76f62210be | ||
|
|
101457cdd7 | ||
|
|
7d4b3fcb60 | ||
|
|
eb53747570 | ||
|
|
8c615edbfa | ||
|
|
1628ea05bd |
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "tmdb-ts",
|
"name": "tmdb-ts",
|
||||||
"version": "1.5.0",
|
"version": "1.6.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "tmdb-ts",
|
"name": "tmdb-ts",
|
||||||
"version": "1.5.0",
|
"version": "1.6.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cross-fetch": "^3.1.4"
|
"cross-fetch": "^3.1.4"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tmdb-ts",
|
"name": "tmdb-ts",
|
||||||
"version": "1.5.1",
|
"version": "1.6.1",
|
||||||
"description": "TMDB v3 library wrapper",
|
"description": "TMDB v3 library wrapper",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import fetch from 'cross-fetch';
|
import fetch from 'cross-fetch';
|
||||||
import { parseOptions } from './utils';
|
import { parseOptions } from './utils';
|
||||||
|
import { ErrorResponse } from './types';
|
||||||
|
|
||||||
const BASE_URL_V3 = 'https://api.themoviedb.org/3';
|
const BASE_URL_V3 = 'https://api.themoviedb.org/3';
|
||||||
|
|
||||||
@@ -17,6 +18,11 @@ export class Api {
|
|||||||
'Content-Type': 'application/json;charset=utf-8',
|
'Content-Type': 'application/json;charset=utf-8',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
return Promise.reject((await response.json()) as ErrorResponse);
|
||||||
|
}
|
||||||
|
|
||||||
return (await response.json()) as T;
|
return (await response.json()) as T;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
CollectionImageOptions,
|
||||||
DetailedCollection,
|
DetailedCollection,
|
||||||
ImageCollection,
|
ImageCollection,
|
||||||
LanguageOption,
|
LanguageOption,
|
||||||
@@ -23,10 +24,17 @@ export class CollectionsEndpoint extends BaseEndpoint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async images(id: number, options?: LanguageOption): Promise<ImageCollection> {
|
async images(
|
||||||
|
id: number,
|
||||||
|
options?: CollectionImageOptions
|
||||||
|
): Promise<ImageCollection> {
|
||||||
|
const computedOptions = {
|
||||||
|
include_image_language: options?.include_image_language?.join(','),
|
||||||
|
language: options?.language,
|
||||||
|
};
|
||||||
return await this.api.get<ImageCollection>(
|
return await this.api.get<ImageCollection>(
|
||||||
`${BASE_COLLECTION}/${id}/images`,
|
`${BASE_COLLECTION}/${id}/images`,
|
||||||
options
|
computedOptions
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { LanguageOption } from '../types';
|
||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
|
|
||||||
export interface Genres {
|
export interface Genres {
|
||||||
@@ -9,11 +10,11 @@ export class GenreEndpoint extends BaseEndpoint {
|
|||||||
super(accessToken);
|
super(accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
async movies(): Promise<Genres> {
|
async movies(options?: LanguageOption): Promise<Genres> {
|
||||||
return await this.api.get<Genres>('/genre/movie/list');
|
return await this.api.get<Genres>('/genre/movie/list', options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async tvShows(): Promise<Genres> {
|
async tvShows(options?: LanguageOption): Promise<Genres> {
|
||||||
return await this.api.get<Genres>('/genre/tv/list');
|
return await this.api.get<Genres>('/genre/tv/list', options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,13 @@ import {
|
|||||||
|
|
||||||
const BASE_MOVIE = '/movie';
|
const BASE_MOVIE = '/movie';
|
||||||
|
|
||||||
|
export interface MoviesImageSearchOptions extends LanguageOption {
|
||||||
|
/**
|
||||||
|
* a list of ISO-639-1 values to query
|
||||||
|
*/
|
||||||
|
include_image_language?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
export class MoviesEndpoint extends BaseEndpoint {
|
export class MoviesEndpoint extends BaseEndpoint {
|
||||||
constructor(protected readonly accessToken: string) {
|
constructor(protected readonly accessToken: string) {
|
||||||
super(accessToken);
|
super(accessToken);
|
||||||
@@ -38,12 +45,14 @@ export class MoviesEndpoint extends BaseEndpoint {
|
|||||||
|
|
||||||
async details<T extends AppendToResponseMovieKey[] | undefined>(
|
async details<T extends AppendToResponseMovieKey[] | undefined>(
|
||||||
id: number,
|
id: number,
|
||||||
appendToResponse?: T
|
appendToResponse?: T,
|
||||||
|
language?: string
|
||||||
) {
|
) {
|
||||||
const options = {
|
const options = {
|
||||||
append_to_response: appendToResponse
|
append_to_response: appendToResponse
|
||||||
? appendToResponse.join(',')
|
? appendToResponse.join(',')
|
||||||
: undefined,
|
: undefined,
|
||||||
|
language: language,
|
||||||
};
|
};
|
||||||
|
|
||||||
return await this.api.get<AppendToResponse<MovieDetails, T, 'movie'>>(
|
return await this.api.get<AppendToResponse<MovieDetails, T, 'movie'>>(
|
||||||
@@ -68,16 +77,26 @@ export class MoviesEndpoint extends BaseEndpoint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async credits(id: number): Promise<Credits> {
|
async credits(id: number, options?: LanguageOption): Promise<Credits> {
|
||||||
return await this.api.get<Credits>(`${BASE_MOVIE}/${id}/credits`);
|
return await this.api.get<Credits>(`${BASE_MOVIE}/${id}/credits`, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async externalIds(id: number): Promise<ExternalIds> {
|
async externalIds(id: number): Promise<ExternalIds> {
|
||||||
return await this.api.get<ExternalIds>(`${BASE_MOVIE}/${id}/external_ids`);
|
return await this.api.get<ExternalIds>(`${BASE_MOVIE}/${id}/external_ids`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async images(id: number): Promise<Images> {
|
async images(
|
||||||
return await this.api.get<Images>(`${BASE_MOVIE}/${id}/images`);
|
id: number,
|
||||||
|
options?: MoviesImageSearchOptions
|
||||||
|
): Promise<Images> {
|
||||||
|
const computedOptions = {
|
||||||
|
include_image_language: options?.include_image_language?.join(','),
|
||||||
|
language: options?.language,
|
||||||
|
};
|
||||||
|
return await this.api.get<Images>(
|
||||||
|
`${BASE_MOVIE}/${id}/images`,
|
||||||
|
computedOptions
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async keywords(id: number): Promise<Keywords> {
|
async keywords(id: number): Promise<Keywords> {
|
||||||
@@ -86,14 +105,14 @@ export class MoviesEndpoint extends BaseEndpoint {
|
|||||||
|
|
||||||
async lists(
|
async lists(
|
||||||
id: number,
|
id: number,
|
||||||
options?: LanguageOption | PageOption
|
options?: LanguageOption & PageOption
|
||||||
): Promise<MovieLists> {
|
): Promise<MovieLists> {
|
||||||
return await this.api.get<MovieLists>(`${BASE_MOVIE}/${id}/lists`, options);
|
return await this.api.get<MovieLists>(`${BASE_MOVIE}/${id}/lists`, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async recommendations(
|
async recommendations(
|
||||||
id: number,
|
id: number,
|
||||||
options?: PageOption
|
options?: LanguageOption & PageOption
|
||||||
): Promise<Recommendations> {
|
): Promise<Recommendations> {
|
||||||
return await this.api.get<Recommendations>(
|
return await this.api.get<Recommendations>(
|
||||||
`${BASE_MOVIE}/${id}/recommendations`,
|
`${BASE_MOVIE}/${id}/recommendations`,
|
||||||
@@ -107,11 +126,17 @@ export class MoviesEndpoint extends BaseEndpoint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async reviews(id: number, options?: PageOption): Promise<Reviews> {
|
async reviews(
|
||||||
|
id: number,
|
||||||
|
options?: LanguageOption & PageOption
|
||||||
|
): Promise<Reviews> {
|
||||||
return await this.api.get<Reviews>(`${BASE_MOVIE}/${id}/reviews`, options);
|
return await this.api.get<Reviews>(`${BASE_MOVIE}/${id}/reviews`, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async similar(id: number, options?: PageOption): Promise<SimilarMovies> {
|
async similar(
|
||||||
|
id: number,
|
||||||
|
options?: LanguageOption & PageOption
|
||||||
|
): Promise<SimilarMovies> {
|
||||||
return await this.api.get<SimilarMovies>(
|
return await this.api.get<SimilarMovies>(
|
||||||
`${BASE_MOVIE}/${id}/similar`,
|
`${BASE_MOVIE}/${id}/similar`,
|
||||||
options
|
options
|
||||||
@@ -122,8 +147,8 @@ export class MoviesEndpoint extends BaseEndpoint {
|
|||||||
return await this.api.get<Translations>(`${BASE_MOVIE}/${id}/translations`);
|
return await this.api.get<Translations>(`${BASE_MOVIE}/${id}/translations`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async videos(id: number): Promise<Videos> {
|
async videos(id: number, options?: LanguageOption): Promise<Videos> {
|
||||||
return await this.api.get<Videos>(`${BASE_MOVIE}/${id}/videos`);
|
return await this.api.get<Videos>(`${BASE_MOVIE}/${id}/videos`, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -149,7 +174,7 @@ export class MoviesEndpoint extends BaseEndpoint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async popular(options?: PageOption): Promise<PopularMovies> {
|
async popular(options?: LanguageOption & PageOption): Promise<PopularMovies> {
|
||||||
return await this.api.get<PopularMovies>(`${BASE_MOVIE}/popular`, options);
|
return await this.api.get<PopularMovies>(`${BASE_MOVIE}/popular`, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
TaggedImages,
|
TaggedImages,
|
||||||
Changes,
|
Changes,
|
||||||
PersonChangeValue,
|
PersonChangeValue,
|
||||||
|
LanguageOption,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
|
|
||||||
@@ -26,12 +27,14 @@ export class PeopleEndpoint extends BaseEndpoint {
|
|||||||
|
|
||||||
async details<T extends AppendToResponsePersonKey[] | undefined>(
|
async details<T extends AppendToResponsePersonKey[] | undefined>(
|
||||||
id: number,
|
id: number,
|
||||||
appendToResponse?: T
|
appendToResponse?: T,
|
||||||
|
language?: string
|
||||||
) {
|
) {
|
||||||
const options = {
|
const options = {
|
||||||
append_to_response: appendToResponse
|
append_to_response: appendToResponse
|
||||||
? appendToResponse.join(',')
|
? appendToResponse.join(',')
|
||||||
: undefined,
|
: undefined,
|
||||||
|
language: language,
|
||||||
};
|
};
|
||||||
return await this.api.get<AppendToResponse<PersonDetails, T, 'person'>>(
|
return await this.api.get<AppendToResponse<PersonDetails, T, 'person'>>(
|
||||||
`${BASE_PERSON}/${id}`,
|
`${BASE_PERSON}/${id}`,
|
||||||
@@ -49,21 +52,33 @@ export class PeopleEndpoint extends BaseEndpoint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async movieCredits(id: number): Promise<PersonMovieCredit> {
|
async movieCredits(
|
||||||
|
id: number,
|
||||||
|
options?: LanguageOption
|
||||||
|
): Promise<PersonMovieCredit> {
|
||||||
return await this.api.get<PersonMovieCredit>(
|
return await this.api.get<PersonMovieCredit>(
|
||||||
`${BASE_PERSON}/${id}/movie_credits`
|
`${BASE_PERSON}/${id}/movie_credits`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async tvShowCredits(id: number): Promise<PersonTvShowCredit> {
|
async tvShowCredits(
|
||||||
|
id: number,
|
||||||
|
options?: LanguageOption
|
||||||
|
): Promise<PersonTvShowCredit> {
|
||||||
return await this.api.get<PersonTvShowCredit>(
|
return await this.api.get<PersonTvShowCredit>(
|
||||||
`${BASE_PERSON}/${id}/tv_credits`
|
`${BASE_PERSON}/${id}/tv_credits`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async combinedCredits(id: number): Promise<PersonCombinedCredits> {
|
async combinedCredits(
|
||||||
|
id: number,
|
||||||
|
options?: LanguageOption
|
||||||
|
): Promise<PersonCombinedCredits> {
|
||||||
return await this.api.get<PersonCombinedCredits>(
|
return await this.api.get<PersonCombinedCredits>(
|
||||||
`${BASE_PERSON}/${id}/combined_credits`
|
`${BASE_PERSON}/${id}/combined_credits`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +107,9 @@ export class PeopleEndpoint extends BaseEndpoint {
|
|||||||
return await this.api.get<PersonDetails>(`${BASE_PERSON}/latest`);
|
return await this.api.get<PersonDetails>(`${BASE_PERSON}/latest`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async popular(options?: PageOption): Promise<PopularPersons> {
|
async popular(
|
||||||
|
options?: LanguageOption & PageOption
|
||||||
|
): Promise<PopularPersons> {
|
||||||
return await this.api.get<PopularPersons>(
|
return await this.api.get<PopularPersons>(
|
||||||
`${BASE_PERSON}/popular`,
|
`${BASE_PERSON}/popular`,
|
||||||
options
|
options
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
import { MultiSearchResult, Search } from '../types/search';
|
import { MultiSearchResult, Search } from '../types/search';
|
||||||
import { Collection, Company, Movie, Person, TV } from '../types';
|
import {
|
||||||
|
Collection,
|
||||||
|
Company,
|
||||||
|
LanguageOption,
|
||||||
|
Movie,
|
||||||
|
PageOption,
|
||||||
|
Person,
|
||||||
|
RegionOption,
|
||||||
|
TV,
|
||||||
|
} from '../types';
|
||||||
|
|
||||||
const BASE_SEARCH = '/search';
|
const BASE_SEARCH = '/search';
|
||||||
|
|
||||||
@@ -9,22 +18,44 @@ export interface SearchOptions {
|
|||||||
page?: number;
|
page?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MovieSearchOptions extends SearchOptions {
|
export interface MovieSearchOptions
|
||||||
|
extends SearchOptions,
|
||||||
|
LanguageOption,
|
||||||
|
PageOption,
|
||||||
|
RegionOption {
|
||||||
include_adult?: boolean;
|
include_adult?: boolean;
|
||||||
year?: number;
|
year?: number;
|
||||||
primary_release_year?: number;
|
primary_release_year?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TvSearchOptions extends SearchOptions {
|
export interface CollectionSearchOptions
|
||||||
|
extends SearchOptions,
|
||||||
|
LanguageOption,
|
||||||
|
PageOption,
|
||||||
|
RegionOption {
|
||||||
include_adult?: boolean;
|
include_adult?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TvSearchOptions
|
||||||
|
extends SearchOptions,
|
||||||
|
LanguageOption,
|
||||||
|
PageOption {
|
||||||
|
include_adult?: boolean;
|
||||||
|
year?: number;
|
||||||
first_air_date_year?: number;
|
first_air_date_year?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PeopleSearchOptions extends SearchOptions {
|
export interface PeopleSearchOptions
|
||||||
|
extends SearchOptions,
|
||||||
|
LanguageOption,
|
||||||
|
PageOption {
|
||||||
include_adult?: boolean;
|
include_adult?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MultiSearchOptions extends SearchOptions {
|
export interface MultiSearchOptions
|
||||||
|
extends SearchOptions,
|
||||||
|
LanguageOption,
|
||||||
|
PageOption {
|
||||||
include_adult?: boolean;
|
include_adult?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
import { TrendingMediaType, TimeWindow, TrendingResults } from '../types';
|
import {
|
||||||
|
TrendingMediaType,
|
||||||
|
TimeWindow,
|
||||||
|
TrendingResults,
|
||||||
|
LanguageOption,
|
||||||
|
} from '../types';
|
||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
|
|
||||||
export class TrendingEndpoint extends BaseEndpoint {
|
export class TrendingEndpoint extends BaseEndpoint {
|
||||||
@@ -8,10 +13,12 @@ export class TrendingEndpoint extends BaseEndpoint {
|
|||||||
|
|
||||||
async trending<T extends TrendingMediaType>(
|
async trending<T extends TrendingMediaType>(
|
||||||
mediaType: T,
|
mediaType: T,
|
||||||
timeWindow: TimeWindow
|
timeWindow: TimeWindow,
|
||||||
|
options?: LanguageOption
|
||||||
): Promise<TrendingResults<T>> {
|
): Promise<TrendingResults<T>> {
|
||||||
return await this.api.get<TrendingResults<T>>(
|
return await this.api.get<TrendingResults<T>>(
|
||||||
`/trending/${mediaType}/${timeWindow}`
|
`/trending/${mediaType}/${timeWindow}`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import {
|
|||||||
Images,
|
Images,
|
||||||
TvEpisodeTranslations,
|
TvEpisodeTranslations,
|
||||||
Videos,
|
Videos,
|
||||||
AppendToResponseMovieKey,
|
|
||||||
AppendToResponse,
|
AppendToResponse,
|
||||||
Changes,
|
Changes,
|
||||||
TvEpisodeChangeValue,
|
TvEpisodeChangeValue,
|
||||||
@@ -20,6 +19,20 @@ const BASE_EPISODE = (episodeSelection: EpisodeSelection): string => {
|
|||||||
return `/tv/${episodeSelection.tvShowID}/season/${episodeSelection.seasonNumber}/episode/${episodeSelection.episodeNumber}`;
|
return `/tv/${episodeSelection.tvShowID}/season/${episodeSelection.seasonNumber}/episode/${episodeSelection.episodeNumber}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface TvEpisodeImageSearchOptions extends LanguageOption {
|
||||||
|
/**
|
||||||
|
* a list of ISO-639-1 values to query
|
||||||
|
*/
|
||||||
|
include_image_language?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TvEpisodeVideoSearchOptions extends LanguageOption {
|
||||||
|
/**
|
||||||
|
* a list of ISO-639-1 values to query
|
||||||
|
*/
|
||||||
|
include_video_language?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
export class TvEpisodesEndpoint extends BaseEndpoint {
|
export class TvEpisodesEndpoint extends BaseEndpoint {
|
||||||
constructor(accessToken: string) {
|
constructor(accessToken: string) {
|
||||||
super(accessToken);
|
super(accessToken);
|
||||||
@@ -62,9 +75,17 @@ export class TvEpisodesEndpoint extends BaseEndpoint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async images(episodeSelection: EpisodeSelection) {
|
async images(
|
||||||
|
episodeSelection: EpisodeSelection,
|
||||||
|
options?: TvEpisodeImageSearchOptions
|
||||||
|
) {
|
||||||
|
const computedOptions = {
|
||||||
|
include_image_language: options?.include_image_language?.join(','),
|
||||||
|
language: options?.language,
|
||||||
|
};
|
||||||
return await this.api.get<Images>(
|
return await this.api.get<Images>(
|
||||||
`${BASE_EPISODE(episodeSelection)}/images`
|
`${BASE_EPISODE(episodeSelection)}/images`,
|
||||||
|
computedOptions
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,10 +95,17 @@ export class TvEpisodesEndpoint extends BaseEndpoint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async videos(episodeSelection: EpisodeSelection, options?: LanguageOption) {
|
async videos(
|
||||||
|
episodeSelection: EpisodeSelection,
|
||||||
|
options?: TvEpisodeVideoSearchOptions
|
||||||
|
) {
|
||||||
|
const computedOptions = {
|
||||||
|
include_video_language: options?.include_video_language?.join(','),
|
||||||
|
language: options?.language,
|
||||||
|
};
|
||||||
return await this.api.get<Videos>(
|
return await this.api.get<Videos>(
|
||||||
`${BASE_EPISODE(episodeSelection)}/videos`,
|
`${BASE_EPISODE(episodeSelection)}/videos`,
|
||||||
options
|
computedOptions
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,20 @@ const BASE_SEASON = (seasonSelection: SeasonSelection): string => {
|
|||||||
return `/tv/${seasonSelection.tvShowID}/season/${seasonSelection.seasonNumber}`;
|
return `/tv/${seasonSelection.tvShowID}/season/${seasonSelection.seasonNumber}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface TvSeasonImageSearchOptions extends LanguageOption {
|
||||||
|
/**
|
||||||
|
* a list of ISO-639-1 values to query
|
||||||
|
*/
|
||||||
|
include_image_language?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TvSeasonVideoSearchOptions extends LanguageOption {
|
||||||
|
/**
|
||||||
|
* a list of ISO-639-1 values to query
|
||||||
|
*/
|
||||||
|
include_video_language?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
export class TvSeasonsEndpoint extends BaseEndpoint {
|
export class TvSeasonsEndpoint extends BaseEndpoint {
|
||||||
constructor(accessToken: string) {
|
constructor(accessToken: string) {
|
||||||
super(accessToken);
|
super(accessToken);
|
||||||
@@ -77,17 +91,31 @@ export class TvSeasonsEndpoint extends BaseEndpoint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async images(seasonSelection: SeasonSelection, options?: LanguageOption) {
|
async images(
|
||||||
|
seasonSelection: SeasonSelection,
|
||||||
|
options?: TvSeasonImageSearchOptions
|
||||||
|
) {
|
||||||
|
const computedOptions = {
|
||||||
|
include_image_language: options?.include_image_language?.join(','),
|
||||||
|
language: options?.language,
|
||||||
|
};
|
||||||
return await this.api.get<Images>(
|
return await this.api.get<Images>(
|
||||||
`${BASE_SEASON(seasonSelection)}/images`,
|
`${BASE_SEASON(seasonSelection)}/images`,
|
||||||
options
|
computedOptions
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async videos(seasonSelection: SeasonSelection, options?: LanguageOption) {
|
async videos(
|
||||||
|
seasonSelection: SeasonSelection,
|
||||||
|
options?: TvSeasonVideoSearchOptions
|
||||||
|
) {
|
||||||
|
const computedOptions = {
|
||||||
|
include_video_language: options?.include_video_language?.join(','),
|
||||||
|
language: options?.language,
|
||||||
|
};
|
||||||
return await this.api.get<Videos>(
|
return await this.api.get<Videos>(
|
||||||
`${BASE_SEASON(seasonSelection)}/videos`,
|
`${BASE_SEASON(seasonSelection)}/videos`,
|
||||||
options
|
computedOptions
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,13 +18,15 @@ import {
|
|||||||
PageOption,
|
PageOption,
|
||||||
PopularTvShows,
|
PopularTvShows,
|
||||||
Recommendations,
|
Recommendations,
|
||||||
RegionOption,
|
|
||||||
Reviews,
|
Reviews,
|
||||||
ScreenedTheatrically,
|
ScreenedTheatrically,
|
||||||
SeasonDetails,
|
SeasonDetails,
|
||||||
SimilarTvShows,
|
SimilarTvShows,
|
||||||
|
TimezoneOption,
|
||||||
TopRatedTvShows,
|
TopRatedTvShows,
|
||||||
Translations,
|
Translations,
|
||||||
|
TvShowImageOptions,
|
||||||
|
TvShowVideoOptions,
|
||||||
TvShowChangeValue,
|
TvShowChangeValue,
|
||||||
TvShowDetails,
|
TvShowDetails,
|
||||||
TvShowsAiringToday,
|
TvShowsAiringToday,
|
||||||
@@ -41,12 +43,14 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
|||||||
|
|
||||||
async details<T extends AppendToResponseTvKey[] | undefined>(
|
async details<T extends AppendToResponseTvKey[] | undefined>(
|
||||||
id: number,
|
id: number,
|
||||||
appendToResponse?: T
|
appendToResponse?: T,
|
||||||
|
language?: string
|
||||||
) {
|
) {
|
||||||
const options = {
|
const options = {
|
||||||
append_to_response: appendToResponse
|
append_to_response: appendToResponse
|
||||||
? appendToResponse.join(',')
|
? appendToResponse.join(',')
|
||||||
: undefined,
|
: undefined,
|
||||||
|
language: language,
|
||||||
};
|
};
|
||||||
return await this.api.get<AppendToResponse<TvShowDetails, T, 'tvShow'>>(
|
return await this.api.get<AppendToResponse<TvShowDetails, T, 'tvShow'>>(
|
||||||
`${BASE_TV}/${id}`,
|
`${BASE_TV}/${id}`,
|
||||||
@@ -76,14 +80,18 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async aggregateCredits(id: number): Promise<AggregateCredits> {
|
async aggregateCredits(
|
||||||
|
id: number,
|
||||||
|
options?: LanguageOption
|
||||||
|
): Promise<AggregateCredits> {
|
||||||
return await this.api.get<AggregateCredits>(
|
return await this.api.get<AggregateCredits>(
|
||||||
`${BASE_TV}/${id}/aggregate_credits`
|
`${BASE_TV}/${id}/aggregate_credits`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async credits(id: number): Promise<Credits> {
|
async credits(id: number, options?: LanguageOption): Promise<Credits> {
|
||||||
return await this.api.get<Credits>(`${BASE_TV}/${id}/credits`);
|
return await this.api.get<Credits>(`${BASE_TV}/${id}/credits`, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async season(tvId: number, seasonNumber: number): Promise<SeasonDetails> {
|
async season(tvId: number, seasonNumber: number): Promise<SeasonDetails> {
|
||||||
@@ -100,8 +108,15 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
|||||||
return await this.api.get<ExternalIds>(`${BASE_TV}/${id}/external_ids`);
|
return await this.api.get<ExternalIds>(`${BASE_TV}/${id}/external_ids`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async images(id: number): Promise<Images> {
|
async images(id: number, options?: TvShowImageOptions): Promise<Images> {
|
||||||
return await this.api.get<Images>(`${BASE_TV}/${id}/images`);
|
const computedOptions = {
|
||||||
|
include_image_language: options?.include_image_language?.join(','),
|
||||||
|
language: options?.language,
|
||||||
|
};
|
||||||
|
return await this.api.get<Images>(
|
||||||
|
`${BASE_TV}/${id}/images`,
|
||||||
|
computedOptions
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async keywords(id: number): Promise<Keywords> {
|
async keywords(id: number): Promise<Keywords> {
|
||||||
@@ -110,7 +125,7 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
|||||||
|
|
||||||
async recommendations(
|
async recommendations(
|
||||||
id: number,
|
id: number,
|
||||||
options?: PageOption
|
options?: LanguageOption & PageOption
|
||||||
): Promise<Recommendations> {
|
): Promise<Recommendations> {
|
||||||
return await this.api.get<Recommendations>(
|
return await this.api.get<Recommendations>(
|
||||||
`${BASE_TV}/${id}/recommendations`,
|
`${BASE_TV}/${id}/recommendations`,
|
||||||
@@ -118,7 +133,10 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async reviews(id: number, options?: PageOption): Promise<Reviews> {
|
async reviews(
|
||||||
|
id: number,
|
||||||
|
options?: LanguageOption & PageOption
|
||||||
|
): Promise<Reviews> {
|
||||||
return await this.api.get<Reviews>(`${BASE_TV}/${id}/reviews`, options);
|
return await this.api.get<Reviews>(`${BASE_TV}/${id}/reviews`, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +146,10 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async similar(id: number, options?: PageOption): Promise<SimilarTvShows> {
|
async similar(
|
||||||
|
id: number,
|
||||||
|
options?: LanguageOption & PageOption
|
||||||
|
): Promise<SimilarTvShows> {
|
||||||
return await this.api.get<SimilarTvShows>(
|
return await this.api.get<SimilarTvShows>(
|
||||||
`${BASE_TV}/${id}/similar`,
|
`${BASE_TV}/${id}/similar`,
|
||||||
options
|
options
|
||||||
@@ -139,8 +160,15 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
|||||||
return await this.api.get<Translations>(`${BASE_TV}/${id}/translations`);
|
return await this.api.get<Translations>(`${BASE_TV}/${id}/translations`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async videos(id: number): Promise<Videos> {
|
async videos(id: number, options?: TvShowVideoOptions): Promise<Videos> {
|
||||||
return await this.api.get<Videos>(`${BASE_TV}/${id}/videos`);
|
const computedOptions = {
|
||||||
|
include_video_language: options?.include_video_language?.join(','),
|
||||||
|
language: options?.language,
|
||||||
|
};
|
||||||
|
return await this.api.get<Videos>(
|
||||||
|
`${BASE_TV}/${id}/videos`,
|
||||||
|
computedOptions
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -157,12 +185,14 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
|||||||
return await this.api.get<LatestTvShows>(`${BASE_TV}/latest`);
|
return await this.api.get<LatestTvShows>(`${BASE_TV}/latest`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onTheAir(): Promise<OnTheAir> {
|
async onTheAir(
|
||||||
return await this.api.get<OnTheAir>(`${BASE_TV}/on_the_air`);
|
options?: PageOption & LanguageOption & TimezoneOption
|
||||||
|
): Promise<OnTheAir> {
|
||||||
|
return await this.api.get<OnTheAir>(`${BASE_TV}/on_the_air`, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async airingToday(
|
async airingToday(
|
||||||
options?: PageOption & LanguageOption & RegionOption
|
options?: PageOption & LanguageOption & TimezoneOption
|
||||||
): Promise<TvShowsAiringToday> {
|
): Promise<TvShowsAiringToday> {
|
||||||
return await this.api.get<TvShowsAiringToday>(
|
return await this.api.get<TvShowsAiringToday>(
|
||||||
`${BASE_TV}/airing_today`,
|
`${BASE_TV}/airing_today`,
|
||||||
@@ -171,13 +201,13 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async popular(
|
async popular(
|
||||||
options?: PageOption & LanguageOption & RegionOption
|
options?: PageOption & LanguageOption
|
||||||
): Promise<PopularTvShows> {
|
): Promise<PopularTvShows> {
|
||||||
return await this.api.get<PopularTvShows>(`${BASE_TV}/popular`, options);
|
return await this.api.get<PopularTvShows>(`${BASE_TV}/popular`, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async topRated(
|
async topRated(
|
||||||
options?: PageOption & LanguageOption & RegionOption
|
options?: PageOption & LanguageOption
|
||||||
): Promise<TopRatedTvShows> {
|
): Promise<TopRatedTvShows> {
|
||||||
return await this.api.get<TopRatedTvShows>(`${BASE_TV}/top_rated`, options);
|
return await this.api.get<TopRatedTvShows>(`${BASE_TV}/top_rated`, options);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Movie } from '.';
|
import { LanguageOption, Movie } from '.';
|
||||||
|
|
||||||
export interface Collection {
|
export interface Collection {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -14,3 +14,10 @@ export interface Collection {
|
|||||||
export interface DetailedCollection extends Collection {
|
export interface DetailedCollection extends Collection {
|
||||||
parts: Movie[];
|
parts: Movie[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CollectionImageOptions extends LanguageOption {
|
||||||
|
/**
|
||||||
|
* a list of ISO-639-1 values to query
|
||||||
|
*/
|
||||||
|
include_image_language?: string[];
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ export * from './collections';
|
|||||||
export * from './tv-episode';
|
export * from './tv-episode';
|
||||||
export * from './tv-seasons';
|
export * from './tv-seasons';
|
||||||
|
|
||||||
|
export interface ErrorResponse {
|
||||||
|
status_code: number;
|
||||||
|
status_message: string;
|
||||||
|
success: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export type MediaType = 'movie' | 'tv' | 'person';
|
export type MediaType = 'movie' | 'tv' | 'person';
|
||||||
|
|
||||||
export interface AuthorDetails {
|
export interface AuthorDetails {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Movie } from '.';
|
import { Movie } from '.';
|
||||||
|
import { PageOption } from './options';
|
||||||
|
|
||||||
export interface KeywordsOptions {
|
export interface KeywordsOptions extends PageOption {
|
||||||
include_adult?: boolean;
|
include_adult?: boolean;
|
||||||
language?: string;
|
language?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ export interface RegionOption {
|
|||||||
region?: string;
|
region?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TimezoneOption {
|
||||||
|
timezone?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface PageOption {
|
export interface PageOption {
|
||||||
page?: number;
|
page?: number;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
ProductionCompany,
|
ProductionCompany,
|
||||||
ProductionCountry,
|
ProductionCountry,
|
||||||
SpokenLanguage,
|
SpokenLanguage,
|
||||||
Episode,
|
LanguageOption,
|
||||||
} from './';
|
} from './';
|
||||||
|
|
||||||
export interface CreatedBy {
|
export interface CreatedBy {
|
||||||
@@ -274,3 +274,17 @@ export interface TvShowChangeValue {
|
|||||||
season_id: number;
|
season_id: number;
|
||||||
season_number: number;
|
season_number: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TvShowImageOptions extends LanguageOption {
|
||||||
|
/**
|
||||||
|
* a list of ISO-639-1 values to query
|
||||||
|
*/
|
||||||
|
include_image_language?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TvShowVideoOptions extends LanguageOption {
|
||||||
|
/**
|
||||||
|
* a list of ISO-639-1 values to query
|
||||||
|
*/
|
||||||
|
include_video_language?: string[];
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user