56 Commits
v1 ... v-1.7.0

Author SHA1 Message Date
Blake
c56ecbef47 Update package.json 2024-03-10 14:23:57 -04:00
Blake
876d2cac0f Merge pull request #49 from pypp/feat/undocumented-backdrop-size
Add w500 size to backdrop
2024-03-10 04:10:01 -04:00
Blake
9dae7144b2 Merge pull request #50 from pypp/feat/trending-page-options
Add pageOption to the trending endpoint
2024-03-10 04:09:51 -04:00
Netanel Henya
f99dbac1d2 feat: add pageOption to the trending endpoint 2024-02-23 11:36:05 +02:00
Netanel Henya
43f5d16dc3 feat: added w500 size to backdrop, this size is not in the officel documentation but it still exists 2024-02-23 08:16:29 +02:00
Blake
682cf48cb0 Merge pull request #48 from blakejoy/chore/add-error-res
Feat: Add error response.
2024-01-15 12:02:07 -05:00
Blake Joynes
1146ca8ad2 add error. linting 2024-01-15 11:59:48 -05:00
Blake
6a68e9973b Merge pull request #46 from blakejoy/chore/v1.6
Update package.json
2023-12-28 21:32:30 -05:00
Blake
ad2b27ca72 Update package.json 2023-12-28 21:32:20 -05:00
Blake
76f62210be Merge pull request #42 from jeremyVignelles/fix/39-language-options
[i18n]Fixed all implemented methods that should allow LanguageOptions to be passed
2023-12-28 21:31:20 -05:00
Jérémy VIGNELLES
101457cdd7 Moved interfaces as requested 2023-11-16 14:22:17 +01:00
Jérémy VIGNELLES
7d4b3fcb60 Added languages options for genres 2023-11-16 13:41:45 +01:00
Jérémy VIGNELLES
eb53747570 Fix a bad union type typing 2023-11-16 13:41:44 +01:00
Jérémy VIGNELLES
8c615edbfa Fixed language options on all supported entrypoints 2023-11-16 13:41:35 +01:00
Blake
1628ea05bd Merge pull request #44 from blakejoy/blakejoy-patch-2
Update patch version
2023-11-14 01:13:18 -05:00
Blake
90b70a9c88 Update package.json 2023-11-14 01:13:04 -05:00
Blake
52c874b79f Merge pull request #41 from benlei/master
Adding company data, network data, tv show aggregate credits
2023-11-09 09:44:05 -05:00
Benjamin Lei
31f9cc3fac updating version 2023-09-06 17:19:21 -07:00
Benjamin Lei
d5013db314 adding tv networks 2023-09-01 19:27:15 -07:00
Benjamin Lei
8738ac7fda omit type like rest 2023-09-01 18:53:24 -07:00
Benjamin Lei
152e742883 fixing season aggregate credit type 2023-09-01 18:51:09 -07:00
Benjamin Lei
8c59fe859c format 2023-09-01 18:34:54 -07:00
Benjamin Lei
ab1925d32c adding in aggregate credits 2023-09-01 18:32:37 -07:00
Benjamin Lei
b11187c093 Need to also add in companies getter 2023-08-30 19:43:45 -07:00
Benjamin Lei
f605edf354 applying format 2023-08-30 17:58:37 -07:00
Benjamin Lei
caae3009d5 adding 2023-08-30 17:52:48 -07:00
Benjamin Lei
1c79599c41 Add company endpoints 2023-08-30 17:52:43 -07:00
Blake
d50ec7eb31 Merge pull request #37 from Der-Penz/endpoint/tv-season
Endpoint/tvSeason
2023-05-20 09:02:24 -04:00
DerPenz
f3469510c3 bumbed version : 1.4.0 2023-05-20 12:30:27 +02:00
DerPenz
0020057097 append to response tvSeason support 2023-05-15 13:30:52 +02:00
DerPenz
dbb93f5104 Merge branch 'master' into endpoint/tv-season 2023-05-15 13:13:20 +02:00
Blake
1b8138b971 Merge pull request #35 from Der-Penz/endpoint/tv-episode
Endpoint/tv episode
2023-05-13 16:38:47 -04:00
DerPenz
f6a5375c8c tv seasons endpoint 2023-05-08 17:11:56 +02:00
DerPenz
54cb13c23e bumbed version : 1.3.0 2023-05-06 19:32:14 +02:00
DerPenz
e46f140890 append to response support 2023-05-06 19:29:36 +02:00
DerPenz
33830afe92 refactored change type 2023-05-06 19:22:40 +02:00
DerPenz
9457dce115 base tv-episode integration 2023-05-06 18:57:20 +02:00
Blake
b0b6398169 Merge pull request #33 from xanderbarkhatov/feature/multi-search
Add multi-search, adjust types to allow type narrowing
2023-05-06 10:13:16 -04:00
Alexander B
5d9c61971d Merge branch 'master' of github.com:blakejoy/tmdb-ts into feature/multi-search 2023-05-04 21:38:37 +06:00
Alexander B
16c8b9e4ff chore: bump minor version 2023-05-04 21:35:22 +06:00
Blake
80a5e5e5bd Merge pull request #30 from Der-Penz/feature/append-result
Feature: append_to_result support
2023-05-04 07:49:39 -04:00
DerPenz
4b88e795f1 fixed wrong ImageConfiguration interface 2023-04-30 18:18:57 +02:00
Alexander B
da6427807f feat: add multi-search, adjust types to allow type narrowing 2023-04-28 20:26:34 +06:00
DerPenz
2e6cc38995 Merge branch 'master' into feature/append-result 2023-04-27 11:31:07 +02:00
DerPenz
738a0a7a24 version: 1.1.0 2023-04-27 11:30:34 +02:00
DerPenz
0a7590e989 fixed grammar mistakes 2023-04-27 11:27:12 +02:00
Blake
2705f52160 Merge pull request #32 from blakejoy/blakejoy-patch-1
Update README.md
2023-04-25 22:56:15 -04:00
Blake
2fed644950 Update README.md 2023-04-25 22:56:07 -04:00
DerPenz
bb5e9ad50f fixed bug with undefined second parameter 2023-04-22 15:44:17 +02:00
DerPenz
7d96ad04d1 full support for /person 2023-04-22 15:33:28 +02:00
DerPenz
cf7a561e3f full support for /movie and /tv 2023-04-21 20:59:12 +02:00
Blake
e5ce15d58d Merge pull request #28 from blakejoy/v1
feat: remove default export
2023-04-21 09:15:52 -04:00
DerPenz
cc41646798 append_to_response changes support 2023-04-19 20:23:16 +02:00
DerPenz
5927f95f0a format & combined equal changes type 2023-04-19 20:20:56 +02:00
DerPenz
a5acac981c support for most of the append_to_response options 2023-04-19 20:12:09 +02:00
DerPenz
4f5c39ba7a fixed wrong image type 2023-04-19 19:32:55 +02:00
34 changed files with 1136 additions and 224 deletions

