1 Commits

Author SHA1 Message Date
Blake
77d3a6cea7 Create npm-publish.yml 2023-04-13 07:02:27 -04:00
62 changed files with 3695 additions and 3779 deletions

View File

@@ -1,3 +1,4 @@
dist
node_modules node_modules
.github dist
lib
coverage

43
.eslintrc.js Normal file
View File

@@ -0,0 +1,43 @@
module.exports = {
env: {
browser: false,
es2021: true,
},
extends: [
'plugin:@typescript-eslint/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 12,
sourceType: 'module',
},
plugins: [
'@typescript-eslint',
],
rules: {
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/explicit-function-return-type': ['warn', { allowExpressions: true }],
indent: 'off',
'@typescript-eslint/indent': ['error', 2],
'no-trailing-spaces': 'error',
quotes: ['error', 'single', { allowTemplateLiterals: true }],
semi: ['error', 'always'],
'spaced-comment': ['error', 'always'],
'no-irregular-whitespace': ['error', { 'skipComments': true }],
'space-infix-ops': 'error',
'array-bracket-spacing': 'error',
'object-curly-spacing': ['error', 'always'],
'space-before-function-paren': ['error', {
named: 'never',
anonymous: 'never',
asyncArrow: 'always',
}],
'comma-dangle': ['warn', 'always-multiline'],
'no-multiple-empty-lines': 'error',
},
};

View File

@@ -5,29 +5,29 @@ name: Node.js Package
on: on:
release: release:
types: [published] types: [created]
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-node@v4 - uses: actions/setup-node@v3
with: with:
node-version: '20.x' node-version: 16
- run: npm ci - run: npm ci
- run: npm test
publish-npm: publish-npm:
needs: build needs: build
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-node@v4 - uses: actions/setup-node@v3
with: with:
node-version: '20.x' node-version: 16
registry-url: https://registry.npmjs.org/ registry-url: https://registry.npmjs.org/
- run: npm ci - run: npm ci
- run: npm run compile - run: npm publish
- run: npm publish --provenance --access public
env: env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} NODE_AUTH_TOKEN: ${{secrets.npm_token}}

View File

@@ -1,4 +0,0 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npm run lint

1
.nvmrc
View File

@@ -1 +0,0 @@
v20.14.0

View File

@@ -1,12 +0,0 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"arrowParens": "always",
"proseWrap": "never",
"htmlWhitespaceSensitivity": "strict"
}

View File

@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2024 Blake Joynes Copyright (c) 2021 Blake Joynes
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@@ -14,10 +14,8 @@ 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');

View File

@@ -1,17 +0,0 @@
import globals from 'globals';
import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
export default [
{
files: ['src/*.ts'],
ignores: ['node_modules', 'dist', 'lib', 'coverage'],
languageOptions: {
globals: globals.browser,
},
},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
eslintPluginPrettierRecommended,
];

