Compare commits
44 Commits
patch/upda
...
blakejoy-p
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90b70a9c88 | ||
|
|
52c874b79f | ||
|
|
31f9cc3fac | ||
|
|
d5013db314 | ||
|
|
8738ac7fda | ||
|
|
152e742883 | ||
|
|
8c59fe859c | ||
|
|
ab1925d32c | ||
|
|
b11187c093 | ||
|
|
f605edf354 | ||
|
|
caae3009d5 | ||
|
|
1c79599c41 | ||
|
|
d50ec7eb31 | ||
|
|
f3469510c3 | ||
|
|
0020057097 | ||
|
|
dbb93f5104 | ||
|
|
1b8138b971 | ||
|
|
f6a5375c8c | ||
|
|
54cb13c23e | ||
|
|
e46f140890 | ||
|
|
33830afe92 | ||
|
|
9457dce115 | ||
|
|
b0b6398169 | ||
|
|
5d9c61971d | ||
|
|
16c8b9e4ff | ||
|
|
80a5e5e5bd | ||
|
|
4b88e795f1 | ||
|
|
da6427807f | ||
|
|
2e6cc38995 | ||
|
|
738a0a7a24 | ||
|
|
0a7590e989 | ||
|
|
2705f52160 | ||
|
|
2fed644950 | ||
|
|
bb5e9ad50f | ||
|
|
7d96ad04d1 | ||
|
|
cf7a561e3f | ||
|
|
e5ce15d58d | ||
|
|
7f98a557dc | ||
|
|
9e54e26e87 | ||
|
|
cc41646798 | ||
|
|
5927f95f0a | ||
|
|
a5acac981c | ||
|
|
4f5c39ba7a | ||
|
|
69a883e845 |
@@ -14,8 +14,10 @@ Installation:
|
|||||||
npm install --save tmdb-ts
|
npm install --save tmdb-ts
|
||||||
``
|
``
|
||||||
|
|
||||||
|
Version 1.0 removed the default import so make sure you update accordingly!
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import TMDB from 'tmdb-ts';
|
import { TMDB } from 'tmdb-ts';
|
||||||
|
|
||||||
const tmdb = new TMDB('accessToken');
|
const tmdb = new TMDB('accessToken');
|
||||||
|
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "tmdb-ts",
|
"name": "tmdb-ts",
|
||||||
"version": "0.2.0",
|
"version": "1.5.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "tmdb-ts",
|
"name": "tmdb-ts",
|
||||||
"version": "0.2.0",
|
"version": "1.5.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cross-fetch": "^3.1.4"
|
"cross-fetch": "^3.1.4"
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "tmdb-ts",
|
"name": "tmdb-ts",
|
||||||
"version": "0.2.0",
|
"version": "1.5.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",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"compile": "rm -rf dist && tsc -d && npm run copy-types",
|
"compile": "rm -rf dist && tsc -d",
|
||||||
"lint": "eslint --ext .ts src/",
|
"lint": "eslint --ext .ts src/",
|
||||||
"lint:fix": "eslint --ext .ts src/ --fix",
|
"lint:fix": "eslint --ext .ts src/ --fix",
|
||||||
"format": "npx prettier --write src",
|
"format": "npx prettier --write src",
|
||||||
"pre-commit": "npm run lint",
|
"pre-commit": "npm run lint"
|
||||||
"copy-types": "mkdir dist/types && cp src/types/*.d.ts dist/types"
|
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/blakejoy/tmdb-ts/issues",
|
"url": "https://github.com/blakejoy/tmdb-ts/issues",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { parseOptions } from './utils';
|
|||||||
|
|
||||||
const BASE_URL_V3 = 'https://api.themoviedb.org/3';
|
const BASE_URL_V3 = 'https://api.themoviedb.org/3';
|
||||||
|
|
||||||
export default class Api {
|
export class Api {
|
||||||
constructor(private accessToken: string) {
|
constructor(private accessToken: string) {
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import Api from '../api';
|
import { Api } from '../api';
|
||||||
|
|
||||||
export class BaseEndpoint {
|
export class BaseEndpoint {
|
||||||
protected api: Api;
|
protected api: Api;
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
|
import { ChangeOption, MediaChanges } from '../types';
|
||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
import { ChangeOptions, Changes } from '../types/changes';
|
|
||||||
|
|
||||||
export class ChangeEndpoint extends BaseEndpoint {
|
export class ChangeEndpoint extends BaseEndpoint {
|
||||||
constructor(protected readonly accessToken: string) {
|
constructor(protected readonly accessToken: string) {
|
||||||
super(accessToken);
|
super(accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
async movies(options?: ChangeOptions): Promise<Changes> {
|
async movies(options?: ChangeOption): Promise<MediaChanges> {
|
||||||
return await this.api.get<Changes>(`/movie/changes`, options);
|
return await this.api.get<MediaChanges>(`/movie/changes`, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async tvShows(options?: ChangeOptions): Promise<Changes> {
|
async tvShows(options?: ChangeOption): Promise<MediaChanges> {
|
||||||
return await this.api.get<Changes>(`/tv/changes`, options);
|
return await this.api.get<MediaChanges>(`/tv/changes`, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async person(options?: ChangeOptions): Promise<Changes> {
|
async person(options?: ChangeOption): Promise<MediaChanges> {
|
||||||
return await this.api.get<Changes>(`/person/change`, options);
|
return await this.api.get<MediaChanges>(`/person/change`, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
26
src/endpoints/companies.ts
Normal file
26
src/endpoints/companies.ts
Normal 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`);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,3 +14,5 @@ export * from './trending';
|
|||||||
export * from './find';
|
export * from './find';
|
||||||
export * from './keywords';
|
export * from './keywords';
|
||||||
export * from './collections';
|
export * from './collections';
|
||||||
|
export * from './tv-seasons';
|
||||||
|
export * from './tv-episode';
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
import {
|
import {
|
||||||
AlternativeTitles,
|
AlternativeTitles,
|
||||||
ChangeOptions,
|
AppendToResponse,
|
||||||
|
AppendToResponseMovieKey,
|
||||||
|
ChangeOption,
|
||||||
|
Changes,
|
||||||
Credits,
|
Credits,
|
||||||
ExternalIds,
|
ExternalIds,
|
||||||
Images,
|
Images,
|
||||||
Keywords,
|
Keywords,
|
||||||
LanguageOption,
|
LanguageOption,
|
||||||
LatestMovie,
|
LatestMovie,
|
||||||
MovieChanges,
|
MovieChangeValue,
|
||||||
MovieDetails,
|
MovieDetails,
|
||||||
MovieLists,
|
MovieLists,
|
||||||
MoviesPlayingNow,
|
MoviesPlayingNow,
|
||||||
@@ -33,8 +36,20 @@ export class MoviesEndpoint extends BaseEndpoint {
|
|||||||
super(accessToken);
|
super(accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
async details(id: number): Promise<MovieDetails> {
|
async details<T extends AppendToResponseMovieKey[] | undefined>(
|
||||||
return await this.api.get<MovieDetails>(`${BASE_MOVIE}/${id}`);
|
id: number,
|
||||||
|
appendToResponse?: T
|
||||||
|
) {
|
||||||
|
const options = {
|
||||||
|
append_to_response: appendToResponse
|
||||||
|
? appendToResponse.join(',')
|
||||||
|
: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
return await this.api.get<AppendToResponse<MovieDetails, T, 'movie'>>(
|
||||||
|
`${BASE_MOVIE}/${id}`,
|
||||||
|
options
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async alternativeTitles(id: number): Promise<AlternativeTitles> {
|
async alternativeTitles(id: number): Promise<AlternativeTitles> {
|
||||||
@@ -43,8 +58,11 @@ export class MoviesEndpoint extends BaseEndpoint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async changes(id: number, options?: ChangeOptions): Promise<MovieChanges> {
|
async changes(
|
||||||
return await this.api.get<MovieChanges>(
|
id: number,
|
||||||
|
options?: ChangeOption
|
||||||
|
): Promise<Changes<MovieChangeValue>> {
|
||||||
|
return await this.api.get<Changes<MovieChangeValue>>(
|
||||||
`${BASE_MOVIE}/${id}/changes`,
|
`${BASE_MOVIE}/${id}/changes`,
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
|
|||||||
23
src/endpoints/networks.ts
Normal file
23
src/endpoints/networks.ts
Normal 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`);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +1,19 @@
|
|||||||
import {
|
import {
|
||||||
ChangeOptions,
|
AppendToResponse,
|
||||||
|
AppendToResponsePersonKey,
|
||||||
|
ChangeOption,
|
||||||
ExternalIds,
|
ExternalIds,
|
||||||
Image,
|
|
||||||
PageOption,
|
PageOption,
|
||||||
PeopleTranslations,
|
PeopleImages,
|
||||||
PersonChanges,
|
PersonTranslations,
|
||||||
PersonCombinedCredits,
|
PersonCombinedCredits,
|
||||||
PersonDetail,
|
PersonDetails,
|
||||||
PersonMovieCredit,
|
PersonMovieCredit,
|
||||||
PersonTvShowCredit,
|
PersonTvShowCredit,
|
||||||
PopularPersons,
|
PopularPersons,
|
||||||
TaggedImages,
|
TaggedImages,
|
||||||
|
Changes,
|
||||||
|
PersonChangeValue,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
|
|
||||||
@@ -21,12 +24,26 @@ export class PeopleEndpoint extends BaseEndpoint {
|
|||||||
super(accessToken);
|
super(accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
async details(id: number): Promise<PersonDetail> {
|
async details<T extends AppendToResponsePersonKey[] | undefined>(
|
||||||
return await this.api.get<PersonDetail>(`${BASE_PERSON}/${id}`);
|
id: number,
|
||||||
|
appendToResponse?: T
|
||||||
|
) {
|
||||||
|
const options = {
|
||||||
|
append_to_response: appendToResponse
|
||||||
|
? appendToResponse.join(',')
|
||||||
|
: undefined,
|
||||||
|
};
|
||||||
|
return await this.api.get<AppendToResponse<PersonDetails, T, 'person'>>(
|
||||||
|
`${BASE_PERSON}/${id}`,
|
||||||
|
options
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async changes(id: number, options?: ChangeOptions): Promise<PersonChanges> {
|
async changes(
|
||||||
return await this.api.get<PersonChanges>(
|
id: number,
|
||||||
|
options?: ChangeOption
|
||||||
|
): Promise<Changes<PersonChangeValue>> {
|
||||||
|
return await this.api.get<Changes<PersonChangeValue>>(
|
||||||
`${BASE_PERSON}/${id}/changes`,
|
`${BASE_PERSON}/${id}/changes`,
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
@@ -54,10 +71,8 @@ export class PeopleEndpoint extends BaseEndpoint {
|
|||||||
return await this.api.get<ExternalIds>(`${BASE_PERSON}/${id}/external_ids`);
|
return await this.api.get<ExternalIds>(`${BASE_PERSON}/${id}/external_ids`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async images(id: number): Promise<{ id: number; profiles: Image[] }> {
|
async images(id: number): Promise<PeopleImages> {
|
||||||
return await this.api.get<{ id: number; profiles: Image[] }>(
|
return await this.api.get<PeopleImages>(`${BASE_PERSON}/${id}/images`);
|
||||||
`${BASE_PERSON}/${id}/images`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async taggedImages(id: number, options?: PageOption): Promise<TaggedImages> {
|
async taggedImages(id: number, options?: PageOption): Promise<TaggedImages> {
|
||||||
@@ -67,14 +82,14 @@ export class PeopleEndpoint extends BaseEndpoint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async translation(id: number): Promise<PeopleTranslations> {
|
async translation(id: number): Promise<PersonTranslations> {
|
||||||
return await this.api.get<PeopleTranslations>(
|
return await this.api.get<PersonTranslations>(
|
||||||
`${BASE_PERSON}/${id}/translations`
|
`${BASE_PERSON}/${id}/translations`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async latest(): Promise<PersonDetail> {
|
async latest(): Promise<PersonDetails> {
|
||||||
return await this.api.get<PersonDetail>(`${BASE_PERSON}/latest`);
|
return await this.api.get<PersonDetails>(`${BASE_PERSON}/latest`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async popular(options?: PageOption): Promise<PopularPersons> {
|
async popular(options?: PageOption): Promise<PopularPersons> {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
import { Search } from '../types/search';
|
import { MultiSearchResult, Search } from '../types/search';
|
||||||
import { Collection, Company, Movie, Person, TV } from '../types';
|
import { Collection, Company, Movie, Person, TV } from '../types';
|
||||||
|
|
||||||
const BASE_SEARCH = '/search';
|
const BASE_SEARCH = '/search';
|
||||||
@@ -24,6 +24,10 @@ export interface PeopleSearchOptions extends SearchOptions {
|
|||||||
include_adult?: boolean;
|
include_adult?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MultiSearchOptions extends SearchOptions {
|
||||||
|
include_adult?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export class SearchEndpoint extends BaseEndpoint {
|
export class SearchEndpoint extends BaseEndpoint {
|
||||||
constructor(protected readonly accessToken: string) {
|
constructor(protected readonly accessToken: string) {
|
||||||
super(accessToken);
|
super(accessToken);
|
||||||
@@ -60,9 +64,14 @@ export class SearchEndpoint extends BaseEndpoint {
|
|||||||
return await this.api.get<Search<Person>>(`${BASE_SEARCH}/person`, options);
|
return await this.api.get<Search<Person>>(`${BASE_SEARCH}/person`, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Multi search
|
|
||||||
|
|
||||||
async tvShows(options: TvSearchOptions): Promise<Search<TV>> {
|
async tvShows(options: TvSearchOptions): Promise<Search<TV>> {
|
||||||
return await this.api.get<Search<TV>>(`${BASE_SEARCH}/tv`, options);
|
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
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { MediaType, TimeWindow, TrendingResults } from '../types';
|
import { TrendingMediaType, TimeWindow, TrendingResults } from '../types';
|
||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
|
|
||||||
export class TrendingEndpoint extends BaseEndpoint {
|
export class TrendingEndpoint extends BaseEndpoint {
|
||||||
@@ -6,7 +6,7 @@ export class TrendingEndpoint extends BaseEndpoint {
|
|||||||
super(accessToken);
|
super(accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
async trending<T extends MediaType>(
|
async trending<T extends TrendingMediaType>(
|
||||||
mediaType: T,
|
mediaType: T,
|
||||||
timeWindow: TimeWindow
|
timeWindow: TimeWindow
|
||||||
): Promise<TrendingResults<T>> {
|
): Promise<TrendingResults<T>> {
|
||||||
|
|||||||
83
src/endpoints/tv-episode.ts
Normal file
83
src/endpoints/tv-episode.ts
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
import {
|
||||||
|
Episode,
|
||||||
|
EpisodeSelection,
|
||||||
|
LanguageOption,
|
||||||
|
ChangeOption,
|
||||||
|
TvEpisodeCredit,
|
||||||
|
ExternalIds,
|
||||||
|
Images,
|
||||||
|
TvEpisodeTranslations,
|
||||||
|
Videos,
|
||||||
|
AppendToResponseMovieKey,
|
||||||
|
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 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) {
|
||||||
|
return await this.api.get<Images>(
|
||||||
|
`${BASE_EPISODE(episodeSelection)}/images`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async translations(episodeSelection: EpisodeSelection) {
|
||||||
|
return await this.api.get<TvEpisodeTranslations>(
|
||||||
|
`${BASE_EPISODE(episodeSelection)}/translations`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async videos(episodeSelection: EpisodeSelection, options?: LanguageOption) {
|
||||||
|
return await this.api.get<Videos>(
|
||||||
|
`${BASE_EPISODE(episodeSelection)}/videos`,
|
||||||
|
options
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
103
src/endpoints/tv-seasons.ts
Normal file
103
src/endpoints/tv-seasons.ts
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
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 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?: LanguageOption) {
|
||||||
|
return await this.api.get<Images>(
|
||||||
|
`${BASE_SEASON(seasonSelection)}/images`,
|
||||||
|
options
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async videos(seasonSelection: SeasonSelection, options?: LanguageOption) {
|
||||||
|
return await this.api.get<Videos>(
|
||||||
|
`${BASE_SEASON(seasonSelection)}/videos`,
|
||||||
|
options
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async translations(
|
||||||
|
seasonSelection: SeasonSelection,
|
||||||
|
options?: LanguageOption
|
||||||
|
) {
|
||||||
|
return await this.api.get<Translations>(
|
||||||
|
`${BASE_SEASON(seasonSelection)}/translations`,
|
||||||
|
options
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
import {
|
import {
|
||||||
|
AggregateCredits,
|
||||||
AlternativeTitles,
|
AlternativeTitles,
|
||||||
ChangeOptions,
|
AppendToResponse,
|
||||||
|
AppendToResponseTvKey,
|
||||||
|
ChangeOption,
|
||||||
|
Changes,
|
||||||
ContentRatings,
|
ContentRatings,
|
||||||
Credits,
|
Credits,
|
||||||
EpisodeGroups,
|
EpisodeGroups,
|
||||||
@@ -21,7 +25,7 @@ import {
|
|||||||
SimilarTvShows,
|
SimilarTvShows,
|
||||||
TopRatedTvShows,
|
TopRatedTvShows,
|
||||||
Translations,
|
Translations,
|
||||||
TvShowChanges,
|
TvShowChangeValue,
|
||||||
TvShowDetails,
|
TvShowDetails,
|
||||||
TvShowsAiringToday,
|
TvShowsAiringToday,
|
||||||
Videos,
|
Videos,
|
||||||
@@ -35,8 +39,19 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
|||||||
super(accessToken);
|
super(accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
async details(id: number): Promise<TvShowDetails> {
|
async details<T extends AppendToResponseTvKey[] | undefined>(
|
||||||
return await this.api.get<TvShowDetails>(`${BASE_TV}/${id}`);
|
id: number,
|
||||||
|
appendToResponse?: T
|
||||||
|
) {
|
||||||
|
const options = {
|
||||||
|
append_to_response: appendToResponse
|
||||||
|
? appendToResponse.join(',')
|
||||||
|
: undefined,
|
||||||
|
};
|
||||||
|
return await this.api.get<AppendToResponse<TvShowDetails, T, 'tvShow'>>(
|
||||||
|
`${BASE_TV}/${id}`,
|
||||||
|
options
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async alternativeTitles(id: number): Promise<AlternativeTitles> {
|
async alternativeTitles(id: number): Promise<AlternativeTitles> {
|
||||||
@@ -45,8 +60,11 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async changes(id: number, options?: ChangeOptions): Promise<TvShowChanges> {
|
async changes(
|
||||||
return await this.api.get<TvShowChanges>(
|
id: number,
|
||||||
|
options?: ChangeOption
|
||||||
|
): Promise<Changes<TvShowChangeValue>> {
|
||||||
|
return await this.api.get<Changes<TvShowChangeValue>>(
|
||||||
`${BASE_TV}/${id}/changes`,
|
`${BASE_TV}/${id}/changes`,
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
@@ -58,6 +76,12 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async aggregateCredits(id: number): Promise<AggregateCredits> {
|
||||||
|
return await this.api.get<AggregateCredits>(
|
||||||
|
`${BASE_TV}/${id}/aggregate_credits`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
async credits(id: number): Promise<Credits> {
|
async credits(id: number): Promise<Credits> {
|
||||||
return await this.api.get<Credits>(`${BASE_TV}/${id}/credits`);
|
return await this.api.get<Credits>(`${BASE_TV}/${id}/credits`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import TMDB from './tmdb';
|
import { TMDB } from './tmdb';
|
||||||
|
|
||||||
export * from './types';
|
export * from './types';
|
||||||
export * from './utils';
|
export * from './utils';
|
||||||
|
|
||||||
export default TMDB;
|
export { TMDB };
|
||||||
|
|||||||
22
src/tmdb.ts
22
src/tmdb.ts
@@ -15,9 +15,13 @@ import {
|
|||||||
FindEndpoint,
|
FindEndpoint,
|
||||||
KeywordsEndpoint,
|
KeywordsEndpoint,
|
||||||
CollectionsEndpoint,
|
CollectionsEndpoint,
|
||||||
|
TvSeasonsEndpoint,
|
||||||
|
TvEpisodesEndpoint,
|
||||||
} from './endpoints';
|
} from './endpoints';
|
||||||
|
import { CompaniesEndpoint } from './endpoints/companies';
|
||||||
|
import { NetworksEndpoint } from './endpoints/networks';
|
||||||
|
|
||||||
export default class TMDB {
|
export class TMDB {
|
||||||
private readonly accessToken: string;
|
private readonly accessToken: string;
|
||||||
|
|
||||||
constructor(accessToken: string) {
|
constructor(accessToken: string) {
|
||||||
@@ -44,6 +48,14 @@ export default class TMDB {
|
|||||||
return new CreditsEndpoint(this.accessToken);
|
return new CreditsEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get companies(): CompaniesEndpoint {
|
||||||
|
return new CompaniesEndpoint(this.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
get networks(): NetworksEndpoint {
|
||||||
|
return new NetworksEndpoint(this.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
get search(): SearchEndpoint {
|
get search(): SearchEndpoint {
|
||||||
return new SearchEndpoint(this.accessToken);
|
return new SearchEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
@@ -60,6 +72,10 @@ export default class TMDB {
|
|||||||
return new TvShowsEndpoint(this.accessToken);
|
return new TvShowsEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get tvEpisode(): TvEpisodesEndpoint {
|
||||||
|
return new TvEpisodesEndpoint(this.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
get discover(): DiscoverEndpoint {
|
get discover(): DiscoverEndpoint {
|
||||||
return new DiscoverEndpoint(this.accessToken);
|
return new DiscoverEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
@@ -87,4 +103,8 @@ export default class TMDB {
|
|||||||
get collections(): CollectionsEndpoint {
|
get collections(): CollectionsEndpoint {
|
||||||
return new CollectionsEndpoint(this.accessToken);
|
return new CollectionsEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get tvSeasons(): TvSeasonsEndpoint {
|
||||||
|
return new TvSeasonsEndpoint(this.accessToken);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,29 @@
|
|||||||
export interface Change {
|
export interface MediaChange {
|
||||||
id: number;
|
id: number;
|
||||||
adult: boolean | undefined;
|
adult: boolean | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Changes {
|
export interface MediaChanges {
|
||||||
results: Change[];
|
results: MediaChange[];
|
||||||
page: number;
|
page: number;
|
||||||
total_pages: number;
|
total_pages: number;
|
||||||
total_results: number;
|
total_results: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ChangeOptions {
|
export interface Changes<T> {
|
||||||
end_date?: string;
|
changes: Change<T>[];
|
||||||
start_date?: string;
|
}
|
||||||
page?: number;
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
33
src/types/companies.ts
Normal file
33
src/types/companies.ts
Normal 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[];
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
export interface Images {
|
export interface ImageConfiguration {
|
||||||
base_url: string;
|
base_url: string;
|
||||||
secure_base_url: string;
|
secure_base_url: string;
|
||||||
backdrop_sizes: BackdropSizes[];
|
backdrop_sizes: BackdropSizes[];
|
||||||
@@ -9,7 +9,7 @@ export interface Images {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Configuration {
|
export interface Configuration {
|
||||||
images: Images;
|
images: ImageConfiguration;
|
||||||
change_keys: ChangeKeys[];
|
change_keys: ChangeKeys[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,3 +101,49 @@ export interface Videos {
|
|||||||
id: number;
|
id: number;
|
||||||
results: Video[];
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
export * from './options';
|
export * from './options';
|
||||||
export * from './certification';
|
export * from './certification';
|
||||||
export * from './credits';
|
export * from './credits';
|
||||||
|
export * from './companies';
|
||||||
|
export * from './networks';
|
||||||
export * from './configuration';
|
export * from './configuration';
|
||||||
export * from './changes';
|
export * from './changes';
|
||||||
export * from './movies';
|
export * from './movies';
|
||||||
@@ -14,6 +16,10 @@ export * from './trending';
|
|||||||
export * from './find';
|
export * from './find';
|
||||||
export * from './keywords';
|
export * from './keywords';
|
||||||
export * from './collections';
|
export * from './collections';
|
||||||
|
export * from './tv-episode';
|
||||||
|
export * from './tv-seasons';
|
||||||
|
|
||||||
|
export type MediaType = 'movie' | 'tv' | 'person';
|
||||||
|
|
||||||
export interface AuthorDetails {
|
export interface AuthorDetails {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -22,23 +28,7 @@ export interface AuthorDetails {
|
|||||||
rating?: number;
|
rating?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface KnownFor {
|
export type KnownFor = MovieWithMediaType | TVWithMediaType;
|
||||||
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 interface Person {
|
export interface Person {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -51,6 +41,10 @@ export interface Person {
|
|||||||
popularity: number;
|
popularity: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PersonWithMediaType extends Person {
|
||||||
|
media_type: 'person';
|
||||||
|
}
|
||||||
|
|
||||||
export interface Movie {
|
export interface Movie {
|
||||||
id: number;
|
id: number;
|
||||||
poster_path: string;
|
poster_path: string;
|
||||||
@@ -68,6 +62,10 @@ export interface Movie {
|
|||||||
vote_average: number;
|
vote_average: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MovieWithMediaType extends Movie {
|
||||||
|
media_type: 'movie';
|
||||||
|
}
|
||||||
|
|
||||||
export interface Company {
|
export interface Company {
|
||||||
id: number;
|
id: number;
|
||||||
logo_path: string;
|
logo_path: string;
|
||||||
@@ -91,6 +89,10 @@ export interface TV {
|
|||||||
vote_average: number;
|
vote_average: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TVWithMediaType extends TV {
|
||||||
|
media_type: 'tv';
|
||||||
|
}
|
||||||
|
|
||||||
export interface Genre {
|
export interface Genre {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -128,6 +130,7 @@ export interface ContentRatings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ContentRatingsResult {
|
export interface ContentRatingsResult {
|
||||||
|
descriptor: unknown[];
|
||||||
iso_3166_1: string;
|
iso_3166_1: string;
|
||||||
rating: string;
|
rating: string;
|
||||||
}
|
}
|
||||||
@@ -202,3 +205,10 @@ export interface Image {
|
|||||||
vote_count: number;
|
vote_count: number;
|
||||||
width: number;
|
width: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Images {
|
||||||
|
id: number;
|
||||||
|
backdrops: Image[];
|
||||||
|
logos: Image[];
|
||||||
|
posters: Image[];
|
||||||
|
}
|
||||||
|
|||||||
@@ -94,24 +94,6 @@ export interface MovieLists {
|
|||||||
total_results: number;
|
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 {
|
export interface LatestMovie {
|
||||||
adult: boolean;
|
adult: boolean;
|
||||||
backdrop_path?: string;
|
backdrop_path?: string;
|
||||||
@@ -173,3 +155,14 @@ export interface UpcomingMovies {
|
|||||||
total_results: number;
|
total_results: number;
|
||||||
total_pages: 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
15
src/types/networks.ts
Normal 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[];
|
||||||
|
}
|
||||||
@@ -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 {
|
export interface LanguageOption {
|
||||||
language?: string;
|
language?: string;
|
||||||
}
|
}
|
||||||
@@ -9,3 +43,194 @@ export interface RegionOption {
|
|||||||
export interface PageOption {
|
export interface PageOption {
|
||||||
page?: number;
|
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);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Movie, Person, TV } from '.';
|
import { Image, Movie, Person, TV } from '.';
|
||||||
|
|
||||||
interface Cast {
|
interface Cast {
|
||||||
character: string;
|
character: string;
|
||||||
@@ -79,7 +79,7 @@ export interface PersonCombinedCredits {
|
|||||||
id: number;
|
id: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PersonDetail {
|
export interface PersonDetails {
|
||||||
birthday: string;
|
birthday: string;
|
||||||
known_for_department: string;
|
known_for_department: string;
|
||||||
deathday: string;
|
deathday: string;
|
||||||
@@ -96,22 +96,13 @@ export interface PersonDetail {
|
|||||||
homepage: string;
|
homepage: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PersonChange {
|
export type PersonChangeValue =
|
||||||
id: string;
|
| string
|
||||||
action: string;
|
| {
|
||||||
time: string;
|
profile: {
|
||||||
iso_639_1: string;
|
file_path: 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 interface PopularPersons {
|
export interface PopularPersons {
|
||||||
page: number;
|
page: number;
|
||||||
@@ -120,6 +111,11 @@ export interface PopularPersons {
|
|||||||
total_pages: number;
|
total_pages: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PeopleImages {
|
||||||
|
id: number;
|
||||||
|
profiles: Image[];
|
||||||
|
}
|
||||||
|
|
||||||
export interface TaggedImage {
|
export interface TaggedImage {
|
||||||
aspect_ratio: number;
|
aspect_ratio: number;
|
||||||
file_path: string;
|
file_path: string;
|
||||||
@@ -141,7 +137,7 @@ export interface TaggedImages {
|
|||||||
total_pages: number;
|
total_pages: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PeopleTranslations {
|
export interface PersonTranslations {
|
||||||
id: number;
|
id: number;
|
||||||
translations: {
|
translations: {
|
||||||
iso_3166_1: string;
|
iso_3166_1: string;
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
|
import { MovieWithMediaType, PersonWithMediaType, TVWithMediaType } from '.';
|
||||||
|
|
||||||
export interface Search<T> {
|
export interface Search<T> {
|
||||||
page: number;
|
page: number;
|
||||||
results: T[];
|
results: T[];
|
||||||
total_pages: number;
|
total_pages: number;
|
||||||
total_results: number;
|
total_results: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type MultiSearchResult =
|
||||||
|
| MovieWithMediaType
|
||||||
|
| TVWithMediaType
|
||||||
|
| PersonWithMediaType;
|
||||||
|
|||||||
@@ -1,19 +1,28 @@
|
|||||||
import { Movie, Person, TV } from '.';
|
import {
|
||||||
export type MediaType = 'all' | 'movie' | 'tv' | 'person';
|
Movie,
|
||||||
|
Person,
|
||||||
|
TV,
|
||||||
|
MediaType,
|
||||||
|
MovieWithMediaType,
|
||||||
|
TVWithMediaType,
|
||||||
|
PersonWithMediaType,
|
||||||
|
} from '.';
|
||||||
|
|
||||||
export type TimeWindow = 'day' | 'week';
|
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
|
? TV
|
||||||
: T extends 'movie'
|
: T extends 'movie'
|
||||||
? Movie
|
? Movie
|
||||||
: T extends 'person'
|
: T extends 'person'
|
||||||
? Person
|
? Person
|
||||||
: TV | Movie | Person;
|
: TVWithMediaType | MovieWithMediaType | PersonWithMediaType;
|
||||||
|
|
||||||
export interface TrendingResults<T extends MediaType> {
|
export interface TrendingResults<T extends TrendingMediaType> {
|
||||||
page: number;
|
page: number;
|
||||||
results: (TrendingResult<T> & { media_type: MediaType })[];
|
results: TrendingResult<T>[];
|
||||||
total_pages: number;
|
total_pages: number;
|
||||||
total_results: number;
|
total_results: number;
|
||||||
}
|
}
|
||||||
|
|||||||
58
src/types/tv-episode.ts
Normal file
58
src/types/tv-episode.ts
Normal 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
23
src/types/tv-seasons.ts
Normal 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;
|
||||||
|
};
|
||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
ProductionCompany,
|
ProductionCompany,
|
||||||
ProductionCountry,
|
ProductionCountry,
|
||||||
SpokenLanguage,
|
SpokenLanguage,
|
||||||
Crew,
|
Episode,
|
||||||
} from './';
|
} from './';
|
||||||
|
|
||||||
export interface CreatedBy {
|
export interface CreatedBy {
|
||||||
@@ -93,65 +93,6 @@ export interface TvShowDetails {
|
|||||||
vote_count: number;
|
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 {
|
export interface Network {
|
||||||
id: number;
|
id: number;
|
||||||
logo_path: string;
|
logo_path: string;
|
||||||
@@ -328,3 +269,8 @@ export interface TopRatedTvShows {
|
|||||||
total_results: number;
|
total_results: number;
|
||||||
total_pages: number;
|
total_pages: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TvShowChangeValue {
|
||||||
|
season_id: number;
|
||||||
|
season_number: number;
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
"strict": true /* Enable all strict type-checking options. */,
|
"strict": true /* Enable all strict type-checking options. */,
|
||||||
"types": ["node"],
|
"types": ["node"],
|
||||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
||||||
// "experimentalDecorators": true /* Enables experimental support for ES7 decorators. */,
|
|
||||||
// "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */,
|
|
||||||
"skipLibCheck": true /* Skip type checking of declaration files. */,
|
"skipLibCheck": true /* Skip type checking of declaration files. */,
|
||||||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
|
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
|
||||||
"typeRoots": ["./src/types"]
|
"typeRoots": ["./src/types"]
|
||||||
|
|||||||
Reference in New Issue
Block a user