View File

@@ -14,8 +14,10 @@ Installation:
npm install --save tmdb-ts
``
Version 1.0 removed the default import so make sure you update accordingly!
```js
import TMDB from 'tmdb-ts';
import { TMDB } from 'tmdb-ts';
const tmdb = new TMDB('accessToken');

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "tmdb-ts",
"version": "0.2.0",
"version": "1.6.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "tmdb-ts",
"version": "0.2.0",
"version": "1.6.1",
"license": "MIT",
"dependencies": {
"cross-fetch": "^3.1.4"

View File

@@ -1,16 +1,15 @@
{
"name": "tmdb-ts",
"version": "1.0.0",
"version": "1.7.0",
"description": "TMDB v3 library wrapper",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"compile": "rm -rf dist && tsc -d && npm run copy-types",
"compile": "rm -rf dist && tsc -d",
"lint": "eslint --ext .ts src/",
"lint:fix": "eslint --ext .ts src/ --fix",
"format": "npx prettier --write src",
"pre-commit": "npm run lint",
"copy-types": "mkdir dist/types && cp src/types/*.d.ts dist/types"
"pre-commit": "npm run lint"
},
"bugs": {
"url": "https://github.com/blakejoy/tmdb-ts/issues",

View File

@@ -1,5 +1,6 @@
import fetch from 'cross-fetch';
import { parseOptions } from './utils';
import { ErrorResponse } from './types';
const BASE_URL_V3 = 'https://api.themoviedb.org/3';
@@ -17,6 +18,11 @@ export class Api {
'Content-Type': 'application/json;charset=utf-8',
},
});
if (!response.ok) {
return Promise.reject((await response.json()) as ErrorResponse);
}
return (await response.json()) as T;
}
}

View File

@@ -1,20 +1,20 @@
import { ChangeOption, MediaChanges } from '../types';
import { BaseEndpoint } from './base';
import { ChangeOptions, Changes } from '../types/changes';
export class ChangeEndpoint extends BaseEndpoint {
constructor(protected readonly accessToken: string) {
super(accessToken);
}
async movies(options?: ChangeOptions): Promise<Changes> {
return await this.api.get<Changes>(`/movie/changes`, options);
async movies(options?: ChangeOption): Promise<MediaChanges> {
return await this.api.get<MediaChanges>(`/movie/changes`, options);
}
async tvShows(options?: ChangeOptions): Promise<Changes> {
return await this.api.get<Changes>(`/tv/changes`, options);
async tvShows(options?: ChangeOption): Promise<MediaChanges> {
return await this.api.get<MediaChanges>(`/tv/changes`, options);
}
async person(options?: ChangeOptions): Promise<Changes> {
return await this.api.get<Changes>(`/person/change`, options);
async person(options?: ChangeOption): Promise<MediaChanges> {
return await this.api.get<MediaChanges>(`/person/change`, options);
}
}

View File

@@ -1,4 +1,5 @@
import {
CollectionImageOptions,
DetailedCollection,
ImageCollection,
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>(
`${BASE_COLLECTION}/${id}/images`,
options
computedOptions
);
}

View File

@@ -0,0 +1,26 @@
import {
CompanyDetails,
AlternativeNames,
CompanyImages,
} from './../types/companies';
import { BaseEndpoint } from './base';
export class CompaniesEndpoint extends BaseEndpoint {
constructor(protected readonly accessToken: string) {
super(accessToken);
}
async details(id: number): Promise<CompanyDetails> {
return await this.api.get<CompanyDetails>(`/company/${id}`);
}
async alternativeNames(id: number): Promise<AlternativeNames> {
return await this.api.get<AlternativeNames>(
`/company/${id}/alternative_names`
);
}
async images(id: number): Promise<CompanyImages> {
return await this.api.get<CompanyImages>(`/company/${id}/images`);
}
}

View File

@@ -1,3 +1,4 @@
import { LanguageOption } from '../types';
import { BaseEndpoint } from './base';
export interface Genres {
@@ -9,11 +10,11 @@ export class GenreEndpoint extends BaseEndpoint {
super(accessToken);
}
async movies(): Promise<Genres> {
return await this.api.get<Genres>('/genre/movie/list');
async movies(options?: LanguageOption): Promise<Genres> {
return await this.api.get<Genres>('/genre/movie/list', options);
}
async tvShows(): Promise<Genres> {
return await this.api.get<Genres>('/genre/tv/list');
async tvShows(options?: LanguageOption): Promise<Genres> {
return await this.api.get<Genres>('/genre/tv/list', options);
}
}

View File

@@ -14,3 +14,5 @@ export * from './trending';
export * from './find';
export * from './keywords';
export * from './collections';
export * from './tv-seasons';
export * from './tv-episode';

View File

@@ -1,14 +1,17 @@
import { BaseEndpoint } from './base';
import {
AlternativeTitles,
ChangeOptions,
AppendToResponse,
AppendToResponseMovieKey,
ChangeOption,
Changes,
Credits,
ExternalIds,
Images,
Keywords,
LanguageOption,
LatestMovie,
MovieChanges,
MovieChangeValue,
MovieDetails,
MovieLists,
MoviesPlayingNow,
@@ -28,13 +31,34 @@ import {
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 {
constructor(protected readonly accessToken: string) {
super(accessToken);
}
async details(id: number): Promise<MovieDetails> {
return await this.api.get<MovieDetails>(`${BASE_MOVIE}/${id}`);
async details<T extends AppendToResponseMovieKey[] | undefined>(
id: number,
appendToResponse?: T,
language?: string
) {
const options = {
append_to_response: appendToResponse
? appendToResponse.join(',')
: undefined,
language: language,
};
return await this.api.get<AppendToResponse<MovieDetails, T, 'movie'>>(
`${BASE_MOVIE}/${id}`,
options
);
}
async alternativeTitles(id: number): Promise<AlternativeTitles> {
@@ -43,23 +67,36 @@ export class MoviesEndpoint extends BaseEndpoint {
);
}
async changes(id: number, options?: ChangeOptions): Promise<MovieChanges> {
return await this.api.get<MovieChanges>(
async changes(
id: number,
options?: ChangeOption
): Promise<Changes<MovieChangeValue>> {
return await this.api.get<Changes<MovieChangeValue>>(
`${BASE_MOVIE}/${id}/changes`,
options
);
}
async credits(id: number): Promise<Credits> {
return await this.api.get<Credits>(`${BASE_MOVIE}/${id}/credits`);
async credits(id: number, options?: LanguageOption): Promise<Credits> {
return await this.api.get<Credits>(`${BASE_MOVIE}/${id}/credits`, options);
}
async externalIds(id: number): Promise<ExternalIds> {
return await this.api.get<ExternalIds>(`${BASE_MOVIE}/${id}/external_ids`);
}
async images(id: number): Promise<Images> {
return await this.api.get<Images>(`${BASE_MOVIE}/${id}/images`);
async 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> {
@@ -68,14 +105,14 @@ export class MoviesEndpoint extends BaseEndpoint {
async lists(
id: number,
options?: LanguageOption | PageOption
options?: LanguageOption & PageOption
): Promise<MovieLists> {
return await this.api.get<MovieLists>(`${BASE_MOVIE}/${id}/lists`, options);
}
async recommendations(
id: number,
options?: PageOption
options?: LanguageOption & PageOption
): Promise<Recommendations> {
return await this.api.get<Recommendations>(
`${BASE_MOVIE}/${id}/recommendations`,
@@ -89,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);
}
async similar(id: number, options?: PageOption): Promise<SimilarMovies> {
async similar(
id: number,
options?: LanguageOption & PageOption
): Promise<SimilarMovies> {
return await this.api.get<SimilarMovies>(
`${BASE_MOVIE}/${id}/similar`,
options
@@ -104,8 +147,8 @@ export class MoviesEndpoint extends BaseEndpoint {
return await this.api.get<Translations>(`${BASE_MOVIE}/${id}/translations`);
}
async videos(id: number): Promise<Videos> {
return await this.api.get<Videos>(`${BASE_MOVIE}/${id}/videos`);
async videos(id: number, options?: LanguageOption): Promise<Videos> {
return await this.api.get<Videos>(`${BASE_MOVIE}/${id}/videos`, options);
}
/**
@@ -131,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);
}

23
src/endpoints/networks.ts Normal file
View File

@@ -0,0 +1,23 @@
import { NetworkDetails, NetworkImages } from '..';
import { AlternativeNames } from './../types/companies';
import { BaseEndpoint } from './base';
export class NetworksEndpoint extends BaseEndpoint {
constructor(protected readonly accessToken: string) {
super(accessToken);
}
async details(id: number): Promise<NetworkDetails> {
return await this.api.get<NetworkDetails>(`/network/${id}`);
}
async alternativeNames(id: number): Promise<AlternativeNames> {
return await this.api.get<AlternativeNames>(
`/network/${id}/alternative_names`
);
}
async images(id: number): Promise<NetworkImages> {
return await this.api.get<NetworkImages>(`/network/${id}/images`);
}
}

View File

@@ -1,16 +1,20 @@
import {
ChangeOptions,
AppendToResponse,
AppendToResponsePersonKey,
ChangeOption,
ExternalIds,
Image,
PageOption,
PeopleTranslations,
PersonChanges,
PeopleImages,
PersonTranslations,
PersonCombinedCredits,
PersonDetail,
PersonDetails,
PersonMovieCredit,
PersonTvShowCredit,
PopularPersons,
TaggedImages,
Changes,
PersonChangeValue,
LanguageOption,
} from '../types';
import { BaseEndpoint } from './base';
@@ -21,32 +25,60 @@ export class PeopleEndpoint extends BaseEndpoint {
super(accessToken);
}
async details(id: number): Promise<PersonDetail> {
return await this.api.get<PersonDetail>(`${BASE_PERSON}/${id}`);
async details<T extends AppendToResponsePersonKey[] | undefined>(
id: number,
appendToResponse?: T,
language?: string
) {
const options = {
append_to_response: appendToResponse
? appendToResponse.join(',')
: undefined,
language: language,
};
return await this.api.get<AppendToResponse<PersonDetails, T, 'person'>>(
`${BASE_PERSON}/${id}`,
options
);
}
async changes(id: number, options?: ChangeOptions): Promise<PersonChanges> {
return await this.api.get<PersonChanges>(
async changes(
id: number,
options?: ChangeOption
): Promise<Changes<PersonChangeValue>> {
return await this.api.get<Changes<PersonChangeValue>>(
`${BASE_PERSON}/${id}/changes`,
options
);
}
async movieCredits(id: number): Promise<PersonMovieCredit> {
async movieCredits(
id: number,
options?: LanguageOption
): Promise<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>(
`${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>(
`${BASE_PERSON}/${id}/combined_credits`
`${BASE_PERSON}/${id}/combined_credits`,
options
);
}
@@ -54,10 +86,8 @@ export class PeopleEndpoint extends BaseEndpoint {
return await this.api.get<ExternalIds>(`${BASE_PERSON}/${id}/external_ids`);
}
async images(id: number): Promise<{ id: number; profiles: Image[] }> {
return await this.api.get<{ id: number; profiles: Image[] }>(
`${BASE_PERSON}/${id}/images`
);
async images(id: number): Promise<PeopleImages> {
return await this.api.get<PeopleImages>(`${BASE_PERSON}/${id}/images`);
}
async taggedImages(id: number, options?: PageOption): Promise<TaggedImages> {
@@ -67,17 +97,19 @@ export class PeopleEndpoint extends BaseEndpoint {
);
}
async translation(id: number): Promise<PeopleTranslations> {
return await this.api.get<PeopleTranslations>(
async translation(id: number): Promise<PersonTranslations> {
return await this.api.get<PersonTranslations>(
`${BASE_PERSON}/${id}/translations`
);
}
async latest(): Promise<PersonDetail> {
return await this.api.get<PersonDetail>(`${BASE_PERSON}/latest`);
async latest(): Promise<PersonDetails> {
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>(
`${BASE_PERSON}/popular`,
options

View File

@@ -1,6 +1,15 @@
import { BaseEndpoint } from './base';
import { Search } from '../types/search';
import { Collection, Company, Movie, Person, TV } from '../types';
import { MultiSearchResult, Search } from '../types/search';
import {
Collection,
Company,
LanguageOption,
Movie,
PageOption,
Person,
RegionOption,
TV,
} from '../types';
const BASE_SEARCH = '/search';
@@ -9,18 +18,44 @@ export interface SearchOptions {
page?: number;
}
export interface MovieSearchOptions extends SearchOptions {
export interface MovieSearchOptions
extends SearchOptions,
LanguageOption,
PageOption,
RegionOption {
include_adult?: boolean;
year?: number;
primary_release_year?: number;
}
export interface TvSearchOptions extends SearchOptions {
export interface CollectionSearchOptions
extends SearchOptions,
LanguageOption,
PageOption,
RegionOption {
include_adult?: boolean;
}
export interface TvSearchOptions
extends SearchOptions,
LanguageOption,
PageOption {
include_adult?: boolean;
year?: number;
first_air_date_year?: number;
}
export interface PeopleSearchOptions extends SearchOptions {
export interface PeopleSearchOptions
extends SearchOptions,
LanguageOption,
PageOption {
include_adult?: boolean;
}
export interface MultiSearchOptions
extends SearchOptions,
LanguageOption,
PageOption {
include_adult?: boolean;
}
@@ -60,9 +95,14 @@ export class SearchEndpoint extends BaseEndpoint {
return await this.api.get<Search<Person>>(`${BASE_SEARCH}/person`, options);
}
// TODO: Multi search
async tvShows(options: TvSearchOptions): Promise<Search<TV>> {
return await this.api.get<Search<TV>>(`${BASE_SEARCH}/tv`, options);
}
async multi(options: MultiSearchOptions): Promise<Search<MultiSearchResult>> {
return await this.api.get<Search<MultiSearchResult>>(
`${BASE_SEARCH}/multi`,
options
);
}
}

View File

@@ -1,4 +1,10 @@
import { MediaType, TimeWindow, TrendingResults } from '../types';
import {
TrendingMediaType,
TimeWindow,
TrendingResults,
LanguageOption,
PageOption,
} from '../types';
import { BaseEndpoint } from './base';
export class TrendingEndpoint extends BaseEndpoint {
@@ -6,12 +12,14 @@ export class TrendingEndpoint extends BaseEndpoint {
super(accessToken);
}
async trending<T extends MediaType>(
async trending<T extends TrendingMediaType>(
mediaType: T,
timeWindow: TimeWindow
timeWindow: TimeWindow,
options?: LanguageOption & PageOption
): Promise<TrendingResults<T>> {
return await this.api.get<TrendingResults<T>>(
`/trending/${mediaType}/${timeWindow}`
`/trending/${mediaType}/${timeWindow}`,
options
);
}
}

111
src/endpoints/tv-episode.ts Normal file
View File

@@ -0,0 +1,111 @@
import {
Episode,
EpisodeSelection,
LanguageOption,
ChangeOption,
TvEpisodeCredit,
ExternalIds,
Images,
TvEpisodeTranslations,
Videos,
AppendToResponse,
Changes,
TvEpisodeChangeValue,
AppendToResponseTvEpisodeKey,
} from '..';
import { BaseEndpoint } from './base';
const BASE_EPISODE = (episodeSelection: EpisodeSelection): string => {
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 {
constructor(accessToken: string) {
super(accessToken);
}
async details<T extends AppendToResponseTvEpisodeKey[] | undefined>(
episodeSelection: EpisodeSelection,
appendToResponse?: T,
options?: LanguageOption
) {
const combinedOptions = {
append_to_response: appendToResponse
? appendToResponse.join(',')
: undefined,
...options,
};
return await this.api.get<
AppendToResponse<Omit<Episode, 'show_id'>, T, 'tvEpisode'>
>(`${BASE_EPISODE(episodeSelection)}`, combinedOptions);
}
async changes(episodeID: number, options?: ChangeOption) {
return await this.api.get<Changes<TvEpisodeChangeValue>>(
`/tv/episode/${episodeID}/changes`,
options
);
}
async credits(episodeSelection: EpisodeSelection, options?: LanguageOption) {
return await this.api.get<TvEpisodeCredit>(
`${BASE_EPISODE(episodeSelection)}/credits`,
options
);
}
async externalIds(episodeSelection: EpisodeSelection) {
return await this.api.get<ExternalIds>(
`${BASE_EPISODE(episodeSelection)}/external_ids`
);
}
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>(
`${BASE_EPISODE(episodeSelection)}/images`,
computedOptions
);
}
async translations(episodeSelection: EpisodeSelection) {
return await this.api.get<TvEpisodeTranslations>(
`${BASE_EPISODE(episodeSelection)}/translations`
);
}
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>(
`${BASE_EPISODE(episodeSelection)}/videos`,
computedOptions
);
}
}

131
src/endpoints/tv-seasons.ts Normal file
View File

@@ -0,0 +1,131 @@
import {
ChangeOption,
Changes,
Credits,
ExternalIds,
Images,
LanguageOption,
TvSeasonChangeValue,
SeasonDetails,
SeasonSelection,
Translations,
Videos,
AppendToResponseTvSeasonKey,
AppendToResponse,
AggregateCredits,
} from '..';
import { BaseEndpoint } from './base';
const BASE_SEASON = (seasonSelection: SeasonSelection): string => {
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 {
constructor(accessToken: string) {
super(accessToken);
}
async details<T extends AppendToResponseTvSeasonKey[] | undefined>(
seasonSelection: SeasonSelection,
appendToResponse?: T,
options?: LanguageOption
) {
const combinedOptions = {
append_to_response: appendToResponse
? appendToResponse.join(',')
: undefined,
...options,
};
return await this.api.get<AppendToResponse<SeasonDetails, T, 'tvSeason'>>(
`${BASE_SEASON(seasonSelection)}`,
combinedOptions
);
}
async aggregateCredits(
seasonSelection: SeasonSelection,
options?: LanguageOption
) {
return await this.api.get<AggregateCredits>(
`${BASE_SEASON(seasonSelection)}/aggregate_credits`,
options
);
}
async changes(seasonId: number, options?: ChangeOption) {
return await this.api.get<Changes<TvSeasonChangeValue>>(
`/tv/season/${seasonId}/changes`,
options
);
}
async credits(seasonSelection: SeasonSelection, options?: LanguageOption) {
return await this.api.get<Credits>(
`${BASE_SEASON(seasonSelection)}/credits`,
options
);
}
async externalIds(
seasonSelection: SeasonSelection,
options?: LanguageOption
) {
return await this.api.get<ExternalIds>(
`${BASE_SEASON(seasonSelection)}/external_ids`,
options
);
}
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>(
`${BASE_SEASON(seasonSelection)}/images`,
computedOptions
);
}
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>(
`${BASE_SEASON(seasonSelection)}/videos`,
computedOptions
);
}
async translations(
seasonSelection: SeasonSelection,
options?: LanguageOption
) {
return await this.api.get<Translations>(
`${BASE_SEASON(seasonSelection)}/translations`,
options
);
}
}

View File

@@ -1,7 +1,11 @@
import { BaseEndpoint } from './base';
import {
AggregateCredits,
AlternativeTitles,
ChangeOptions,
AppendToResponse,
AppendToResponseTvKey,
ChangeOption,
Changes,
ContentRatings,
Credits,
EpisodeGroups,
@@ -14,14 +18,16 @@ import {
PageOption,
PopularTvShows,
Recommendations,
RegionOption,
Reviews,
ScreenedTheatrically,
SeasonDetails,
SimilarTvShows,
TimezoneOption,
TopRatedTvShows,
Translations,
TvShowChanges,
TvShowImageOptions,
TvShowVideoOptions,
TvShowChangeValue,
TvShowDetails,
TvShowsAiringToday,
Videos,
@@ -35,8 +41,21 @@ export class TvShowsEndpoint extends BaseEndpoint {
super(accessToken);
}
async details(id: number): Promise<TvShowDetails> {
return await this.api.get<TvShowDetails>(`${BASE_TV}/${id}`);
async details<T extends AppendToResponseTvKey[] | undefined>(
id: number,
appendToResponse?: T,
language?: string
) {
const options = {
append_to_response: appendToResponse
? appendToResponse.join(',')
: undefined,
language: language,
};
return await this.api.get<AppendToResponse<TvShowDetails, T, 'tvShow'>>(
`${BASE_TV}/${id}`,
options
);
}
async alternativeTitles(id: number): Promise<AlternativeTitles> {
@@ -45,8 +64,11 @@ export class TvShowsEndpoint extends BaseEndpoint {
);
}
async changes(id: number, options?: ChangeOptions): Promise<TvShowChanges> {
return await this.api.get<TvShowChanges>(
async changes(
id: number,
options?: ChangeOption
): Promise<Changes<TvShowChangeValue>> {
return await this.api.get<Changes<TvShowChangeValue>>(
`${BASE_TV}/${id}/changes`,
options
);
@@ -58,8 +80,18 @@ export class TvShowsEndpoint extends BaseEndpoint {
);
}
async credits(id: number): Promise<Credits> {
return await this.api.get<Credits>(`${BASE_TV}/${id}/credits`);
async aggregateCredits(
id: number,
options?: LanguageOption
): Promise<AggregateCredits> {
return await this.api.get<AggregateCredits>(
`${BASE_TV}/${id}/aggregate_credits`,
options
);
}
async credits(id: number, options?: LanguageOption): Promise<Credits> {
return await this.api.get<Credits>(`${BASE_TV}/${id}/credits`, options);
}
async season(tvId: number, seasonNumber: number): Promise<SeasonDetails> {
@@ -76,8 +108,15 @@ export class TvShowsEndpoint extends BaseEndpoint {
return await this.api.get<ExternalIds>(`${BASE_TV}/${id}/external_ids`);
}
async images(id: number): Promise<Images> {
return await this.api.get<Images>(`${BASE_TV}/${id}/images`);
async images(id: number, options?: TvShowImageOptions): Promise<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> {
@@ -86,7 +125,7 @@ export class TvShowsEndpoint extends BaseEndpoint {
async recommendations(
id: number,
options?: PageOption
options?: LanguageOption & PageOption
): Promise<Recommendations> {
return await this.api.get<Recommendations>(
`${BASE_TV}/${id}/recommendations`,
@@ -94,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);
}
@@ -104,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>(
`${BASE_TV}/${id}/similar`,
options
@@ -115,8 +160,15 @@ export class TvShowsEndpoint extends BaseEndpoint {
return await this.api.get<Translations>(`${BASE_TV}/${id}/translations`);
}
async videos(id: number): Promise<Videos> {
return await this.api.get<Videos>(`${BASE_TV}/${id}/videos`);
async videos(id: number, options?: TvShowVideoOptions): Promise<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
);
}
/**
@@ -133,12 +185,14 @@ export class TvShowsEndpoint extends BaseEndpoint {
return await this.api.get<LatestTvShows>(`${BASE_TV}/latest`);
}
async onTheAir(): Promise<OnTheAir> {
return await this.api.get<OnTheAir>(`${BASE_TV}/on_the_air`);
async onTheAir(
options?: PageOption & LanguageOption & TimezoneOption
): Promise<OnTheAir> {
return await this.api.get<OnTheAir>(`${BASE_TV}/on_the_air`, options);
}
async airingToday(
options?: PageOption & LanguageOption & RegionOption
options?: PageOption & LanguageOption & TimezoneOption
): Promise<TvShowsAiringToday> {
return await this.api.get<TvShowsAiringToday>(
`${BASE_TV}/airing_today`,
@@ -147,13 +201,13 @@ export class TvShowsEndpoint extends BaseEndpoint {
}
async popular(
options?: PageOption & LanguageOption & RegionOption
options?: PageOption & LanguageOption
): Promise<PopularTvShows> {
return await this.api.get<PopularTvShows>(`${BASE_TV}/popular`, options);
}
async topRated(
options?: PageOption & LanguageOption & RegionOption
options?: PageOption & LanguageOption
): Promise<TopRatedTvShows> {
return await this.api.get<TopRatedTvShows>(`${BASE_TV}/top_rated`, options);
}

View File

@@ -15,7 +15,11 @@ import {
FindEndpoint,
KeywordsEndpoint,
CollectionsEndpoint,
TvSeasonsEndpoint,
TvEpisodesEndpoint,
} from './endpoints';
import { CompaniesEndpoint } from './endpoints/companies';
import { NetworksEndpoint } from './endpoints/networks';
export class TMDB {
private readonly accessToken: string;
@@ -44,6 +48,14 @@ export class TMDB {
return new CreditsEndpoint(this.accessToken);
}
get companies(): CompaniesEndpoint {
return new CompaniesEndpoint(this.accessToken);
}
get networks(): NetworksEndpoint {
return new NetworksEndpoint(this.accessToken);
}
get search(): SearchEndpoint {
return new SearchEndpoint(this.accessToken);
}
@@ -60,6 +72,10 @@ export class TMDB {
return new TvShowsEndpoint(this.accessToken);
}
get tvEpisode(): TvEpisodesEndpoint {
return new TvEpisodesEndpoint(this.accessToken);
}
get discover(): DiscoverEndpoint {
return new DiscoverEndpoint(this.accessToken);
}
@@ -87,4 +103,8 @@ export class TMDB {
get collections(): CollectionsEndpoint {
return new CollectionsEndpoint(this.accessToken);
}
get tvSeasons(): TvSeasonsEndpoint {
return new TvSeasonsEndpoint(this.accessToken);
}
}

View File

@@ -1,17 +1,29 @@
export interface Change {
export interface MediaChange {
id: number;
adult: boolean | undefined;
}
export interface Changes {
results: Change[];
export interface MediaChanges {
results: MediaChange[];
page: number;
total_pages: number;
total_results: number;
}
export interface ChangeOptions {
end_date?: string;
start_date?: string;
page?: number;
export interface Changes<T> {
changes: Change<T>[];
}
export interface Change<T> {
key: string;
items: ChangeItem<T>[];
}
export interface ChangeItem<T> {
id: string;
action: string;
time: string;
value: T;
iso_639_1: string;
original_value: T;
}

View File

@@ -1,4 +1,4 @@
import { Movie } from '.';
import { LanguageOption, Movie } from '.';
export interface Collection {
id: number;
@@ -14,3 +14,10 @@ export interface Collection {
export interface DetailedCollection extends Collection {
parts: Movie[];
}
export interface CollectionImageOptions extends LanguageOption {
/**
* a list of ISO-639-1 values to query
*/
include_image_language?: string[];
}

33
src/types/companies.ts Normal file
View File

@@ -0,0 +1,33 @@
import { Image } from '.';
export interface CompanyDetails {
description: string;
headquarters: string;
homepage: string;
id: number;
logo_path: string;
name: string;
origin_country: string;
parent_company: ParentCompany;
}
export interface ParentCompany {
name: string;
id: number;
logo_path: string;
}
export interface AlternativeNames {
id: number;
results: Name[];
}
export interface Name {
name: string;
type: string;
}
export interface CompanyImages {
id: number;
logos: Image[];
}

View File

@@ -1,4 +1,4 @@
export interface Images {
export interface ImageConfiguration {
base_url: string;
secure_base_url: string;
backdrop_sizes: BackdropSizes[];
@@ -9,12 +9,13 @@ export interface Images {
}
export interface Configuration {
images: Images;
images: ImageConfiguration;
change_keys: ChangeKeys[];
}
export const enum BackdropSizes {
W300 = 'w300',
W500 = 'w500',
W780 = 'w780',
W1280 = 'w1280',
ORIGINAL = 'original',

View File

@@ -101,3 +101,49 @@ export interface Videos {
id: number;
results: Video[];
}
export interface AggregateCredits {
id: number;
cast: AggregateCast[];
crew: AggregateCrew[];
}
export interface CastRole {
credit_id: string;
character: string;
episode_count: number;
}
export interface AggregateCast {
adult: boolean;
gender: number;
id: number;
known_for_department: string;
name: string;
original_name: string;
popularity: number;
profile_path: string;
roles: CastRole[];
total_episode_count: number;
order: number;
}
export interface CrewJob {
credit_id: string;
job: string;
episode_count: number;
}
export interface AggregateCrew {
adult: boolean;
gender: number;
id: number;
known_for_department: string;
name: string;
original_name: string;
popularity: number;
profile_path: string;
jobs: CrewJob[];
department: string;
total_episode_count: number;
}

View File

@@ -1,6 +1,8 @@
export * from './options';
export * from './certification';
export * from './credits';
export * from './companies';
export * from './networks';
export * from './configuration';
export * from './changes';
export * from './movies';
@@ -14,6 +16,16 @@ export * from './trending';
export * from './find';
export * from './keywords';
export * from './collections';
export * from './tv-episode';
export * from './tv-seasons';
export interface ErrorResponse {
status_code: number;
status_message: string;
success: boolean;
}
export type MediaType = 'movie' | 'tv' | 'person';
export interface AuthorDetails {
name: string;
@@ -22,23 +34,7 @@ export interface AuthorDetails {
rating?: number;
}
export interface KnownFor {
id: number;
overview: string;
release_date: string;
video: boolean;
adult: boolean;
backdrop_path: string;
media_type: string;
genre_ids: number[];
title: string;
original_language: string;
original_title: string;
poster_path: string;
vote_count: number;
vote_average: number;
popularity: number;
}
export type KnownFor = MovieWithMediaType | TVWithMediaType;
export interface Person {
id: number;
@@ -51,6 +47,10 @@ export interface Person {
popularity: number;
}
export interface PersonWithMediaType extends Person {
media_type: 'person';
}
export interface Movie {
id: number;
poster_path: string;
@@ -68,6 +68,10 @@ export interface Movie {
vote_average: number;
}
export interface MovieWithMediaType extends Movie {
media_type: 'movie';
}
export interface Company {
id: number;
logo_path: string;
@@ -91,6 +95,10 @@ export interface TV {
vote_average: number;
}
export interface TVWithMediaType extends TV {
media_type: 'tv';
}
export interface Genre {
id: number;
name: string;
@@ -128,6 +136,7 @@ export interface ContentRatings {
}
export interface ContentRatingsResult {
descriptor: unknown[];
iso_3166_1: string;
rating: string;
}
@@ -202,3 +211,10 @@ export interface Image {
vote_count: number;
width: number;
}
export interface Images {
id: number;
backdrops: Image[];
logos: Image[];
posters: Image[];
}

View File

@@ -1,6 +1,7 @@
import { Movie } from '.';
import { PageOption } from './options';
export interface KeywordsOptions {
export interface KeywordsOptions extends PageOption {
include_adult?: boolean;
language?: string;
}

View File

@@ -94,24 +94,6 @@ export interface MovieLists {
total_results: number;
}
export interface MovieChangeItem {
id: string;
action: string;
time: string;
iso_639_1: string;
value: string;
original_value: string;
}
export interface MovieChange {
key: string;
items: MovieChangeItem[];
}
export interface MovieChanges {
changes: MovieChange[];
}
export interface LatestMovie {
adult: boolean;
backdrop_path?: string;
@@ -173,3 +155,14 @@ export interface UpcomingMovies {
total_results: number;
total_pages: number;
}
export type MovieChangeValue =
| string
| {
person_id: number;
character: string;
order: number;
cast_id: number;
credit_id: string;
}
| unknown;

15
src/types/networks.ts Normal file
View File

@@ -0,0 +1,15 @@
import { Image } from '.';
export interface NetworkDetails {
headquarters: string;
homepage: string;
id: number;
logo_path: string;
name: string;
origin_country: string;
}
export interface NetworkImages {
id: number;
logos: Image[];
}

View File

@@ -1,3 +1,37 @@
import {
AlternativeTitles,
Changes,
ContentRatings,
Credits,
EpisodeGroups,
ExternalIds,
Images,
Keywords,
MovieLists,
PeopleImages,
PersonTranslations,
PersonCombinedCredits,
PersonMovieCredit,
PersonTvShowCredit,
Recommendations,
ReleaseDates,
Reviews,
ScreenedTheatrically,
SimilarMovies,
SimilarTvShows,
TaggedImages,
Translations,
Videos,
WatchProviders,
PersonChangeValue,
MovieChangeValue,
TvShowChangeValue,
TvEpisodeChangeValue,
TvEpisodeCredit,
TvEpisodeTranslations,
TvSeasonChangeValue,
} from '.';
export interface LanguageOption {
language?: string;
}
@@ -6,6 +40,201 @@ export interface RegionOption {
region?: string;
}
export interface TimezoneOption {
timezone?: string;
}
export interface PageOption {
page?: number;
}
export interface ChangeOption extends PageOption {
start_date?: Date;
end_date?: Date;
}
export type AppendToResponseMovieKey =
| 'images'
| 'videos'
| 'credits'
| 'recommendations'
| 'reviews'
| 'changes'
| 'similar'
| 'lists'
| 'release_dates'
| 'alternative_titles'
| 'external_ids'
| 'translations'
| 'watch/providers'
| 'keywords';
export type AppendToResponseTvKey =
| 'content_ratings'
| 'images'
| 'videos'
| 'credits'
| 'recommendations'
| 'reviews'
| 'changes'
| 'similar'
| 'alternative_titles'
| 'external_ids'
| 'translations'
| 'watch/providers'
| 'aggregate_credits'
| 'episode_groups'
| 'screened_theatrically'
| 'keywords';
export type AppendToResponsePersonKey =
| 'images'
| 'changes'
| 'movie_credits'
| 'tv_credits'
| 'combined_credits'
| 'external_ids'
| 'tagged_images'
| 'translations';
export type AppendToResponseTvEpisodeKey =
| 'images'
| 'credits'
| 'external_ids'
| 'videos'
| 'translations';
export type AppendToResponseTvSeasonKey =
| 'images'
| 'credits'
| 'external_ids'
| 'videos'
| 'aggregate_credits'
| 'translations';
type AppendToResponseAllKeys =
| AppendToResponseTvKey
| AppendToResponseMovieKey
| AppendToResponseTvEpisodeKey
| AppendToResponseTvSeasonKey
| AppendToResponsePersonKey;
export type AppendToResponseMediaType =
| 'movie'
| 'tvShow'
| 'person'
| 'tvSeason'
| 'tvEpisode';
export type AppendToResponse<
K,
T extends AppendToResponseAllKeys[] | undefined,
Media extends AppendToResponseMediaType
> = K &
(T extends undefined
? object
: T extends Array<unknown>
? ('credits' extends T[number]
? {
credits: Media extends 'tvEpisode'
? TvEpisodeCredit
: Omit<Credits, 'id'>;
}
: object) &
('videos' extends T[number] ? { videos: Omit<Videos, 'id'> } : object) &
('images' extends T[number]
? {
images: Omit<
Media extends 'person' ? PeopleImages : Images,
'id'
>;
}
: object) &
('recommendations' extends T[number]
? { recommendations: Recommendations }
: object) &
('reviews' extends T[number]
? { reviews: Omit<Reviews, 'id'> }
: object) &
('reviews' extends T[number]
? { reviews: Omit<Translations, 'id'> }
: object) &
('changes' extends T[number]
? {
changes: Changes<
Media extends 'person'
? PersonChangeValue
: Media extends 'movie'
? MovieChangeValue
: Media extends 'tvShow'
? TvShowChangeValue
: Media extends 'tvSeason'
? TvSeasonChangeValue
: TvEpisodeChangeValue
>;
}
: object) &
('keywords' extends T[number]
? { keywords: Omit<Keywords, 'id'> }
: object) &
('lists' extends T[number]
? { lists: Omit<MovieLists, 'id'> }
: object) &
('release_dates' extends T[number]
? { release_dates: Omit<ReleaseDates, 'id'> }
: object) &
('alternative_titles' extends T[number]
? { alternative_titles: Omit<AlternativeTitles, 'id'> }
: object) &
('external_ids' extends T[number]
? { external_ids: Omit<ExternalIds, 'id'> }
: object) &
('translations' extends T[number]
? {
translations: Omit<
Media extends 'person'
? PersonTranslations
: Media extends 'tvEpisode'
? TvEpisodeTranslations
: Translations,
'id'
>;
}
: object) &
('watch/providers' extends T[number]
? { 'watch/providers': Omit<WatchProviders, 'id'> }
: object) &
('aggregate_credits' extends T[number]
? { aggregate_credits: Omit<Credits, 'id'> }
: object) &
('episode_groups' extends T[number]
? { episode_groups: Omit<EpisodeGroups, 'id'> }
: object) &
('screened_theatrically' extends T[number]
? { screened_theatrically: Omit<ScreenedTheatrically, 'id'> }
: object) &
('similar' extends T[number]
? {
similar: Media extends 'movie'
? SimilarMovies
: Media extends 'tvShow'
? SimilarTvShows
: unknown;
}
: object) &
('content_ratings' extends T[number]
? { content_ratings: Omit<ContentRatings, 'id'> }
: object) &
('movie_credits' extends T[number]
? { movie_credits: Omit<PersonMovieCredit, 'id'> }
: object) &
('tv_credits' extends T[number]
? { tv_credits: Omit<PersonTvShowCredit, 'id'> }
: object) &
('combined_credits' extends T[number]
? { combined_credits: Omit<PersonCombinedCredits, 'id'> }
: object) &
('tagged_images' extends T[number]
? { tagged_images: TaggedImages }
: object)
: never);

View File

@@ -1,4 +1,4 @@
import { Movie, Person, TV } from '.';
import { Image, Movie, Person, TV } from '.';
interface Cast {
character: string;
@@ -79,7 +79,7 @@ export interface PersonCombinedCredits {
id: number;
}
export interface PersonDetail {
export interface PersonDetails {
birthday: string;
known_for_department: string;
deathday: string;
@@ -96,22 +96,13 @@ export interface PersonDetail {
homepage: string;
}
export interface PersonChange {
id: string;
action: string;
time: string;
iso_639_1: string;
iso_3166_1: string;
value: string | { profile: { file_path: string } };
original_value: string | { profile: { file_path: string } };
}
export interface PersonChanges {
changes: {
key: string;
items: PersonChange[];
}[];
}
export type PersonChangeValue =
| string
| {
profile: {
file_path: string;
};
};
export interface PopularPersons {
page: number;
@@ -120,6 +111,11 @@ export interface PopularPersons {
total_pages: number;
}
export interface PeopleImages {
id: number;
profiles: Image[];
}
export interface TaggedImage {
aspect_ratio: number;
file_path: string;
@@ -141,7 +137,7 @@ export interface TaggedImages {
total_pages: number;
}
export interface PeopleTranslations {
export interface PersonTranslations {
id: number;
translations: {
iso_3166_1: string;

View File

@@ -1,6 +1,13 @@
import { MovieWithMediaType, PersonWithMediaType, TVWithMediaType } from '.';
export interface Search<T> {
page: number;
results: T[];
total_pages: number;
total_results: number;
}
export type MultiSearchResult =
| MovieWithMediaType
| TVWithMediaType
| PersonWithMediaType;

View File

@@ -1,19 +1,28 @@
import { Movie, Person, TV } from '.';
export type MediaType = 'all' | 'movie' | 'tv' | 'person';
import {
Movie,
Person,
TV,
MediaType,
MovieWithMediaType,
TVWithMediaType,
PersonWithMediaType,
} from '.';
export type TimeWindow = 'day' | 'week';
type TrendingResult<T extends MediaType> = T extends 'tv'
export type TrendingMediaType = MediaType | 'all';
type TrendingResult<T extends TrendingMediaType> = T extends 'tv'
? TV
: T extends 'movie'
? Movie
: T extends 'person'
? Person
: TV | Movie | Person;
: TVWithMediaType | MovieWithMediaType | PersonWithMediaType;
export interface TrendingResults<T extends MediaType> {
export interface TrendingResults<T extends TrendingMediaType> {
page: number;
results: (TrendingResult<T> & { media_type: MediaType })[];
results: TrendingResult<T>[];
total_pages: number;
total_results: number;
}

58
src/types/tv-episode.ts Normal file
View File

@@ -0,0 +1,58 @@
import { Credits, Crew } from '.';
export interface EpisodeSelection {
tvShowID: number;
seasonNumber: number;
episodeNumber: number;
}
export interface Episode {
air_date: string;
episode_number: number;
crew: Crew[];
guest_stars: GuestStar[];
id: number;
name: string;
overview: string;
production_code: string;
season_number: number;
still_path: string;
vote_average: number;
vote_count: number;
runtime: number;
show_id: number;
}
export interface GuestStar {
credit_id: string;
order: number;
character: string;
adult: boolean;
gender: number | null;
id: number;
known_for_department: string;
name: string;
original_name: string;
popularity: number;
profile_path: string | null;
}
export interface TvEpisodeCredit extends Credits {
guest_stars: GuestStar[];
}
export interface TvEpisodeTranslations {
id: number;
translations: {
iso_3166_1: string;
iso_639_1: string;
name: string;
english_name: string;
data: {
name: string;
overview: string;
};
};
}
export type TvEpisodeChangeValue = string | unknown;

23
src/types/tv-seasons.ts Normal file
View File

@@ -0,0 +1,23 @@
import { Episode } from '.';
export interface SeasonSelection {
tvShowID: number;
seasonNumber: number;
}
export interface SeasonDetails {
air_date: string;
episodes: Episode[];
name: string;
overview: string;
id: number;
poster_path: string | null;
season_number: number;
}
export type TvSeasonChangeValue =
| string
| {
episode_id: number;
episode_number: number;
};

View File

@@ -3,7 +3,7 @@ import {
ProductionCompany,
ProductionCountry,
SpokenLanguage,
Crew,
LanguageOption,
} from './';
export interface CreatedBy {
@@ -93,65 +93,6 @@ export interface TvShowDetails {
vote_count: number;
}
export interface GuestStar {
credit_id: string;
order: number;
character: string;
adult: boolean;
gender: number | null;
id: number;
known_for_department: string;
name: string;
original_name: string;
popularity: number;
profile_path: string | null;
}
export interface Episode {
air_date: string;
episode_number: number;
crew: Crew[];
guest_stars: GuestStar[];
id: number;
name: string;
overview: string;
production_code: string;
season_number: number;
still_path: string;
vote_average: number;
vote_count: number;
show_id: number;
runtime: number;
}
export interface SeasonDetails {
air_date: string;
episodes: Episode[];
name: string;
overview: string;
id: number;
poster_path: string | null;
season_number: number;
}
export interface TvShowItem {
id: string;
action: string;
time: string;
value: Array<number>;
iso_639_1: string;
original_value: Array<number>;
}
export interface TvShowChange {
key: string;
items: TvShowItem[];
}
export interface TvShowChanges {
changes: TvShowChange[];
}
export interface Network {
id: number;
logo_path: string;
@@ -328,3 +269,22 @@ export interface TopRatedTvShows {
total_results: number;
total_pages: number;
}
export interface TvShowChangeValue {
season_id: 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[];
}