4594
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,15 @@
{ {
"name": "tmdb-ts", "name": "tmdb-ts",
"version": "2.0.1", "version": "0.1.8",
"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", "compile": "rm -rf dist && tsc -d && npm run copy-types",
"lint": "eslint src/", "lint": "eslint --ext .ts src/",
"lint:fix": "eslint --fix", "lint:fix": "eslint --ext .ts src/ --fix",
"format": "prettier --write src", "prepublish": "tsc",
"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",
@@ -29,27 +29,24 @@
"author": "Blake Joynes", "author": "Blake Joynes",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@eslint/js": "^9.4.0", "@types/node": "^15.3.0",
"@types/eslint__js": "^8.42.3", "@types/node-fetch": "^2.5.10",
"@types/node": "^20.14.2", "@typescript-eslint/eslint-plugin": "^4.23.0",
"@types/node-fetch": "^3.0.3", "@typescript-eslint/parser": "^4.23.0",
"dotenv": "^16.4.5", "dotenv": "^9.0.2",
"eslint-config-prettier": "^9.1.0", "eslint": "^7.26.0",
"eslint-plugin-prettier": "^5.1.3", "eslint-config-airbnb-base": "^14.2.1",
"globals": "^15.4.0", "eslint-plugin-import": "^2.23.1",
"husky": "^9.0.11", "ts-node": "^9.1.1",
"prettier": "^3.3.1", "typescript": "^4.2.4"
"ts-node": "^10.9.2",
"typescript": "^5.4.5",
"typescript-eslint": "^7.12.0"
}, },
"dependencies": { "dependencies": {
"cross-fetch": "^4.0.0" "cross-fetch": "^3.1.4"
}, },
"husky": { "volta": {
"hooks": { "node": "15.13.0",
"pre-commit": "npm run pre-commit" "yarn": "1.19.2",
} "npm": "7.12.1"
}, },
"files": [ "files": [
"dist" "dist"

View File

@@ -1,28 +1,20 @@
import fetch from 'cross-fetch'; import fetch from 'cross-fetch';
import { parseOptions } from './utils';
import { ErrorResponse } from './types';
import { BASE_URL_V3 } from './common/constants';
export class Api { const BASE_URL_V3 = 'https://api.themoviedb.org/3';
export default class Api {
constructor(private accessToken: string) { constructor(private accessToken: string) {
this.accessToken = accessToken; this.accessToken = accessToken;
} }
/* eslint-disable @typescript-eslint/no-explicit-any */ async get<T>(path: string): Promise<T> {
async get<T>(path: string, options?: Record<string, any>): Promise<T> { const response = await fetch(`${BASE_URL_V3}${path}`, {
const params = parseOptions(options);
const response = await fetch(`${BASE_URL_V3}${path}?${params}`, {
method: 'GET', method: 'GET',
headers: { headers: {
Authorization: `Bearer ${this.accessToken}`, Authorization: `Bearer ${this.accessToken}`,
'Content-Type': 'application/json;charset=utf-8', 'Content-Type': 'application/json;charset=utf-8',
}, },
}); });
return await response.json() as T;
if (!response.ok) {
return Promise.reject((await response.json()) as ErrorResponse);
}
return (await response.json()) as T;
} }
} }

View File

@@ -1 +0,0 @@
export const BASE_URL_V3 = 'https://api.themoviedb.org/3';

View File

@@ -1,12 +1,11 @@
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
import { AccountDetails } from '../types/account';
export class AccountEndpoint extends BaseEndpoint { export class AccountEndpoint extends BaseEndpoint {
constructor(accessToken: string) { constructor(accessToken: string) {
super(accessToken); super(accessToken);
} }
async details(): Promise<AccountDetails> { async details(): Promise<any> {
return await this.api.get('/account'); return await this.api.get('/account');
} }
} }

View File

@@ -1,4 +1,4 @@
import { Api } from '../api'; import Api from '../api';
export class BaseEndpoint { export class BaseEndpoint {
protected api: Api; protected api: Api;

View File

@@ -1,20 +1,25 @@
import { ChangeOption, MediaChanges } from '../types';
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
import { ChangeOptions, Changes } from '../types/changes';
import { parseOptions } from '../utils';
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?: ChangeOption): Promise<MediaChanges> { async movies(options?: ChangeOptions): Promise<Changes> {
return await this.api.get<MediaChanges>(`/movie/changes`, options); const params = parseOptions(options);
return await this.api.get<Changes>(`/movie/changes?${params}`);
} }
async tvShows(options?: ChangeOption): Promise<MediaChanges> { async tvShows(options?: ChangeOptions): Promise<Changes> {
return await this.api.get<MediaChanges>(`/tv/changes`, options); const params = parseOptions(options);
return await this.api.get<Changes>(`/tv/changes?${params}`);
} }
async person(options?: ChangeOption): Promise<MediaChanges> { async person(options?: ChangeOptions): Promise<Changes> {
return await this.api.get<MediaChanges>(`/person/changes`, options); const params = parseOptions(options);
return await this.api.get<Changes>(`/person/changes${params}`);
} }
} }

View File

@@ -1,10 +1,5 @@
import { import { DetailedCollection, ImageCollection, LanguageOption, Translations } from '../types';
CollectionDetails, import { parseOptions } from '../utils';
CollectionImageOptions,
ImageCollection,
LanguageOption,
Translations,
} from '../types';
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
const BASE_COLLECTION = '/collection'; const BASE_COLLECTION = '/collection';
@@ -14,37 +9,18 @@ export class CollectionsEndpoint extends BaseEndpoint {
super(accessToken); super(accessToken);
} }
async details( async details(id: number, options? : LanguageOption): Promise<DetailedCollection> {
id: number, const params = parseOptions(options);
options?: LanguageOption return await this.api.get<DetailedCollection>(`${BASE_COLLECTION}/${id}?${params}`);
): Promise<CollectionDetails> {
return await this.api.get<CollectionDetails>(
`${BASE_COLLECTION}/${id}`,
options
);
} }
async images( async images(id: number, options? : LanguageOption): Promise<ImageCollection> {
id: number, const params = parseOptions(options);
options?: CollectionImageOptions return await this.api.get<ImageCollection>(`${BASE_COLLECTION}/${id}/images?${params}`);
): 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`,
computedOptions
);
} }
async translations( async translations(id: number, options? : LanguageOption): Promise<Translations> {
id: number, const params = parseOptions(options);
options?: LanguageOption return await this.api.get<Translations>(`${BASE_COLLECTION}/${id}/translations?${params}`);
): Promise<Translations> {
return await this.api.get<Translations>(
`${BASE_COLLECTION}/${id}/translations`,
options
);
} }
} }

View File

@@ -1,26 +0,0 @@
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,44 +1,13 @@
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
import { import { Configuration } from '../types/configuration';
Configuration,
CountryConfiguration,
JobConfiguration,
LanguageConfiguration,
TimezoneConfiguration,
} from '../types/configuration';
export class ConfigurationEndpoint extends BaseEndpoint { export class ConfigurationEndpoint extends BaseEndpoint {
constructor(protected readonly accessToken: string) { constructor(protected readonly accessToken: string) {
super(accessToken); super(accessToken);
} }
async getApiConfiguration(): Promise<Configuration> { async getCurrent(): Promise<Configuration> {
return await this.api.get<Configuration>(`/configuration`); return await this.api.get<Configuration>(`/configuration`);
} }
async getCountries(): Promise<CountryConfiguration[]> {
return await this.api.get<CountryConfiguration[]>(
`/configuration/countries`
);
}
async getLanguages(): Promise<LanguageConfiguration[]> {
return await this.api.get<LanguageConfiguration[]>(
`/configuration/languages`
);
}
async getJobs(): Promise<JobConfiguration[]> {
return await this.api.get<JobConfiguration[]>(`/configuration/jobs`);
}
async getPrimaryTranslations(): Promise<string[]> {
return await this.api.get<string[]>(`/configuration/primary_translations`);
}
async getTimezones(): Promise<TimezoneConfiguration[]> {
return await this.api.get<TimezoneConfiguration[]>(
`/configuration/timezones`
);
}
} }

View File

@@ -1,6 +1,7 @@
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
import { CreditResponse } from '../types/credits'; import { CreditResponse } from '../types/credits';
export class CreditsEndpoint extends BaseEndpoint { export class CreditsEndpoint extends BaseEndpoint {
constructor(protected readonly accessToken: string) { constructor(protected readonly accessToken: string) {
super(accessToken); super(accessToken);
@@ -9,4 +10,5 @@ export class CreditsEndpoint extends BaseEndpoint {
async getById(id: string): Promise<CreditResponse> { async getById(id: string): Promise<CreditResponse> {
return await this.api.get<CreditResponse>(`/credit/${id}`); return await this.api.get<CreditResponse>(`/credit/${id}`);
} }
} }

View File

@@ -1,29 +1,77 @@
import { import { MovieDiscoverResult, SortOption, TvShowDiscoverResult } from '../types';
MovieDiscoverResult, import { parseOptions } from '../utils';
MovieQueryOptions,
TvShowDiscoverResult,
TvShowQueryOptions,
} from '../types';
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
const BASE_DISCOVER = '/discover'; const BASE_DISCOVER = '/discover';
interface DiscoverQueryOptions {
language?: string;
sort_by?: SortOption;
page?: number;
'vote_average.gte'?: number;
'vote_count.gte'?: number;
'vote_count.lte'?: number;
'vote_average.lte'?: number;
with_watch_providers?: string;
watch_region?: string;
without_companies?: string;
with_watch_monetization_types?: 'flatrate' | 'free' | 'ads' | 'rent' | 'buy';
'with_runtime.gte'?: number;
'with_runtime.lte'?: number;
with_genres?: string;
without_genres?: string;
with_original_language?: string;
without_keywords?: string;
with_keywords?: string;
with_companies?: string;
}
interface MovieQueryOptions extends DiscoverQueryOptions{
region?: string;
certification_country?: string;
certification?: string;
'certification.lte'?: string;
'certification.gte'?: string;
include_adult?: boolean;
include_video?: boolean;
primary_release_year?: number;
'primary_release_date.gte'?: string;
'primary_release_date.lte'?: string;
'release_date.gte'?: string;
'release_date.lte'?: string;
with_release_type?: string;
year?: number;
with_cast?: string;
with_crew?: string;
with_people?: string;
}
interface TvShowQueryOptions extends DiscoverQueryOptions{
'air_date.gte'?: string;
'air_date.lte'?: string;
'first_air_date.gte'?: string;
'first_air_date.lte'?: string;
first_air_date_year?: number;
timezone?: string;
with_networks?: string;
include_null_first_air_dates?: boolean;
screened_theatrically?: boolean;
with_status?: string;
with_type?: string;
}
export class DiscoverEndpoint extends BaseEndpoint { export class DiscoverEndpoint extends BaseEndpoint {
constructor(accessToken: string) { constructor(accessToken: string) {
super(accessToken); super(accessToken);
} }
async movie(options?: MovieQueryOptions): Promise<MovieDiscoverResult> { async movie(options?: MovieQueryOptions): Promise<MovieDiscoverResult> {
return await this.api.get<MovieDiscoverResult>( const params = parseOptions(options);
`${BASE_DISCOVER}/movie`, return await this.api.get<MovieDiscoverResult>(`${BASE_DISCOVER}/movie?${params}`);
options
);
} }
async tvShow(options?: TvShowQueryOptions): Promise<TvShowDiscoverResult> { async tvShow(options?: TvShowQueryOptions): Promise<TvShowDiscoverResult> {
return await this.api.get<TvShowDiscoverResult>( const params = parseOptions(options);
`${BASE_DISCOVER}/tv`, return await this.api.get<TvShowDiscoverResult>(`${BASE_DISCOVER}/tv?${params}`);
options
);
} }
} }

View File

@@ -1,15 +1,14 @@
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
import { ExternalIdOptions, FindResult } from '../types'; import { ExternalIdOptions, FindResult } from '../types';
import { parseOptions } from '../utils';
export class FindEndpoint extends BaseEndpoint { export class FindEndpoint extends BaseEndpoint {
constructor(accessToken: string) { constructor(accessToken: string) {
super(accessToken); super(accessToken);
} }
async byExternalId( async byId(externalId: string, options: ExternalIdOptions): Promise<FindResult> {
id: string, const params = parseOptions(options);
options: ExternalIdOptions return await this.api.get<FindResult>(`/find/${externalId}?${params}`);
): Promise<FindResult> {
return await this.api.get<FindResult>(`/find/${id}`, options);
} }
} }

View File

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

View File

@@ -1,3 +1,5 @@
export * from './account'; export * from './account';
export * from './certification'; export * from './certification';
export * from './changes'; export * from './changes';
@@ -14,6 +16,4 @@ 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';
export * from './watch-providers';

View File

@@ -1,5 +1,6 @@
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
import { BelongingMovies, Keyword, KeywordsOptions } from '../types'; import { BelongingMovies, Keyword, KeywordsOptions } from '../types';
import { parseOptions } from '../utils';
const BASE_Keyword = '/keyword'; const BASE_Keyword = '/keyword';
@@ -12,17 +13,8 @@ export class KeywordsEndpoint extends BaseEndpoint {
return await this.api.get<Keyword>(`${BASE_Keyword}/${keywordId}`); return await this.api.get<Keyword>(`${BASE_Keyword}/${keywordId}`);
} }
/** async belongingMovies(keywordId : number, options?: KeywordsOptions): Promise<BelongingMovies> {
* const params = parseOptions(options);
* @deprecated return await this.api.get<BelongingMovies>(`${BASE_Keyword}/${keywordId}/movies?${params}`);
*/
async belongingMovies(
keywordId: number,
options?: KeywordsOptions
): Promise<BelongingMovies> {
return await this.api.get<BelongingMovies>(
`${BASE_Keyword}/${keywordId}/movies`,
options
);
} }
} }

View File

@@ -1,17 +1,14 @@
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
import { import {
AlternativeTitles, AlternativeTitles,
AppendToResponse, ChangeOptions,
AppendToResponseMovieKey,
ChangeOption,
Changes,
Credits, Credits,
ExternalIds, ExternalIds,
Images, Images,
Keywords, Keywords,
LanguageOption, LanguageOption,
LatestMovie, LatestMovie,
MovieChangeValue, MovieChanges,
MovieDetails, MovieDetails,
MovieLists, MovieLists,
MoviesPlayingNow, MoviesPlayingNow,
@@ -22,133 +19,79 @@ import {
ReleaseDates, ReleaseDates,
Reviews, Reviews,
SimilarMovies, SimilarMovies,
TopRatedMovies, TopRatedMovies, Translations,
Translations,
UpcomingMovies, UpcomingMovies,
Videos, Videos,
WatchProviders, WatchProviders,
} from '../types'; } from '../types';
import { parseOptions } from '../utils';
const BASE_MOVIE = '/movie'; const BASE_MOVIE = '/movie';
export interface MoviesImageSearchOptions extends LanguageOption {
/**
* a list of ISO-639-1 values to query
*/
include_image_language?: string[];
}
export class MoviesEndpoint extends BaseEndpoint{ export class MoviesEndpoint extends BaseEndpoint{
constructor(protected readonly accessToken: string) { constructor(protected readonly accessToken: string) {
super(accessToken); super(accessToken);
} }
async details<T extends AppendToResponseMovieKey[] | undefined>( async details(id: number): Promise<MovieDetails>{
id: number, return await this.api.get<MovieDetails>(`${BASE_MOVIE}/${id}`);
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>{ async alternativeTitles(id: number): Promise<AlternativeTitles>{
return await this.api.get<AlternativeTitles>( return await this.api.get<AlternativeTitles>(`${BASE_MOVIE}/${id}/alternative_titles`);
`${BASE_MOVIE}/${id}/alternative_titles`
);
} }
async changes( async changes(id: number, options?: ChangeOptions): Promise<MovieChanges>{
id: number, const params = parseOptions(options);
options?: ChangeOption return await this.api.get<MovieChanges>(`${BASE_MOVIE}/${id}/changes?${params}`);
): Promise<Changes<MovieChangeValue>> {
return await this.api.get<Changes<MovieChangeValue>>(
`${BASE_MOVIE}/${id}/changes`,
options
);
} }
async credits(id: number, options?: LanguageOption): Promise<Credits> { async credits(id: number): Promise<Credits>{
return await this.api.get<Credits>(`${BASE_MOVIE}/${id}/credits`, options); return await this.api.get<Credits>(`${BASE_MOVIE}/${id}/credits`);
} }
async externalIds(id: number): Promise<ExternalIds>{ async externalIds(id: number): Promise<ExternalIds>{
return await this.api.get<ExternalIds>(`${BASE_MOVIE}/${id}/external_ids`); return await this.api.get<ExternalIds>(`${BASE_MOVIE}/${id}/external_ids`);
} }
async images( async images(id: number): Promise<Images>{
id: number, return await this.api.get<Images>(`${BASE_MOVIE}/${id}/images`);
options?: MoviesImageSearchOptions
): Promise<Images> {
const computedOptions = {
include_image_language: options?.include_image_language?.join(','),
language: options?.language,
};
return await this.api.get<Images>(
`${BASE_MOVIE}/${id}/images`,
computedOptions
);
} }
async keywords(id: number): Promise<Keywords>{ async keywords(id: number): Promise<Keywords>{
return await this.api.get<Keywords>(`${BASE_MOVIE}/${id}/keywords`); return await this.api.get<Keywords>(`${BASE_MOVIE}/${id}/keywords`);
} }
async lists( async lists(id: number, options?: LanguageOption | PageOption): Promise<MovieLists>{
id: number, const params = parseOptions(options);
options?: LanguageOption & PageOption return await this.api.get<MovieLists>(`${BASE_MOVIE}/${id}/lists?${params}`);
): Promise<MovieLists> {
return await this.api.get<MovieLists>(`${BASE_MOVIE}/${id}/lists`, options);
} }
async recommendations( async recommendations(id: number, options?: PageOption): Promise<Recommendations>{
id: number, const params = parseOptions(options);
options?: LanguageOption & PageOption return await this.api.get<Recommendations>(`${BASE_MOVIE}/${id}/recommendations?${params}`);
): Promise<Recommendations> {
return await this.api.get<Recommendations>(
`${BASE_MOVIE}/${id}/recommendations`,
options
);
} }
async releaseDates(id: number): Promise<ReleaseDates>{ async releaseDates(id: number): Promise<ReleaseDates>{
return await this.api.get<ReleaseDates>( return await this.api.get<ReleaseDates>(`${BASE_MOVIE}/${id}/release_dates`);
`${BASE_MOVIE}/${id}/release_dates`
);
} }
async reviews( async reviews(id: number, options?: PageOption): Promise<Reviews>{
id: number, const params = parseOptions(options);
options?: LanguageOption & PageOption return await this.api.get<Reviews>(`${BASE_MOVIE}/${id}/reviews?${params}`);
): Promise<Reviews> {
return await this.api.get<Reviews>(`${BASE_MOVIE}/${id}/reviews`, options);
} }
async similar( async similar(id: number, options?: PageOption): Promise<SimilarMovies>{
id: number, const params = parseOptions(options);
options?: LanguageOption & PageOption return await this.api.get<SimilarMovies>(`${BASE_MOVIE}/${id}/similar?${params}`);
): Promise<SimilarMovies> {
return await this.api.get<SimilarMovies>(
`${BASE_MOVIE}/${id}/similar`,
options
);
} }
async translations(id: number): Promise<Translations>{ async translations(id: number): Promise<Translations>{
return await this.api.get<Translations>(`${BASE_MOVIE}/${id}/translations`); return await this.api.get<Translations>(`${BASE_MOVIE}/${id}/translations`);
} }
async videos(id: number, options?: LanguageOption): Promise<Videos> { async videos(id: number): Promise<Videos>{
return await this.api.get<Videos>(`${BASE_MOVIE}/${id}/videos`, options); return await this.api.get<Videos>(`${BASE_MOVIE}/${id}/videos`);
} }
/** /**
@@ -156,43 +99,32 @@ export class MoviesEndpoint extends BaseEndpoint {
* @param id * @param id
*/ */
async watchProviders(id: number): Promise<WatchProviders>{ async watchProviders(id: number): Promise<WatchProviders>{
return await this.api.get<WatchProviders>( return await this.api.get<WatchProviders>(`${BASE_MOVIE}/${id}/watch/providers`);
`${BASE_MOVIE}/${id}/watch/providers`
);
} }
async latest(): Promise<LatestMovie>{ async latest(): Promise<LatestMovie>{
return await this.api.get<LatestMovie>(`${BASE_MOVIE}/latest`); return await this.api.get<LatestMovie>(`${BASE_MOVIE}/latest`);
} }
async nowPlaying( async nowPlaying(options?: PageOption & LanguageOption & RegionOption): Promise<MoviesPlayingNow>{
options?: PageOption & LanguageOption & RegionOption const params = parseOptions(options);
): Promise<MoviesPlayingNow> { return await this.api.get<MoviesPlayingNow>(`${BASE_MOVIE}/now_playing?${params}`);
return await this.api.get<MoviesPlayingNow>(
`${BASE_MOVIE}/now_playing`,
options
);
} }
async popular(options?: LanguageOption & PageOption): Promise<PopularMovies> { async popular(options?: PageOption): Promise<PopularMovies>{
return await this.api.get<PopularMovies>(`${BASE_MOVIE}/popular`, options); const params = parseOptions(options);
return await this.api.get<PopularMovies>(`${BASE_MOVIE}/popular?${params}`);
} }
async topRated( async topRated(options?: PageOption & LanguageOption & RegionOption): Promise<TopRatedMovies>{
options?: PageOption & LanguageOption & RegionOption const params = parseOptions(options);
): Promise<TopRatedMovies> { return await this.api.get<TopRatedMovies>(`${BASE_MOVIE}/top_rated?${params}`);
return await this.api.get<TopRatedMovies>(
`${BASE_MOVIE}/top_rated`,
options
);
} }
async upcoming( async upcoming(options?: PageOption & LanguageOption & RegionOption): Promise<UpcomingMovies>{
options?: PageOption & LanguageOption & RegionOption const params = parseOptions(options);
): Promise<UpcomingMovies> { return await this.api.get<UpcomingMovies>(`${BASE_MOVIE}/upcoming?${params}`);
return await this.api.get<UpcomingMovies>(
`${BASE_MOVIE}/upcoming`,
options
);
} }
} }

View File

@@ -1,23 +0,0 @@
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,21 +1,18 @@
import { import {
AppendToResponse, ChangeOptions,
AppendToResponsePersonKey,
ChangeOption,
ExternalIds, ExternalIds,
Image,
PageOption, PageOption,
PeopleImages, PeopleTranslations,
PersonTranslations, PersonChanges,
PersonCombinedCredits, PersonCombinedCredits,
PersonDetails, PersonDetail,
PersonMovieCredit, PersonMovieCredit,
PersonTvShowCredit, PersonTvShowCredit,
PopularPersons,
TaggedImages, TaggedImages,
Changes,
PersonChangeValue,
LanguageOption,
PopularPeople,
} from '../types'; } from '../types';
import { parseOptions } from '../utils';
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
const BASE_PERSON = '/person'; const BASE_PERSON = '/person';
@@ -25,92 +22,50 @@ export class PeopleEndpoint extends BaseEndpoint {
super(accessToken); super(accessToken);
} }
async details<T extends AppendToResponsePersonKey[] | undefined>( async details(id: number): Promise<PersonDetail> {
id: number, return await this.api.get<PersonDetail>(`${BASE_PERSON}/${id}`);
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( async changes(id: number, options? : ChangeOptions): Promise<PersonChanges> {
id: number, const params = parseOptions(options);
options?: ChangeOption return await this.api.get<PersonChanges>(`${BASE_PERSON}/${id}/changes?${params}`);
): Promise<Changes<PersonChangeValue>> {
return await this.api.get<Changes<PersonChangeValue>>(
`${BASE_PERSON}/${id}/changes`,
options
);
} }
async movieCredits( async movieCredits(id: number): Promise<PersonMovieCredit> {
id: number, return await this.api.get<PersonMovieCredit>(`${BASE_PERSON}/${id}/movie_credits`);
options?: LanguageOption
): Promise<PersonMovieCredit> {
return await this.api.get<PersonMovieCredit>(
`${BASE_PERSON}/${id}/movie_credits`,
options
);
} }
async tvShowCredits( async tvShowCredits(id: number): Promise<PersonTvShowCredit> {
id: number, return await this.api.get<PersonTvShowCredit>(`${BASE_PERSON}/${id}/tv_credits`);
options?: LanguageOption
): Promise<PersonTvShowCredit> {
return await this.api.get<PersonTvShowCredit>(
`${BASE_PERSON}/${id}/tv_credits`,
options
);
} }
async combinedCredits( async combinedCredits(id: number) : Promise<PersonCombinedCredits> {
id: number, return await this.api.get<PersonCombinedCredits>(`${BASE_PERSON}/${id}/combined_credits`);
options?: LanguageOption
): Promise<PersonCombinedCredits> {
return await this.api.get<PersonCombinedCredits>(
`${BASE_PERSON}/${id}/combined_credits`,
options
);
} }
async externalId(id: number): Promise<ExternalIds>{ async externalId(id: number): Promise<ExternalIds>{
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<PeopleImages> { async images(id: number): Promise<{id: number, profiles: Image[]}>{
return await this.api.get<PeopleImages>(`${BASE_PERSON}/${id}/images`); return await this.api.get<{id: number, profiles: Image[]}>(`${BASE_PERSON}/${id}/images`);
} }
/**
* @deprecated
*/
async taggedImages(id: number, options?: PageOption): Promise<TaggedImages>{ async taggedImages(id: number, options?: PageOption): Promise<TaggedImages>{
return await this.api.get<TaggedImages>( const params = parseOptions(options);
`${BASE_PERSON}/${id}/tagged_images`, return await this.api.get<TaggedImages>(`${BASE_PERSON}/${id}/tagged_images?${params}`);
options
);
} }
async translation(id: number): Promise<PersonTranslations> { async translation(id: number) : Promise<PeopleTranslations>{
return await this.api.get<PersonTranslations>( return await this.api.get<PeopleTranslations>(`${BASE_PERSON}/${id}/translations`);
`${BASE_PERSON}/${id}/translations`
);
} }
async latest(): Promise<PersonDetails> { async latest(): Promise<PersonDetail>{
return await this.api.get<PersonDetails>(`${BASE_PERSON}/latest`); return await this.api.get<PersonDetail>(`${BASE_PERSON}/latest`);
} }
async popular(options?: LanguageOption & PageOption): Promise<PopularPeople> { async popular(options?: PageOption): Promise<PopularPersons>{
return await this.api.get<PopularPeople>(`${BASE_PERSON}/popular`, options); const params = parseOptions(options);
return await this.api.get<PopularPersons>(`${BASE_PERSON}/popular?${params}`);
} }
} }

View File

@@ -1,15 +1,7 @@
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
import { MultiSearchResult, Search } from '../types/search'; import { Search } from '../types/search';
import { import { Collection, Company, Movie, Person, TV } from '../types';
Collection, import { parseOptions } from '../utils';
Company,
LanguageOption,
Movie,
PageOption,
Person,
RegionOption,
TV,
} from '../types';
const BASE_SEARCH = '/search'; const BASE_SEARCH = '/search';
@@ -18,44 +10,18 @@ export interface SearchOptions {
page?: number; page?: number;
} }
export interface MovieSearchOptions export interface MovieSearchOptions extends SearchOptions {
extends SearchOptions,
LanguageOption,
PageOption,
RegionOption {
include_adult?: boolean; include_adult?: boolean;
year?: number; year?: number;
primary_release_year?: number; primary_release_year?: number;
} }
export interface CollectionSearchOptions export interface TvSearchOptions extends SearchOptions{
extends SearchOptions,
LanguageOption,
PageOption,
RegionOption {
include_adult?: boolean; include_adult?: boolean;
}
export interface TvSearchOptions
extends SearchOptions,
LanguageOption,
PageOption {
include_adult?: boolean;
year?: number;
first_air_date_year?: number; first_air_date_year?: number;
} }
export interface PeopleSearchOptions export interface PeopleSearchOptions extends SearchOptions{
extends SearchOptions,
LanguageOption,
PageOption {
include_adult?: boolean;
}
export interface MultiSearchOptions
extends SearchOptions,
LanguageOption,
PageOption {
include_adult?: boolean; include_adult?: boolean;
} }
@@ -65,44 +31,34 @@ export class SearchEndpoint extends BaseEndpoint {
} }
async companies(options: SearchOptions): Promise<Search<Company>>{ async companies(options: SearchOptions): Promise<Search<Company>>{
return await this.api.get<Search<Company>>( const params = parseOptions(options);
`${BASE_SEARCH}/company`, return await this.api.get<Search<Company>>(`${BASE_SEARCH}/company?${params}`);
options
);
} }
async collections(options: SearchOptions): Promise<Search<Collection>>{ async collections(options: SearchOptions): Promise<Search<Collection>>{
return await this.api.get<Search<Collection>>( const params = parseOptions(options);
`${BASE_SEARCH}/collection`, return await this.api.get<Search<Collection>>(`${BASE_SEARCH}/collection?${params}`);
options
);
} }
async keywords( async keywords(options: SearchOptions): Promise<Search<{ id: string, name: string }>>{
options: SearchOptions const params = parseOptions(options);
): Promise<Search<{ id: string; name: string }>> { return await this.api.get<Search<{ id: string, name: string }>>(`${BASE_SEARCH}/keyword?${params}`);
return await this.api.get<Search<{ id: string; name: string }>>(
`${BASE_SEARCH}/keyword`,
options
);
} }
async movies(options: MovieSearchOptions): Promise<Search<Movie>>{ async movies(options: MovieSearchOptions): Promise<Search<Movie>>{
return await this.api.get<Search<Movie>>(`${BASE_SEARCH}/movie`, options); const params = parseOptions(options);
return await this.api.get<Search<Movie>>(`${BASE_SEARCH}/movie?${params}`);
} }
async people(options: PeopleSearchOptions): Promise<Search<Person>>{ async people(options: PeopleSearchOptions): Promise<Search<Person>>{
return await this.api.get<Search<Person>>(`${BASE_SEARCH}/person`, options); const params = parseOptions(options);
return await this.api.get<Search<Person>>(`${BASE_SEARCH}/person?${params}`);
} }
// 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); const params = parseOptions(options);
} return await this.api.get<Search<TV>>(`${BASE_SEARCH}/tv?${params}`);
async multi(options: MultiSearchOptions): Promise<Search<MultiSearchResult>> {
return await this.api.get<Search<MultiSearchResult>>(
`${BASE_SEARCH}/multi`,
options
);
} }
} }

View File

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

View File

@@ -1,111 +0,0 @@
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
);
}
}

View File

@@ -1,131 +0,0 @@
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,11 +1,7 @@
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
import { import {
AggregateCredits,
AlternativeTitles, AlternativeTitles,
AppendToResponse, ChangeOptions,
AppendToResponseTvKey,
ChangeOption,
Changes,
ContentRatings, ContentRatings,
Credits, Credits,
EpisodeGroups, EpisodeGroups,
@@ -18,21 +14,20 @@ import {
PageOption, PageOption,
PopularTvShows, PopularTvShows,
Recommendations, Recommendations,
RegionOption,
Reviews, Reviews,
ScreenedTheatrically, ScreenedTheatrically,
SeasonDetails, SeasonDetails,
SimilarTvShows, SimilarTvShows,
TimezoneOption,
TopRatedTvShows, TopRatedTvShows,
Translations, Translations,
TvShowImageOptions, TvShowChanges,
TvShowVideoOptions,
TvShowChangeValue,
TvShowDetails, TvShowDetails,
TvShowsAiringToday, TvShowsAiringToday,
Videos, Videos,
WatchProviders, WatchProviders,
} from '../types'; } from '../types';
import { parseOptions } from '../utils';
const BASE_TV = '/tv'; const BASE_TV = '/tv';
@@ -41,63 +36,29 @@ export class TvShowsEndpoint extends BaseEndpoint {
super(accessToken); super(accessToken);
} }
async details<T extends AppendToResponseTvKey[] | undefined>( async details(id: number): Promise<TvShowDetails>{
id: number, return await this.api.get<TvShowDetails>(`${BASE_TV}/${id}`);
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>{ async alternativeTitles(id: number): Promise<AlternativeTitles>{
return await this.api.get<AlternativeTitles>( return await this.api.get<AlternativeTitles>(`${BASE_TV}/${id}/alternative_titles`);
`${BASE_TV}/${id}/alternative_titles`
);
} }
async changes( async changes(id: number, options?: ChangeOptions): Promise<TvShowChanges>{
id: number, const params = parseOptions(options);
options?: ChangeOption return await this.api.get<TvShowChanges>(`${BASE_TV}/${id}/changes?${params}`);
): Promise<Changes<TvShowChangeValue>> {
return await this.api.get<Changes<TvShowChangeValue>>(
`${BASE_TV}/${id}/changes`,
options
);
} }
async contentRatings(id: number): Promise<ContentRatings>{ async contentRatings(id: number): Promise<ContentRatings>{
return await this.api.get<ContentRatings>( return await this.api.get<ContentRatings>(`${BASE_TV}/${id}/content_ratings`);
`${BASE_TV}/${id}/content_ratings`
);
} }
async aggregateCredits( async credits(id: number): Promise<Credits>{
id: number, return await this.api.get<Credits>(`${BASE_TV}/${id}/credits`);
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>{ async season(tvId: number, seasonNumber: number): Promise<SeasonDetails>{
return await this.api.get<SeasonDetails>( return await this.api.get<SeasonDetails>(`${BASE_TV}/${tvId}/season/${seasonNumber}`);
`${BASE_TV}/${tvId}/season/${seasonNumber}`
);
} }
async episodeGroups(id: number): Promise<EpisodeGroups>{ async episodeGroups(id: number): Promise<EpisodeGroups>{
@@ -108,67 +69,39 @@ export class TvShowsEndpoint extends BaseEndpoint {
return await this.api.get<ExternalIds>(`${BASE_TV}/${id}/external_ids`); return await this.api.get<ExternalIds>(`${BASE_TV}/${id}/external_ids`);
} }
async images(id: number, options?: TvShowImageOptions): Promise<Images> { async images(id: number): Promise<Images>{
const computedOptions = { return await this.api.get<Images>(`${BASE_TV}/${id}/images`);
include_image_language: options?.include_image_language?.join(','),
language: options?.language,
};
return await this.api.get<Images>(
`${BASE_TV}/${id}/images`,
computedOptions
);
} }
async keywords(id: number): Promise<Keywords>{ async keywords(id: number): Promise<Keywords>{
return await this.api.get<Keywords>(`${BASE_TV}/${id}/keywords`); return await this.api.get<Keywords>(`${BASE_TV}/${id}/keywords`);
} }
async recommendations( async recommendations(id: number, options?: PageOption): Promise<Recommendations>{
id: number, const params = parseOptions(options);
options?: LanguageOption & PageOption return await this.api.get<Recommendations>(`${BASE_TV}/${id}/recommendations?${params}`);
): Promise<Recommendations> {
return await this.api.get<Recommendations>(
`${BASE_TV}/${id}/recommendations`,
options
);
} }
async reviews( async reviews(id: number, options?: PageOption): Promise<Reviews>{
id: number, const params = parseOptions(options);
options?: LanguageOption & PageOption return await this.api.get<Reviews>(`${BASE_TV}/${id}/reviews?${params}`);
): Promise<Reviews> {
return await this.api.get<Reviews>(`${BASE_TV}/${id}/reviews`, options);
} }
async screenedTheatrically(id: number): Promise<ScreenedTheatrically>{ async screenedTheatrically(id: number): Promise<ScreenedTheatrically>{
return await this.api.get<ScreenedTheatrically>( return await this.api.get<ScreenedTheatrically>(`${BASE_TV}/${id}/screened_theatrically`);
`${BASE_TV}/${id}/screened_theatrically`
);
} }
async similar( async similar(id: number, options?: PageOption): Promise<SimilarTvShows>{
id: number, const params = parseOptions(options);
options?: LanguageOption & PageOption return await this.api.get<SimilarTvShows>(`${BASE_TV}/${id}/similar?${params}`);
): Promise<SimilarTvShows> {
return await this.api.get<SimilarTvShows>(
`${BASE_TV}/${id}/similar`,
options
);
} }
async translations(id: number): Promise<Translations>{ async translations(id: number): Promise<Translations>{
return await this.api.get<Translations>(`${BASE_TV}/${id}/translations`); return await this.api.get<Translations>(`${BASE_TV}/${id}/translations`);
} }
async videos(id: number, options?: TvShowVideoOptions): Promise<Videos> { async videos(id: number): Promise<Videos>{
const computedOptions = { return await this.api.get<Videos>(`${BASE_TV}/${id}/videos`);
include_video_language: options?.include_video_language?.join(','),
language: options?.language,
};
return await this.api.get<Videos>(
`${BASE_TV}/${id}/videos`,
computedOptions
);
} }
/** /**
@@ -176,39 +109,29 @@ export class TvShowsEndpoint extends BaseEndpoint {
* @param id * @param id
*/ */
async watchProviders(id: number): Promise<WatchProviders>{ async watchProviders(id: number): Promise<WatchProviders>{
return await this.api.get<WatchProviders>( return await this.api.get<WatchProviders>(`${BASE_TV}/${id}/watch/providers`);
`${BASE_TV}/${id}/watch/providers`
);
} }
async latest(): Promise<LatestTvShows>{ async latest(): Promise<LatestTvShows>{
return await this.api.get<LatestTvShows>(`${BASE_TV}/latest`); return await this.api.get<LatestTvShows>(`${BASE_TV}/latest`);
} }
async onTheAir( async onTheAir(): Promise<OnTheAir>{
options?: PageOption & LanguageOption & TimezoneOption return await this.api.get<OnTheAir>(`${BASE_TV}/on_the_air`);
): Promise<OnTheAir> {
return await this.api.get<OnTheAir>(`${BASE_TV}/on_the_air`, options);
} }
async airingToday( async airingToday(options?: PageOption & LanguageOption & RegionOption): Promise<TvShowsAiringToday>{
options?: PageOption & LanguageOption & TimezoneOption const params = parseOptions(options);
): Promise<TvShowsAiringToday> { return await this.api.get<TvShowsAiringToday>(`${BASE_TV}/airing_today?${params}`);
return await this.api.get<TvShowsAiringToday>(
`${BASE_TV}/airing_today`,
options
);
} }
async popular( async popular(options?: PageOption & LanguageOption & RegionOption): Promise<PopularTvShows>{
options?: PageOption & LanguageOption const params = parseOptions(options);
): Promise<PopularTvShows> { return await this.api.get<PopularTvShows>(`${BASE_TV}/popular?${params}`);
return await this.api.get<PopularTvShows>(`${BASE_TV}/popular`, options);
} }
async topRated( async topRated(options?: PageOption & LanguageOption & RegionOption): Promise<TopRatedTvShows>{
options?: PageOption & LanguageOption const params = parseOptions(options);
): Promise<TopRatedTvShows> { return await this.api.get<TopRatedTvShows>(`${BASE_TV}/top_rated?${params}`);
return await this.api.get<TopRatedTvShows>(`${BASE_TV}/top_rated`, options);
} }
} }

View File

@@ -1,40 +0,0 @@
import { BaseEndpoint } from './base';
import {
LanguageOption,
RegionResult,
WatchProviderResult,
WatchRegionOption,
} from '../types';
type ProviderOptions = WatchRegionOption & LanguageOption;
export class WatchProvidersEndpoint extends BaseEndpoint {
constructor(protected readonly accessToken: string) {
super(accessToken);
}
async getRegions(options?: LanguageOption): Promise<RegionResult> {
return await this.api.get<RegionResult>(
`/watch/providers/regions`,
options
);
}
async getMovieProviders(
options?: ProviderOptions
): Promise<WatchProviderResult> {
return await this.api.get<WatchProviderResult>(
`/watch/providers/movie`,
options
);
}
async getTvProviders(
options?: ProviderOptions
): Promise<WatchProviderResult> {
return await this.api.get<WatchProviderResult>(
`/watch/providers/tv`,
options
);
}
}

View File

@@ -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 { TMDB }; export default TMDB;

View File

@@ -15,14 +15,9 @@ import {
FindEndpoint, FindEndpoint,
KeywordsEndpoint, KeywordsEndpoint,
CollectionsEndpoint, CollectionsEndpoint,
TvSeasonsEndpoint,
TvEpisodesEndpoint,
WatchProvidersEndpoint,
} from './endpoints'; } from './endpoints';
import { CompaniesEndpoint } from './endpoints/companies';
import { NetworksEndpoint } from './endpoints/networks';
export class TMDB { export default class TMDB {
private readonly accessToken: string; private readonly accessToken: string;
constructor(accessToken: string) { constructor(accessToken: string) {
@@ -49,14 +44,6 @@ export 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);
} }
@@ -73,10 +60,6 @@ export 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);
} }
@@ -104,12 +87,4 @@ export 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);
}
get watchProviders(): WatchProvidersEndpoint {
return new WatchProvidersEndpoint(this.accessToken);
}
} }

View File

@@ -1,19 +0,0 @@
import { CountryCode } from '../types';
export interface Gravatar {
hash: string;
}
export interface Avatar {
gravatar: Gravatar;
}
export interface AccountDetails {
avatar: Avatar;
id: number;
include_adult: boolean;
iso_3166_1: CountryCode;
iso_639_1: string;
name: string;
username: string;
}

View File

@@ -6,56 +6,14 @@ export interface Certification {
export interface Certifications { export interface Certifications {
certifications: { certifications: {
AR: Certification[]; US: Certification[],
AT: Certification[]; CA: Certification[],
AU: Certification[]; DE: Certification[],
BG: Certification[]; GB: Certification[],
BR: Certification[]; AU: Certification[],
CA: Certification[]; BR: Certification[],
'CA-QC': Certification[]; FR: Certification[],
CH: Certification[]; NZ: Certification[],
CL: Certification[]; IN: Certification[],
CZ: Certification[]; }
DE: Certification[];
DK: Certification[];
ES: Certification[];
FI: Certification[];
FR: Certification[];
GB: Certification[];
GR: Certification[];
HK: Certification[];
HU: Certification[];
ID: Certification[];
IE: Certification[];
IL: Certification[];
IN: Certification[];
IT: Certification[];
JP: Certification[];
KR: Certification[];
LT: Certification[];
LU: Certification[];
LV: Certification[];
MO: Certification[];
MX: Certification[];
MY: Certification[];
NL: Certification[];
NO: Certification[];
NZ: Certification[];
PH: Certification[];
PL: Certification[];
PR: Certification[];
PT: Certification[];
RO: Certification[];
RU: Certification[];
SE: Certification[];
SG: Certification[];
SK: Certification[];
TH: Certification[];
TR: Certification[];
TW: Certification[];
UA: Certification[];
US: Certification[];
VI: Certification[];
ZA: Certification[];
};
} }

View File

@@ -1,29 +1,17 @@
export interface MediaChange { export interface Change {
id: number; id: number;
adult?: boolean; adult: boolean | undefined;
} }
export interface MediaChanges { export interface Changes{
results: MediaChange[]; results: Change[];
page: number; page: number;
total_pages: number; total_pages: number;
total_results: number; total_results: number;
} }
export interface Changes<T> { export interface ChangeOptions {
changes: Change<T>[]; end_date?: string;
} 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;
} }

View File

@@ -1,20 +1,16 @@
import { LanguageOption, Movie } from '.'; import { Movie } from '.';
export interface Collection { export interface Collection {
id: number; id: number;
name: string;
overview: string;
poster_path: string;
backdrop_path: string; backdrop_path: string;
name: string;
poster_path: string;
adult: boolean;
original_language: string;
original_name: string;
overview: string;
} }
export interface CollectionDetails extends Collection { export interface DetailedCollection extends Collection {
parts: Movie[]; parts: Movie[]
}
export interface CollectionImageOptions extends LanguageOption {
/**
* a list of ISO-639-1 values to query
*/
include_image_language?: string[];
} }

View File

@@ -1,33 +0,0 @@
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,6 +1,5 @@
import { CountryCode } from '../types';
export interface ImageConfiguration { export interface Images {
base_url: string; base_url: string;
secure_base_url: string; secure_base_url: string;
backdrop_sizes: BackdropSizes[]; backdrop_sizes: BackdropSizes[];
@@ -11,157 +10,105 @@ export interface ImageConfiguration {
} }
export interface Configuration { export interface Configuration {
images: ImageConfiguration; images: Images;
change_keys: ChangeKeys[]; change_keys: ChangeKeys[];
} }
export interface CountryConfiguration {
iso_3166_1: CountryCode; export const enum BackdropSizes {
english_name: string; W300 = 'w300',
native_name: string; W780 = 'w780',
W1280 = 'w1280',
ORIGINAL = 'original'
} }
export interface LanguageConfiguration { export const enum LogoSizes {
iso_639_1: string; W45= 'w45',
english_name: string; W92= 'w92',
name: string; W154= 'w154',
W185= 'w185',
W300 = 'w300',
W500 = 'w500',
ORIGINAL = 'original'
} }
export interface JobConfiguration { export const enum PosterSizes {
department: string; W92= 'w92',
jobs: string[]; W154= 'w154',
W185='w185',
W300 = 'w300',
W500 = 'w500',
W780 = 'w780',
ORIGINAL = 'original'
} }
export interface TimezoneConfiguration { export const enum ProfileSizes {
iso_3166_1: CountryCode; W45 = 'w45',
zones: string[]; W185 = 'w185',
W632 = 'w632',
ORIGINAL = 'original'
} }
export const MediaSize = {
W45: 'w45',
W92: 'w92',
W154: 'w154',
W185: 'w185',
W300: 'w300',
W342: 'w342',
W500: 'w500',
W632: 'w632',
W780: 'w780',
W1280: 'w1280',
ORIGINAL: 'original',
} as const;
export const BackdropSize = { export const enum StillSizes {
W45: 'w45', W92= 'w92',
W92: 'w92', W185 = 'w185',
W154: 'w154', W300 = 'w300',
W185: 'w185', ORIGINAL = 'original'
W300: 'w300', }
W500: 'w500',
W780: 'w780',
W1280: 'w1280',
ORIGINAL: 'original',
} as const;
type BackdropSizes = (typeof BackdropSize)[keyof typeof BackdropSize]; export const enum ChangeKeys {
ADULT = 'adult',
export const LogoSize = { AIR_DATE = 'air_date',
W45: 'w45', ALSO_KNOWN_AS = 'also_known_as',
W92: 'w92', ALTERNATIVE_TITLES = 'alternative_titles',
W154: 'w154', BIOGRAPHY = 'biography',
W185: 'w185', BIRTHDAY = 'birthday',
W300: 'w300', BUDGET = 'budget',
W500: 'w500', CAST = 'cast',
ORIGINAL: 'original', CERTIFICATIONS = 'certifications',
} as const; CHARACTER_NAMES = 'character_names',
CREATED_BY = 'created_by',
type LogoSizes = (typeof LogoSize)[keyof typeof LogoSize]; CREW = 'crew',
DEATHDAY = 'deathday',
export const PosterSize = { EPISODE = 'episode',
W92: 'w92', EPISODE_NUMBER = 'episode_number',
W154: 'w154', EPISODE_RUN_TIME = 'episode_run_time',
W185: 'w185', FREEBASE_ID = 'freebase_id',
W300: 'w300', FREEBASE_MID = 'freebase_mid',
W342: 'w342', GENERAL = 'general',
W500: 'w500', GENRES = 'genres',
W780: 'w780', GUEST_STARS = 'guest_stars',
ORIGINAL: 'original', HOMEPAGE = 'homepage',
} as const; IMAGES = 'images',
IMDB_ID = 'imdb_id',
type PosterSizes = (typeof PosterSize)[keyof typeof PosterSize]; LANGUAGES = 'languages',
NAME = 'name',
export const ProfileSize = { NETWORK = 'network',
W45: 'w45', ORIGIN_COUNTRY = 'origin_country',
W185: 'w185', ORIGINAL_NAME = 'original_name',
W632: 'w632', ORIGINAL_TITLE = 'original_title',
ORIGINAL: 'original', OVERVIEW = 'overview',
} as const; PARTS = 'parts',
PLACE_OF_BIRTH = 'place_of_birth',
type ProfileSizes = (typeof ProfileSize)[keyof typeof ProfileSize]; PLOT_KEYWORDS = 'plot_keywords',
PRODUCTION_CODE = 'production_code',
export const StillSize = { PRODUCTION_COMPANIES = 'production_companies',
W92: 'w92', PRODUCTION_COUNTRIES = 'production_countries',
W185: 'w185', RELEASES = 'releases',
W300: 'w300', REVENUE = 'revenue',
ORIGINAL: 'original', RUNTIME = 'runtime',
} as const; SEASON = 'season',
SEASON_NUMBER = 'season_number',
type StillSizes = (typeof StillSize)[keyof typeof StillSize]; SEASON_REGULAR = 'season_regular',
SPOKEN_LANGUAGES = 'spoken_languages',
export const ChangeKey = { STATUS = 'status',
ADULT: 'adult', TAGLINE = 'tagline',
AIR_DATE: 'air_date', TITLE = 'title',
ALSO_KNOWN_AS: 'also_known_as', TRANSLATIONS = 'translations',
ALTERNATIVE_TITLES: 'alternative_titles', TVDB_ID = 'tvdb_id',
BIOGRAPHY: 'biography', TVRAGE_ID = 'tvrage_id',
BIRTHDAY: 'birthday', TYPE = 'type',
BUDGET: 'budget', VIDEO = 'video',
CAST: 'cast', VIDEOS = 'videos'
CERTIFICATIONS: 'certifications', }
CHARACTER_NAMES: 'character_names',
CREATED_BY: 'created_by',
CREW: 'crew',
DEATHDAY: 'deathday',
EPISODE: 'episode',
EPISODE_NUMBER: 'episode_number',
EPISODE_RUN_TIME: 'episode_run_time',
FREEBASE_ID: 'freebase_id',
FREEBASE_MID: 'freebase_mid',
GENERAL: 'general',
GENRES: 'genres',
GUEST_STARS: 'guest_stars',
HOMEPAGE: 'homepage',
IMAGES: 'images',
IMDB_ID: 'imdb_id',
LANGUAGES: 'languages',
NAME: 'name',
NETWORK: 'network',
ORIGIN_COUNTRY: 'origin_country',
ORIGINAL_NAME: 'original_name',
ORIGINAL_TITLE: 'original_title',
OVERVIEW: 'overview',
PARTS: 'parts',
PLACE_OF_BIRTH: 'place_of_birth',
PLOT_KEYWORDS: 'plot_keywords',
PRODUCTION_CODE: 'production_code',
PRODUCTION_COMPANIES: 'production_companies',
PRODUCTION_COUNTRIES: 'production_countries',
RELEASES: 'releases',
REVENUE: 'revenue',
RUNTIME: 'runtime',
SEASON: 'season',
SEASON_NUMBER: 'season_number',
SEASON_REGULAR: 'season_regular',
SPOKEN_LANGUAGES: 'spoken_languages',
STATUS: 'status',
TAGLINE: 'tagline',
TITLE: 'title',
TRANSLATIONS: 'translations',
TVDB_ID: 'tvdb_id',
TVRAGE_ID: 'tvrage_id',
TYPE: 'type',
VIDEO: 'video',
VIDEOS: 'videos',
} as const;
type ChangeKeys = (typeof ChangeKey)[keyof typeof ChangeKey];

View File

@@ -1,4 +1,4 @@
import { CountryCode, Image, Person } from './'; import { Image, Person } from './';
export interface CreditSeason { export interface CreditSeason {
air_date?: string; air_date?: string;
@@ -6,8 +6,9 @@ export interface CreditSeason {
season_number?: number; season_number?: number;
} }
export interface Media{ export interface Media{
id?: number; i?: number;
name?:string; name?:string;
first_air_date?: string; first_air_date?: string;
vote_count?: number; vote_count?: number;
@@ -15,8 +16,6 @@ export interface Media {
vote_average?: number; vote_average?: number;
backdrop_path?: string; backdrop_path?: string;
genre_ids?: number[]; genre_ids?: number[];
media_type: string;
adult: boolean;
original_name?: string; original_name?: string;
origin_country?: string[]; origin_country?: string[];
poster_path?: string; poster_path?: string;
@@ -38,7 +37,7 @@ export interface CreditResponse {
} }
export interface Title { export interface Title {
iso_3166_1: CountryCode; iso_3166_1: string;
title: string; title: string;
type: string; type: string;
} }
@@ -88,10 +87,12 @@ export interface ImageCollection {
backdrops: Image[]; backdrops: Image[];
posters: Image[]; posters: Image[];
} }
export interface Video { export interface Video {
id: string; id: string;
iso_639_1: string; iso_639_1: string;
iso_3166_1: CountryCode; iso_3166_1: string;
key: string; key: string;
name: string; name: string;
site: string; site: string;
@@ -103,49 +104,3 @@ 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;
}

View File

@@ -1,67 +1,6 @@
import { Movie, TV } from '.'; import { Movie, TV } from '.';
export type MonetizationType = 'flatrate' | 'free' | 'ads' | 'rent' | 'buy';
export interface DiscoverQueryOptions {
language?: string;
sort_by?: SortOption;
page?: number;
'vote_average.gte'?: number;
'vote_count.gte'?: number;
'vote_count.lte'?: number;
'vote_average.lte'?: number;
with_watch_providers?: string;
watch_region?: string;
without_companies?: string;
with_watch_monetization_types?: MonetizationType;
'with_runtime.gte'?: number;
'with_runtime.lte'?: number;
with_genres?: string;
without_genres?: string;
with_original_language?: string;
without_keywords?: string;
with_keywords?: string;
with_companies?: string;
include_adult?: boolean;
}
export interface MovieQueryOptions extends DiscoverQueryOptions {
region?: string;
certification_country?: string;
certification?: string;
'certification.lte'?: string;
'certification.gte'?: string;
include_adult?: boolean;
include_video?: boolean;
primary_release_year?: number;
'primary_release_date.gte'?: string;
'primary_release_date.lte'?: string;
'release_date.gte'?: string;
'release_date.lte'?: string;
with_release_type?: string;
year?: number;
with_cast?: string;
with_crew?: string;
with_people?: string;
}
export interface TvShowQueryOptions extends DiscoverQueryOptions {
'air_date.gte'?: string;
'air_date.lte'?: string;
'first_air_date.gte'?: string;
'first_air_date.lte'?: string;
first_air_date_year?: number;
timezone?: string;
with_networks?: string;
include_null_first_air_dates?: boolean;
screened_theatrically?: boolean;
with_status?: string;
with_type?: string;
}
export type SortOption = export type SortOption =
| 'first_air_date.asc'
| 'first_air_date.desc'
| 'popularity.asc' | 'popularity.asc'
| 'popularity.desc' | 'popularity.desc'
| 'release_date.asc' | 'release_date.asc'

View File

@@ -1,8 +1,6 @@
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';
@@ -16,16 +14,6 @@ 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 interface ErrorResponse {
status_code: number;
status_message: string;
success: boolean;
}
export type MediaType = 'movie' | 'tv' | 'person';
export interface AuthorDetails { export interface AuthorDetails {
name: string; name: string;
@@ -34,12 +22,27 @@ export interface AuthorDetails {
rating?: number; rating?: number;
} }
export type KnownFor = MovieWithMediaType | TVWithMediaType; 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 interface Person { export interface Person {
id: number; id: number;
name: string; name: string;
original_name: string;
known_for: KnownFor[]; known_for: KnownFor[];
profile_path: string; profile_path: string;
adult: boolean; adult: boolean;
@@ -48,10 +51,6 @@ 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;
@@ -69,10 +68,6 @@ 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;
@@ -82,7 +77,6 @@ export interface Company {
export interface TV { export interface TV {
id: number; id: number;
adult: boolean;
name:string; name:string;
first_air_date: string; first_air_date: string;
backdrop_path: string; backdrop_path: string;
@@ -97,10 +91,6 @@ 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;
@@ -111,13 +101,6 @@ export interface ExternalIds {
facebook_id: string; facebook_id: string;
instagram_id: string; instagram_id: string;
twitter_id: string; twitter_id: string;
tvdb_id?: number;
freebase_mid?: string;
freebase_id?: string;
tvrage_id?: number;
wikidata_id: string;
tiktok_id?: string;
youtube_id?: string;
id: number; id: number;
} }
@@ -129,7 +112,7 @@ export interface ProductionCompany {
} }
export interface ProductionCountry { export interface ProductionCountry {
iso_3166_1: CountryCode; iso_3166_1: string;
name: string; name: string;
} }
@@ -145,21 +128,21 @@ export interface ContentRatings {
} }
export interface ContentRatingsResult { export interface ContentRatingsResult {
descriptor: unknown[]; iso_3166_1: string;
iso_3166_1: CountryCode;
rating: string; rating: string;
} }
export interface Recommendation { export interface Recommendation {
adult: boolean; adult: boolean;
backdrop_path?: string; backdrop_path?: any;
genre_ids: number[]; genre_ids: number[];
id: number; id: number;
original_language: string; original_language: string;
original_title: string; original_title: string;
overview: string; overview: string;
release_date: string; release_date: string;
poster_path?: string; poster_path?: any;
popularity: number; popularity: number;
title: string; title: string;
video: boolean; video: boolean;
@@ -167,6 +150,7 @@ export interface Recommendation {
vote_count: number; vote_count: number;
} }
export interface Recommendations { export interface Recommendations {
page: number; page: number;
results: Recommendation[]; results: Recommendation[];
@@ -178,9 +162,9 @@ export interface Review {
author: string; author: string;
author_details: AuthorDetails; author_details: AuthorDetails;
content: string; content: string;
created_at: string; created_at: Date;
id: string; id: string;
updated_at: string; updated_at: Date;
url: string; url: string;
} }
@@ -192,6 +176,7 @@ export interface Reviews {
total_results: number; total_results: number;
} }
export interface TranslationData { export interface TranslationData {
title: string; title: string;
overview: string; overview: string;
@@ -199,7 +184,7 @@ export interface TranslationData {
} }
export interface Translation { export interface Translation {
iso_3166_1: CountryCode; iso_3166_1: string;
iso_639_1: string; iso_639_1: string;
name: string; name: string;
english_name: string; english_name: string;
@@ -220,78 +205,3 @@ export interface Image {
vote_count: number; vote_count: number;
width: number; width: number;
} }
export interface Images {
id: number;
backdrops: Image[];
logos: Image[];
posters: Image[];
}
export const CountryCodes = [
'AE',
'AR',
'AT',
'AU',
'BE',
'BG',
'BO',
'BR',
'CA',
'CH',
'CL',
'CO',
'CR',
'CV',
'CZ',
'DE',
'DK',
'EC',
'EE',
'EG',
'ES',
'FI',
'FR',
'GB',
'GH',
'GR',
'GT',
'HK',
'HN',
'HU',
'ID',
'IE',
'IL',
'IN',
'IT',
'JP',
'LT',
'LV',
'MU',
'MX',
'MY',
'MZ',
'NL',
'NO',
'NZ',
'PE',
'PH',
'PL',
'PT',
'PY',
'RU',
'SA',
'SE',
'SG',
'SI',
'SK',
'TH',
'TR',
'TW',
'UG',
'US',
'VE',
'ZA',
] as const;
export type CountryCode = (typeof CountryCodes)[number];

View File

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

View File

@@ -1,23 +1,9 @@
import { import { Genre, Movie, ProductionCompany, ProductionCountry, SpokenLanguage } from './';
CountryCode,
Genre,
Movie,
ProductionCompany,
ProductionCountry,
SpokenLanguage,
} from './';
export interface BelongsToCollection {
id: number;
name: string;
poster_path: string;
backdrop_path: string;
}
export interface MovieDetails { export interface MovieDetails {
adult: boolean; adult: boolean;
backdrop_path: string; backdrop_path: string;
belongs_to_collection?: BelongsToCollection; belongs_to_collection?: any;
budget: number; budget: number;
genres: Genre[]; genres: Genre[];
homepage: string; homepage: string;
@@ -27,7 +13,7 @@ export interface MovieDetails {
original_title: string; original_title: string;
overview: string; overview: string;
popularity: number; popularity: number;
poster_path?: string; poster_path?: any;
production_companies: ProductionCompany[]; production_companies: ProductionCompany[];
production_countries: ProductionCountry[]; production_countries: ProductionCountry[];
release_date: string; release_date: string;
@@ -48,20 +34,19 @@ export enum ReleaseDateType {
'Theatrical', 'Theatrical',
'Digital', 'Digital',
'Physical', 'Physical',
'TV', 'TV'
} }
export interface ReleaseDate { export interface ReleaseDate {
certification: string; certification: string;
descriptors: string[];
iso_639_1: string; iso_639_1: string;
release_date: string; release_date: Date;
type: ReleaseDateType; type: ReleaseDateType;
note: string; note: string;
} }
export interface ReleaseDateResult { export interface ReleaseDateResult {
iso_3166_1: CountryCode; iso_3166_1: string;
release_dates: ReleaseDate[]; release_dates: ReleaseDate[];
} }
@@ -70,6 +55,7 @@ export interface ReleaseDates {
results: ReleaseDateResult[]; results: ReleaseDateResult[];
} }
export interface SimilarMovies { export interface SimilarMovies {
page: number; page: number;
results: Movie[]; results: Movie[];
@@ -96,10 +82,29 @@ 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?: any;
belongs_to_collection?: BelongsToCollection; belongs_to_collection?: any;
budget: number; budget: number;
genres: Genre[]; genres: Genre[];
homepage: string; homepage: string;
@@ -110,12 +115,12 @@ export interface LatestMovie {
overview: string; overview: string;
popularity: number; popularity: number;
poster_path: string; poster_path: string;
production_companies: ProductionCompany[]; production_companies: any[];
production_countries: ProductionCountry[]; production_countries: any[];
release_date: string; release_date: string;
revenue: number; revenue: number;
runtime: number; runtime: number;
spoken_languages: SpokenLanguage[]; spoken_languages: any[];
status: string; status: string;
tagline: string; tagline: string;
title: string; title: string;
@@ -124,6 +129,7 @@ export interface LatestMovie {
vote_count: number; vote_count: number;
} }
export interface Dates { export interface Dates {
maximum: string; maximum: string;
minimum: string; minimum: string;
@@ -157,14 +163,3 @@ 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;

View File

@@ -1,15 +0,0 @@
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,389 +1,11 @@
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,
CountryCode,
} from '.';
export const AvailableLanguages = [
'af-ZA',
'ar-AE',
'ar-BH',
'ar-EG',
'ar-IQ',
'ar-JO',
'ar-LY',
'ar-MA',
'ar-QA',
'ar-SA',
'ar-TD',
'ar-YE',
'be-BY',
'bg-BG',
'bn-BD',
'br-FR',
'ca-AD',
'ca-ES',
'ch-GU',
'cs-CZ',
'cy-GB',
'da-DK',
'de-AT',
'de-CH',
'de-DE',
'el-CY',
'el-GR',
'en-AG',
'en-AU',
'en-BB',
'en-BZ',
'en-CA',
'en-CM',
'en-GB',
'en-GG',
'en-GH',
'en-GI',
'en-GY',
'en-IE',
'en-JM',
'en-KE',
'en-LC',
'en-MW',
'en-NZ',
'en-PG',
'en-TC',
'en-US',
'en-ZM',
'en-ZW',
'eo-EO',
'es-AR',
'es-CL',
'es-DO',
'es-EC',
'es-ES',
'es-GQ',
'es-GT',
'es-HN',
'es-MX',
'es-NI',
'es-PA',
'es-PE',
'es-PY',
'es-SV',
'es-UY',
'et-EE',
'eu-ES',
'fa-IR',
'fi-FI',
'fr-BF',
'fr-CA',
'fr-CD',
'fr-CI',
'fr-FR',
'fr-GF',
'fr-GP',
'fr-MC',
'fr-ML',
'fr-MU',
'fr-PF',
'ga-IE',
'gd-GB',
'gl-ES',
'he-IL',
'hi-IN',
'hr-HR',
'hu-HU',
'id-ID',
'it-IT',
'it-VA',
'ja-JP',
'ka-GE',
'kk-KZ',
'kn-IN',
'ko-KR',
'ky-KG',
'lt-LT',
'lv-LV',
'ml-IN',
'mr-IN',
'ms-MY',
'ms-SG',
'nb-NO',
'nl-BE',
'nl-NL',
'no-NO',
'pa-IN',
'pl-PL',
'pt-AO',
'pt-BR',
'pt-MZ',
'pt-PT',
'ro-MD',
'ro-RO',
'ru-RU',
'si-LK',
'sk-SK',
'sl-SI',
'sq-AL',
'sq-XK',
'sr-ME',
'sr-RS',
'sv-SE',
'sw-TZ',
'ta-IN',
'te-IN',
'th-TH',
'tl-PH',
'tr-TR',
'uk-UA',
'ur-PK',
'vi-VN',
'zh-CN',
'zh-HK',
'zh-SG',
'zh-TW',
'zu-ZA',
] as const;
export type AvailableLanguage = (typeof AvailableLanguages)[number];
export interface LanguageOption { export interface LanguageOption {
language?: AvailableLanguage; language?: string;
}
export interface WatchRegionOption {
watch_region?: CountryCode;
} }
export interface RegionOption { export interface RegionOption {
region?: string; region?: string;
} }
export interface TimezoneOption {
timezone?: string;
}
export interface PageOption { export interface PageOption {
page?: number; page?: number;
} }
export interface ChangeOption extends PageOption {
start_date?: string;
end_date?: string;
}
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 { CountryCode, Image, Movie, Person, TV } from '.'; import { 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 PersonDetails { export interface PersonDetail {
birthday: string; birthday: string;
known_for_department: string; known_for_department: string;
deathday: string; deathday: string;
@@ -96,26 +96,30 @@ export interface PersonDetails {
homepage: string; homepage: string;
} }
export type PersonChangeValue = export interface PersonChange {
| string id: string;
| { action: string;
profile: { time: string;
file_path: string; iso_639_1: string;
}; iso_3166_1: string;
}; value: string | { profile: { file_path: string } };
original_value: string | { profile: { file_path: string } };
}
export interface PopularPeople { export interface PersonChanges {
changes: {
key: string;
items: PersonChange[];
}[];
}
export interface PopularPersons {
page: number; page: number;
results: Person[]; results: Person[];
total_results: number; total_results: number;
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;
@@ -137,10 +141,10 @@ export interface TaggedImages {
total_pages: number; total_pages: number;
} }
export interface PersonTranslations { export interface PeopleTranslations {
id: number; id: number;
translations: { translations: {
iso_3166_1: CountryCode; iso_3166_1: string;
iso_639_1: string; iso_639_1: string;
name: string; name: string;
english_name: string; english_name: string;

View File

@@ -1,7 +0,0 @@
import { CountryCode } from '../types';
export interface Region {
iso_3166_1: CountryCode;
english_name: string;
native_name: string;
}

View File

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

View File

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

View File

@@ -1,58 +0,0 @@
import { CountryCode, 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: CountryCode;
iso_639_1: string;
name: string;
english_name: string;
data: {
name: string;
overview: string;
};
};
}
export type TvEpisodeChangeValue = string | unknown;

View File

@@ -1,23 +0,0 @@
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

@@ -1,10 +1,4 @@
import { import { Genre, ProductionCompany, ProductionCountry, SpokenLanguage, Crew } from './';
Genre,
ProductionCompany,
ProductionCountry,
SpokenLanguage,
LanguageOption,
} from './';
export interface CreatedBy { export interface CreatedBy {
id: number; id: number;
@@ -14,21 +8,6 @@ export interface CreatedBy {
profile_path: string; profile_path: string;
} }
export interface NextEpisodeToAir {
id: number;
name: string;
overview: string;
vote_average: number;
vote_count: number;
air_date: string;
episode_number: number;
production_code: string;
runtime: number;
season_number: number;
show_id: number;
still_path: string;
}
export interface LastEpisodeToAir { export interface LastEpisodeToAir {
air_date: string; air_date: string;
episode_number: number; episode_number: number;
@@ -72,7 +51,7 @@ export interface TvShowDetails {
last_air_date: string; last_air_date: string;
last_episode_to_air: LastEpisodeToAir; last_episode_to_air: LastEpisodeToAir;
name: string; name: string;
next_episode_to_air?: NextEpisodeToAir; next_episode_to_air?: any;
networks: Network[]; networks: Network[];
number_of_episodes: number; number_of_episodes: number;
number_of_seasons: number; number_of_seasons: number;
@@ -93,6 +72,66 @@ 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: any;
iso_639_1: string;
original_value: any;
}
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;
@@ -126,6 +165,7 @@ export interface ScreenedTheatrically {
results: ScreenedTheatricallyResult[]; results: ScreenedTheatricallyResult[];
} }
export interface SimilarTvShow { export interface SimilarTvShow {
backdrop_path: string; backdrop_path: string;
first_air_date: string; first_air_date: string;
@@ -150,8 +190,8 @@ export interface SimilarTvShows {
} }
export interface LatestTvShows { export interface LatestTvShows {
backdrop_path?: string; backdrop_path?: any;
created_by: CreatedBy[]; created_by: any[];
episode_run_time: number[]; episode_run_time: number[];
first_air_date: string; first_air_date: string;
genres: Genre[]; genres: Genre[];
@@ -167,10 +207,10 @@ export interface LatestTvShows {
origin_country: string[]; origin_country: string[];
original_language: string; original_language: string;
original_name: string; original_name: string;
overview?: string; overview?: any;
popularity: number; popularity: number;
poster_path?: string; poster_path?: any;
production_companies: ProductionCompany[]; production_companies: any[];
seasons: Season[]; seasons: Season[];
status: string; status: string;
type: string; type: string;
@@ -178,6 +218,7 @@ export interface LatestTvShows {
vote_count: number; vote_count: number;
} }
export interface OnTheAirResult { export interface OnTheAirResult {
poster_path: string; poster_path: string;
popularity: number; popularity: number;
@@ -201,6 +242,7 @@ export interface OnTheAir {
total_pages: number; total_pages: number;
} }
export interface AiringTodayResult { export interface AiringTodayResult {
poster_path: string; poster_path: string;
popularity: number; popularity: number;
@@ -224,6 +266,7 @@ export interface TvShowsAiringToday {
total_pages: number; total_pages: number;
} }
export interface PopularTvShowResult { export interface PopularTvShowResult {
poster_path: string; poster_path: string;
popularity: number; popularity: number;
@@ -247,6 +290,7 @@ export interface PopularTvShows {
total_pages: number; total_pages: number;
} }
export interface TopRatedTvShowResult { export interface TopRatedTvShowResult {
poster_path: string; poster_path: string;
popularity: number; popularity: number;
@@ -270,21 +314,4 @@ export interface TopRatedTvShows {
total_pages: 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[];
}

View File

@@ -1,21 +1,3 @@
import { Region } from './regions';
import { CountryCode } from '../types';
export interface WatchProvider {
display_priorities: { [K in CountryCode]: number };
display_priority: number;
logo_path: string;
provider_id: number;
provider_name: string;
}
export interface RegionResult {
results: Array<Region>;
}
export interface WatchProviderResult {
results: Array<WatchProvider>;
}
export interface Flatrate { export interface Flatrate {
display_priority: number; display_priority: number;
@@ -38,6 +20,7 @@ export interface Buy {
provider_name: string; provider_name: string;
} }
export interface WatchLocale { export interface WatchLocale {
AR: { AR: {
link: string; link: string;
@@ -315,3 +298,5 @@ export interface WatchProviders {
id: number; id: number;
results: WatchLocale; results: WatchLocale;
} }

View File

@@ -8,12 +8,7 @@
* @param {string} imagePath raw image path * @param {string} imagePath raw image path
* @param {boolean} svg get svg version if true * @param {boolean} svg get svg version if true
*/ */
export const getFullImagePath = ( export const getFullImagePath = (baseUrl: string, fileSize: string, imagePath: string, svg = false): string => {
baseUrl: string,
fileSize: string,
imagePath: string,
svg: boolean = false
): string => {
const imagePathArr = imagePath.split('.'); const imagePathArr = imagePath.split('.');
const imageFormat = svg ? 'svg' : imagePathArr[1]; const imageFormat = svg ? 'svg' : imagePathArr[1];

View File

@@ -1,8 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ export function parseOptions(
export function parseOptions(options?: Record<string, any>): string { options?: { [s: string]: any },
): string {
return options return options
? new URLSearchParams( ? new URLSearchParams(Object.entries(options)).toString()
Object.entries(options).filter(([, v]) => v) // remove undefined
).toString()
: ''; : '';
} }

View File

@@ -1,18 +1,28 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "esnext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */, "target": "es2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
"module": "CommonJS" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
"moduleResolution": "node",
"sourceMap": true /* Generates corresponding '.map' file. */, "sourceMap": true /* Generates corresponding '.map' file. */,
"outDir": "dist" /* Redirect output structure to the directory. */, "outDir": "dist" /* Redirect output structure to the directory. */,
"strict": true /* Enable all strict type-checking options. */, "strict": true /* Enable all strict type-checking options. */,
"allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"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"
]
}, },
"types": ["node"], "types": ["node"],
"include": ["src"], "include": [
"exclude": ["node_modules", "dist", "./src/types/*.ts"] "src"
],
"exclude": [
"node_modules",
"dist",
"./src/types/*.ts"
]
} }