Compare commits
101 Commits
feat/add_l
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| e32ed16a48 | |||
| 670ab42b16 | |||
| 32e282a2e1 | |||
|
|
fdf00f6655 | ||
|
|
71817751a7 | ||
|
|
9f05886a5b | ||
|
|
7a1453d8d4 | ||
|
|
da5abe276a | ||
|
|
9e1e65205c | ||
|
|
6157405fe1 | ||
|
|
eaa5f9a751 | ||
|
|
2abf448bb2 | ||
|
|
4140bd7a7f | ||
|
|
f513103785 | ||
|
|
ea19c5b9e1 | ||
|
|
1bf4063121 | ||
|
|
8df7fe2f2a | ||
|
|
9ac3da7321 | ||
|
|
313d44878c | ||
|
|
6fc8c7b6d3 | ||
|
|
730afebd7d | ||
|
|
fc44bcf425 | ||
|
|
defd0a5998 | ||
|
|
64ba6e0fd1 | ||
|
|
e723b2f8fa | ||
|
|
3d3ec34fc5 | ||
|
|
00709c1d28 | ||
|
|
9c14fb80fd | ||
|
|
c56ecbef47 | ||
|
|
876d2cac0f | ||
|
|
9dae7144b2 | ||
|
|
f99dbac1d2 | ||
|
|
43f5d16dc3 | ||
|
|
682cf48cb0 | ||
|
|
1146ca8ad2 | ||
|
|
6a68e9973b | ||
|
|
ad2b27ca72 | ||
|
|
76f62210be | ||
|
|
101457cdd7 | ||
|
|
7d4b3fcb60 | ||
|
|
eb53747570 | ||
|
|
8c615edbfa | ||
|
|
1628ea05bd | ||
|
|
90b70a9c88 | ||
|
|
52c874b79f | ||
|
|
31f9cc3fac | ||
|
|
d5013db314 | ||
|
|
8738ac7fda | ||
|
|
152e742883 | ||
|
|
8c59fe859c | ||
|
|
ab1925d32c | ||
|
|
b11187c093 | ||
|
|
f605edf354 | ||
|
|
caae3009d5 | ||
|
|
1c79599c41 | ||
|
|
d50ec7eb31 | ||
|
|
f3469510c3 | ||
|
|
0020057097 | ||
|
|
dbb93f5104 | ||
|
|
1b8138b971 | ||
|
|
f6a5375c8c | ||
|
|
54cb13c23e | ||
|
|
e46f140890 | ||
|
|
33830afe92 | ||
|
|
9457dce115 | ||
|
|
b0b6398169 | ||
|
|
5d9c61971d | ||
|
|
16c8b9e4ff | ||
|
|
80a5e5e5bd | ||
|
|
4b88e795f1 | ||
|
|
da6427807f | ||
|
|
2e6cc38995 | ||
|
|
738a0a7a24 | ||
|
|
0a7590e989 | ||
|
|
2705f52160 | ||
|
|
2fed644950 | ||
|
|
bb5e9ad50f | ||
|
|
7d96ad04d1 | ||
|
|
cf7a561e3f | ||
|
|
e5ce15d58d | ||
|
|
7f98a557dc | ||
|
|
9e54e26e87 | ||
|
|
cc41646798 | ||
|
|
5927f95f0a | ||
|
|
a5acac981c | ||
|
|
4f5c39ba7a | ||
|
|
69a883e845 | ||
|
|
de2f76d257 | ||
|
|
af7dc02a07 | ||
|
|
6e111921b5 | ||
|
|
c95a66baae | ||
|
|
f3f4868ef8 | ||
|
|
6bcddc62f1 | ||
|
|
2b26b7b848 | ||
|
|
6c361002bf | ||
|
|
6fd471b921 | ||
|
|
60a2f8e00e | ||
|
|
933ebf25a3 | ||
|
|
5d38a76997 | ||
|
|
562864a70f | ||
|
|
1200064194 |
@@ -1,4 +0,0 @@
|
||||
node_modules
|
||||
dist
|
||||
lib
|
||||
coverage
|
||||
22
.eslintrc.js
22
.eslintrc.js
@@ -1,22 +0,0 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
browser: false,
|
||||
es2021: true,
|
||||
node: true,
|
||||
},
|
||||
extends: [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"prettier",
|
||||
],
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
ecmaVersion: 12,
|
||||
sourceType: "module",
|
||||
},
|
||||
rules:{
|
||||
'linebreak-style': ['off', 'unix'],
|
||||
},
|
||||
plugins: ["@typescript-eslint"],
|
||||
};
|
||||
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,38 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Smartphone (please complete the following information):**
|
||||
- Device: [e.g. iPhone6]
|
||||
- OS: [e.g. iOS8.1]
|
||||
- Browser [e.g. stock browser, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,3 +4,4 @@
|
||||
dist
|
||||
/.npmignore
|
||||
.idea
|
||||
.DS_Store
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
npm run lint
|
||||
@@ -1,3 +0,0 @@
|
||||
dist
|
||||
node_modules
|
||||
.github
|
||||
12
.prettierrc
12
.prettierrc
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"printWidth": 80,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "es5",
|
||||
"bracketSpacing": true,
|
||||
"arrowParens": "always",
|
||||
"proseWrap": "never",
|
||||
"htmlWhitespaceSensitivity": "strict"
|
||||
}
|
||||
1328
DOCUMENTATION.md
Normal file
1328
DOCUMENTATION.md
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Blake Joynes
|
||||
Copyright (c) 2024 Blake Joynes
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -14,8 +14,10 @@ Installation:
|
||||
npm install --save tmdb-ts
|
||||
``
|
||||
|
||||
Version 1.0 removed the default import so make sure you update accordingly!
|
||||
|
||||
```js
|
||||
import TMDB from 'tmdb-ts';
|
||||
import { TMDB } from 'tmdb-ts';
|
||||
|
||||
const tmdb = new TMDB('accessToken');
|
||||
|
||||
|
||||
17
eslint.config.mjs
Normal file
17
eslint.config.mjs
Normal file
@@ -0,0 +1,17 @@
|
||||
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,
|
||||
];
|
||||
5213
package-lock.json
generated
5213
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
46
package.json
46
package.json
@@ -1,16 +1,14 @@
|
||||
{
|
||||
"name": "tmdb-ts",
|
||||
"version": "0.1.8",
|
||||
"version": "2.0.2",
|
||||
"description": "TMDB v3 library wrapper",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"compile": "rm -rf dist && tsc -d && npm run copy-types",
|
||||
"lint": "eslint --ext .ts src/",
|
||||
"lint:fix": "eslint --ext .ts src/ --fix",
|
||||
"format": "npx prettier --write src",
|
||||
"pre-commit": "npm run lint",
|
||||
"copy-types": "mkdir dist/types && cp src/types/*.d.ts dist/types"
|
||||
"compile": "rm -rf dist && tsc -d",
|
||||
"lint": "eslint src/",
|
||||
"lint:fix": "eslint --fix",
|
||||
"format": "prettier --write src",
|
||||
"pre-commit": "npm run lint"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/blakejoy/tmdb-ts/issues",
|
||||
@@ -30,27 +28,17 @@
|
||||
"author": "Blake Joynes",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^15.3.0",
|
||||
"@types/node-fetch": "^2.5.10",
|
||||
"@typescript-eslint/eslint-plugin": "^5.58.0",
|
||||
"@typescript-eslint/parser": "^5.58.0",
|
||||
"dotenv": "^9.0.2",
|
||||
"eslint": "^8.38.0",
|
||||
"eslint-config-airbnb-typescript": "^17.0.0",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"husky": "^8.0.3",
|
||||
"prettier": "^2.8.7",
|
||||
"ts-node": "^9.1.1",
|
||||
"typescript": "^4.9.5"
|
||||
"@types/node": "^20.16.10",
|
||||
"@types/node-fetch": "^3.0.3",
|
||||
"dotenv": "^16.4.5",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"globals": "^15.4.0",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.4.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"cross-fetch": "^3.1.4"
|
||||
},
|
||||
"volta": {
|
||||
"node": "15.13.0",
|
||||
"yarn": "1.19.2",
|
||||
"npm": "7.12.1"
|
||||
"cross-fetch": "^4.0.0"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
@@ -60,4 +48,4 @@
|
||||
"files": [
|
||||
"dist"
|
||||
]
|
||||
}
|
||||
}
|
||||
18
src/api.ts
18
src/api.ts
@@ -1,20 +1,28 @@
|
||||
import fetch from 'cross-fetch';
|
||||
import { parseOptions } from './utils';
|
||||
import { ErrorResponse } from './types';
|
||||
import { BASE_URL_V3 } from './common/constants';
|
||||
|
||||
const BASE_URL_V3 = 'https://api.themoviedb.org/3';
|
||||
|
||||
export default class Api {
|
||||
export class Api {
|
||||
constructor(private accessToken: string) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
async get<T>(path: string): Promise<T> {
|
||||
const response = await fetch(`${BASE_URL_V3}${path}`, {
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
async get<T>(path: string, options?: Record<string, any>): Promise<T> {
|
||||
const params = parseOptions(options);
|
||||
const response = await fetch(`${BASE_URL_V3}${path}?${params}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: `Bearer ${this.accessToken}`,
|
||||
'Content-Type': 'application/json;charset=utf-8',
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
return Promise.reject((await response.json()) as ErrorResponse);
|
||||
}
|
||||
|
||||
return (await response.json()) as T;
|
||||
}
|
||||
}
|
||||
|
||||
1
src/common/constants.ts
Normal file
1
src/common/constants.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const BASE_URL_V3 = 'https://api.themoviedb.org/3';
|
||||
@@ -1,11 +1,12 @@
|
||||
import { BaseEndpoint } from './base';
|
||||
import { AccountDetails } from '../types/account';
|
||||
|
||||
export class AccountEndpoint extends BaseEndpoint {
|
||||
constructor(accessToken: string) {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async details(): Promise<any> {
|
||||
async details(): Promise<AccountDetails> {
|
||||
return await this.api.get('/account');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import Api from '../api';
|
||||
import { Api } from '../api';
|
||||
|
||||
export class BaseEndpoint {
|
||||
protected api: Api;
|
||||
|
||||
@@ -1,24 +1,20 @@
|
||||
import { ChangeOption, MediaChanges } from '../types';
|
||||
import { BaseEndpoint } from './base';
|
||||
import { ChangeOptions, Changes } from '../types/changes';
|
||||
import { parseOptions } from '../utils';
|
||||
|
||||
export class ChangeEndpoint extends BaseEndpoint {
|
||||
constructor(protected readonly accessToken: string) {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async movies(options?: ChangeOptions): Promise<Changes> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<Changes>(`/movie/changes?${params}`);
|
||||
async movies(options?: ChangeOption): Promise<MediaChanges> {
|
||||
return await this.api.get<MediaChanges>(`/movie/changes`, options);
|
||||
}
|
||||
|
||||
async tvShows(options?: ChangeOptions): Promise<Changes> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<Changes>(`/tv/changes?${params}`);
|
||||
async tvShows(options?: ChangeOption): Promise<MediaChanges> {
|
||||
return await this.api.get<MediaChanges>(`/tv/changes`, options);
|
||||
}
|
||||
|
||||
async person(options?: ChangeOptions): Promise<Changes> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<Changes>(`/person/changes${params}`);
|
||||
async person(options?: ChangeOption): Promise<MediaChanges> {
|
||||
return await this.api.get<MediaChanges>(`/person/changes`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import {
|
||||
DetailedCollection,
|
||||
CollectionDetails,
|
||||
CollectionImageOptions,
|
||||
ImageCollection,
|
||||
LanguageOption,
|
||||
Translations,
|
||||
} from '../types';
|
||||
import { parseOptions } from '../utils';
|
||||
import { BaseEndpoint } from './base';
|
||||
|
||||
const BASE_COLLECTION = '/collection';
|
||||
@@ -17,17 +17,24 @@ export class CollectionsEndpoint extends BaseEndpoint {
|
||||
async details(
|
||||
id: number,
|
||||
options?: LanguageOption
|
||||
): Promise<DetailedCollection> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<DetailedCollection>(
|
||||
`${BASE_COLLECTION}/${id}?${params}`
|
||||
): Promise<CollectionDetails> {
|
||||
return await this.api.get<CollectionDetails>(
|
||||
`${BASE_COLLECTION}/${id}`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async images(id: number, options?: LanguageOption): Promise<ImageCollection> {
|
||||
const params = parseOptions(options);
|
||||
async images(
|
||||
id: number,
|
||||
options?: CollectionImageOptions
|
||||
): Promise<ImageCollection> {
|
||||
const computedOptions = {
|
||||
include_image_language: options?.include_image_language?.join(','),
|
||||
language: options?.language,
|
||||
};
|
||||
return await this.api.get<ImageCollection>(
|
||||
`${BASE_COLLECTION}/${id}/images?${params}`
|
||||
`${BASE_COLLECTION}/${id}/images`,
|
||||
computedOptions
|
||||
);
|
||||
}
|
||||
|
||||
@@ -35,9 +42,9 @@ export class CollectionsEndpoint extends BaseEndpoint {
|
||||
id: number,
|
||||
options?: LanguageOption
|
||||
): Promise<Translations> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<Translations>(
|
||||
`${BASE_COLLECTION}/${id}/translations?${params}`
|
||||
`${BASE_COLLECTION}/${id}/translations`,
|
||||
options
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
26
src/endpoints/companies.ts
Normal file
26
src/endpoints/companies.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import {
|
||||
CompanyDetails,
|
||||
AlternativeNames,
|
||||
CompanyImages,
|
||||
} from './../types/companies';
|
||||
import { BaseEndpoint } from './base';
|
||||
|
||||
export class CompaniesEndpoint extends BaseEndpoint {
|
||||
constructor(protected readonly accessToken: string) {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async details(id: number): Promise<CompanyDetails> {
|
||||
return await this.api.get<CompanyDetails>(`/company/${id}`);
|
||||
}
|
||||
|
||||
async alternativeNames(id: number): Promise<AlternativeNames> {
|
||||
return await this.api.get<AlternativeNames>(
|
||||
`/company/${id}/alternative_names`
|
||||
);
|
||||
}
|
||||
|
||||
async images(id: number): Promise<CompanyImages> {
|
||||
return await this.api.get<CompanyImages>(`/company/${id}/images`);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,44 @@
|
||||
import { BaseEndpoint } from './base';
|
||||
import { Configuration } from '../types/configuration';
|
||||
import {
|
||||
Configuration,
|
||||
CountryConfiguration,
|
||||
JobConfiguration,
|
||||
LanguageConfiguration,
|
||||
TimezoneConfiguration,
|
||||
} from '../types/configuration';
|
||||
|
||||
export class ConfigurationEndpoint extends BaseEndpoint {
|
||||
constructor(protected readonly accessToken: string) {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async getCurrent(): Promise<Configuration> {
|
||||
async getApiConfiguration(): Promise<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`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,85 +1,29 @@
|
||||
import {
|
||||
MovieDiscoverResult,
|
||||
SortOption,
|
||||
MovieQueryOptions,
|
||||
TvShowDiscoverResult,
|
||||
TvShowQueryOptions,
|
||||
} from '../types';
|
||||
import { parseOptions } from '../utils';
|
||||
import { BaseEndpoint } from './base';
|
||||
|
||||
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 {
|
||||
constructor(accessToken: string) {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async movie(options?: MovieQueryOptions): Promise<MovieDiscoverResult> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<MovieDiscoverResult>(
|
||||
`${BASE_DISCOVER}/movie?${params}`
|
||||
`${BASE_DISCOVER}/movie`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async tvShow(options?: TvShowQueryOptions): Promise<TvShowDiscoverResult> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<TvShowDiscoverResult>(
|
||||
`${BASE_DISCOVER}/tv?${params}`
|
||||
`${BASE_DISCOVER}/tv`,
|
||||
options
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
import { BaseEndpoint } from './base';
|
||||
import { ExternalIdOptions, FindResult } from '../types';
|
||||
import { parseOptions } from '../utils';
|
||||
|
||||
export class FindEndpoint extends BaseEndpoint {
|
||||
constructor(accessToken: string) {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async byId(
|
||||
externalId: string,
|
||||
async byExternalId(
|
||||
id: string,
|
||||
options: ExternalIdOptions
|
||||
): Promise<FindResult> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<FindResult>(`/find/${externalId}?${params}`);
|
||||
return await this.api.get<FindResult>(`/find/${id}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { LanguageOption } from '../types';
|
||||
import { BaseEndpoint } from './base';
|
||||
|
||||
export interface Genres {
|
||||
@@ -9,11 +10,11 @@ export class GenreEndpoint extends BaseEndpoint {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async movies(): Promise<Genres> {
|
||||
return await this.api.get<Genres>('/genre/movie/list');
|
||||
async movies(options?: LanguageOption): Promise<Genres> {
|
||||
return await this.api.get<Genres>('/genre/movie/list', options);
|
||||
}
|
||||
|
||||
async tvShows(): Promise<Genres> {
|
||||
return await this.api.get<Genres>('/genre/tv/list');
|
||||
async tvShows(options?: LanguageOption): Promise<Genres> {
|
||||
return await this.api.get<Genres>('/genre/tv/list', options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,3 +14,6 @@ export * from './trending';
|
||||
export * from './find';
|
||||
export * from './keywords';
|
||||
export * from './collections';
|
||||
export * from './tv-seasons';
|
||||
export * from './tv-episode';
|
||||
export * from './watch-providers';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { BaseEndpoint } from './base';
|
||||
import { BelongingMovies, Keyword, KeywordsOptions } from '../types';
|
||||
import { parseOptions } from '../utils';
|
||||
|
||||
const BASE_Keyword = '/keyword';
|
||||
|
||||
@@ -13,13 +12,17 @@ export class KeywordsEndpoint extends BaseEndpoint {
|
||||
return await this.api.get<Keyword>(`${BASE_Keyword}/${keywordId}`);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
async belongingMovies(
|
||||
keywordId: number,
|
||||
options?: KeywordsOptions
|
||||
): Promise<BelongingMovies> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<BelongingMovies>(
|
||||
`${BASE_Keyword}/${keywordId}/movies?${params}`
|
||||
`${BASE_Keyword}/${keywordId}/movies`,
|
||||
options
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
import { BaseEndpoint } from './base';
|
||||
import {
|
||||
AlternativeTitles,
|
||||
ChangeOptions,
|
||||
AppendToResponse,
|
||||
AppendToResponseMovieKey,
|
||||
ChangeOption,
|
||||
Changes,
|
||||
Credits,
|
||||
ExternalIds,
|
||||
Images,
|
||||
Keywords,
|
||||
LanguageOption,
|
||||
LatestMovie,
|
||||
MovieChanges,
|
||||
MovieChangeValue,
|
||||
MovieDetails,
|
||||
MovieLists,
|
||||
MoviesPlayingNow,
|
||||
@@ -25,17 +28,37 @@ import {
|
||||
Videos,
|
||||
WatchProviders,
|
||||
} from '../types';
|
||||
import { parseOptions } from '../utils';
|
||||
|
||||
const BASE_MOVIE = '/movie';
|
||||
|
||||
export interface MoviesImageSearchOptions extends LanguageOption {
|
||||
/**
|
||||
* a list of ISO-639-1 values to query
|
||||
*/
|
||||
include_image_language?: string[];
|
||||
}
|
||||
|
||||
export class MoviesEndpoint extends BaseEndpoint {
|
||||
constructor(protected readonly accessToken: string) {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async details(id: number): Promise<MovieDetails> {
|
||||
return await this.api.get<MovieDetails>(`${BASE_MOVIE}/${id}`);
|
||||
async details<T extends AppendToResponseMovieKey[] | undefined>(
|
||||
id: number,
|
||||
appendToResponse?: T,
|
||||
language?: string
|
||||
) {
|
||||
const options = {
|
||||
append_to_response: appendToResponse
|
||||
? appendToResponse.join(',')
|
||||
: undefined,
|
||||
language: language,
|
||||
};
|
||||
|
||||
return await this.api.get<AppendToResponse<MovieDetails, T, 'movie'>>(
|
||||
`${BASE_MOVIE}/${id}`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async alternativeTitles(id: number): Promise<AlternativeTitles> {
|
||||
@@ -44,23 +67,36 @@ export class MoviesEndpoint extends BaseEndpoint {
|
||||
);
|
||||
}
|
||||
|
||||
async changes(id: number, options?: ChangeOptions): Promise<MovieChanges> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<MovieChanges>(
|
||||
`${BASE_MOVIE}/${id}/changes?${params}`
|
||||
async changes(
|
||||
id: number,
|
||||
options?: ChangeOption
|
||||
): Promise<Changes<MovieChangeValue>> {
|
||||
return await this.api.get<Changes<MovieChangeValue>>(
|
||||
`${BASE_MOVIE}/${id}/changes`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async credits(id: number): Promise<Credits> {
|
||||
return await this.api.get<Credits>(`${BASE_MOVIE}/${id}/credits`);
|
||||
async credits(id: number, options?: LanguageOption): Promise<Credits> {
|
||||
return await this.api.get<Credits>(`${BASE_MOVIE}/${id}/credits`, options);
|
||||
}
|
||||
|
||||
async externalIds(id: number): Promise<ExternalIds> {
|
||||
return await this.api.get<ExternalIds>(`${BASE_MOVIE}/${id}/external_ids`);
|
||||
}
|
||||
|
||||
async images(id: number): Promise<Images> {
|
||||
return await this.api.get<Images>(`${BASE_MOVIE}/${id}/images`);
|
||||
async images(
|
||||
id: number,
|
||||
options?: MoviesImageSearchOptions
|
||||
): Promise<Images> {
|
||||
const computedOptions = {
|
||||
include_image_language: options?.include_image_language?.join(','),
|
||||
language: options?.language,
|
||||
};
|
||||
return await this.api.get<Images>(
|
||||
`${BASE_MOVIE}/${id}/images`,
|
||||
computedOptions
|
||||
);
|
||||
}
|
||||
|
||||
async keywords(id: number): Promise<Keywords> {
|
||||
@@ -69,21 +105,18 @@ export class MoviesEndpoint extends BaseEndpoint {
|
||||
|
||||
async lists(
|
||||
id: number,
|
||||
options?: LanguageOption | PageOption
|
||||
options?: LanguageOption & PageOption
|
||||
): Promise<MovieLists> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<MovieLists>(
|
||||
`${BASE_MOVIE}/${id}/lists?${params}`
|
||||
);
|
||||
return await this.api.get<MovieLists>(`${BASE_MOVIE}/${id}/lists`, options);
|
||||
}
|
||||
|
||||
async recommendations(
|
||||
id: number,
|
||||
options?: PageOption
|
||||
options?: LanguageOption & PageOption
|
||||
): Promise<Recommendations> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<Recommendations>(
|
||||
`${BASE_MOVIE}/${id}/recommendations?${params}`
|
||||
`${BASE_MOVIE}/${id}/recommendations`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
@@ -93,15 +126,20 @@ export class MoviesEndpoint extends BaseEndpoint {
|
||||
);
|
||||
}
|
||||
|
||||
async reviews(id: number, options?: PageOption): Promise<Reviews> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<Reviews>(`${BASE_MOVIE}/${id}/reviews?${params}`);
|
||||
async reviews(
|
||||
id: number,
|
||||
options?: LanguageOption & PageOption
|
||||
): Promise<Reviews> {
|
||||
return await this.api.get<Reviews>(`${BASE_MOVIE}/${id}/reviews`, options);
|
||||
}
|
||||
|
||||
async similar(id: number, options?: PageOption): Promise<SimilarMovies> {
|
||||
const params = parseOptions(options);
|
||||
async similar(
|
||||
id: number,
|
||||
options?: LanguageOption & PageOption
|
||||
): Promise<SimilarMovies> {
|
||||
return await this.api.get<SimilarMovies>(
|
||||
`${BASE_MOVIE}/${id}/similar?${params}`
|
||||
`${BASE_MOVIE}/${id}/similar`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
@@ -109,8 +147,8 @@ export class MoviesEndpoint extends BaseEndpoint {
|
||||
return await this.api.get<Translations>(`${BASE_MOVIE}/${id}/translations`);
|
||||
}
|
||||
|
||||
async videos(id: number): Promise<Videos> {
|
||||
return await this.api.get<Videos>(`${BASE_MOVIE}/${id}/videos`);
|
||||
async videos(id: number, options?: LanguageOption): Promise<Videos> {
|
||||
return await this.api.get<Videos>(`${BASE_MOVIE}/${id}/videos`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,32 +168,31 @@ export class MoviesEndpoint extends BaseEndpoint {
|
||||
async nowPlaying(
|
||||
options?: PageOption & LanguageOption & RegionOption
|
||||
): Promise<MoviesPlayingNow> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<MoviesPlayingNow>(
|
||||
`${BASE_MOVIE}/now_playing?${params}`
|
||||
`${BASE_MOVIE}/now_playing`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async popular(options?: PageOption): Promise<PopularMovies> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<PopularMovies>(`${BASE_MOVIE}/popular?${params}`);
|
||||
async popular(options?: LanguageOption & PageOption): Promise<PopularMovies> {
|
||||
return await this.api.get<PopularMovies>(`${BASE_MOVIE}/popular`, options);
|
||||
}
|
||||
|
||||
async topRated(
|
||||
options?: PageOption & LanguageOption & RegionOption
|
||||
): Promise<TopRatedMovies> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<TopRatedMovies>(
|
||||
`${BASE_MOVIE}/top_rated?${params}`
|
||||
`${BASE_MOVIE}/top_rated`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async upcoming(
|
||||
options?: PageOption & LanguageOption & RegionOption
|
||||
): Promise<UpcomingMovies> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<UpcomingMovies>(
|
||||
`${BASE_MOVIE}/upcoming?${params}`
|
||||
`${BASE_MOVIE}/upcoming`,
|
||||
options
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
23
src/endpoints/networks.ts
Normal file
23
src/endpoints/networks.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { NetworkDetails, NetworkImages } from '..';
|
||||
import { AlternativeNames } from './../types/companies';
|
||||
import { BaseEndpoint } from './base';
|
||||
|
||||
export class NetworksEndpoint extends BaseEndpoint {
|
||||
constructor(protected readonly accessToken: string) {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async details(id: number): Promise<NetworkDetails> {
|
||||
return await this.api.get<NetworkDetails>(`/network/${id}`);
|
||||
}
|
||||
|
||||
async alternativeNames(id: number): Promise<AlternativeNames> {
|
||||
return await this.api.get<AlternativeNames>(
|
||||
`/network/${id}/alternative_names`
|
||||
);
|
||||
}
|
||||
|
||||
async images(id: number): Promise<NetworkImages> {
|
||||
return await this.api.get<NetworkImages>(`/network/${id}/images`);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,21 @@
|
||||
import {
|
||||
ChangeOptions,
|
||||
AppendToResponse,
|
||||
AppendToResponsePersonKey,
|
||||
ChangeOption,
|
||||
ExternalIds,
|
||||
Image,
|
||||
PageOption,
|
||||
PeopleTranslations,
|
||||
PersonChanges,
|
||||
PeopleImages,
|
||||
PersonTranslations,
|
||||
PersonCombinedCredits,
|
||||
PersonDetail,
|
||||
PersonDetails,
|
||||
PersonMovieCredit,
|
||||
PersonTvShowCredit,
|
||||
PopularPersons,
|
||||
TaggedImages,
|
||||
Changes,
|
||||
PersonChangeValue,
|
||||
LanguageOption,
|
||||
PopularPeople,
|
||||
} from '../types';
|
||||
import { parseOptions } from '../utils';
|
||||
import { BaseEndpoint } from './base';
|
||||
|
||||
const BASE_PERSON = '/person';
|
||||
@@ -22,32 +25,60 @@ export class PeopleEndpoint extends BaseEndpoint {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async details(id: number): Promise<PersonDetail> {
|
||||
return await this.api.get<PersonDetail>(`${BASE_PERSON}/${id}`);
|
||||
}
|
||||
|
||||
async changes(id: number, options?: ChangeOptions): Promise<PersonChanges> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<PersonChanges>(
|
||||
`${BASE_PERSON}/${id}/changes?${params}`
|
||||
async details<T extends AppendToResponsePersonKey[] | undefined>(
|
||||
id: number,
|
||||
appendToResponse?: T,
|
||||
language?: string
|
||||
) {
|
||||
const options = {
|
||||
append_to_response: appendToResponse
|
||||
? appendToResponse.join(',')
|
||||
: undefined,
|
||||
language: language,
|
||||
};
|
||||
return await this.api.get<AppendToResponse<PersonDetails, T, 'person'>>(
|
||||
`${BASE_PERSON}/${id}`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async movieCredits(id: number): Promise<PersonMovieCredit> {
|
||||
async changes(
|
||||
id: number,
|
||||
options?: ChangeOption
|
||||
): Promise<Changes<PersonChangeValue>> {
|
||||
return await this.api.get<Changes<PersonChangeValue>>(
|
||||
`${BASE_PERSON}/${id}/changes`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async movieCredits(
|
||||
id: number,
|
||||
options?: LanguageOption
|
||||
): Promise<PersonMovieCredit> {
|
||||
return await this.api.get<PersonMovieCredit>(
|
||||
`${BASE_PERSON}/${id}/movie_credits`
|
||||
`${BASE_PERSON}/${id}/movie_credits`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async tvShowCredits(id: number): Promise<PersonTvShowCredit> {
|
||||
async tvShowCredits(
|
||||
id: number,
|
||||
options?: LanguageOption
|
||||
): Promise<PersonTvShowCredit> {
|
||||
return await this.api.get<PersonTvShowCredit>(
|
||||
`${BASE_PERSON}/${id}/tv_credits`
|
||||
`${BASE_PERSON}/${id}/tv_credits`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async combinedCredits(id: number): Promise<PersonCombinedCredits> {
|
||||
async combinedCredits(
|
||||
id: number,
|
||||
options?: LanguageOption
|
||||
): Promise<PersonCombinedCredits> {
|
||||
return await this.api.get<PersonCombinedCredits>(
|
||||
`${BASE_PERSON}/${id}/combined_credits`
|
||||
`${BASE_PERSON}/${id}/combined_credits`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
@@ -55,33 +86,31 @@ export class PeopleEndpoint extends BaseEndpoint {
|
||||
return await this.api.get<ExternalIds>(`${BASE_PERSON}/${id}/external_ids`);
|
||||
}
|
||||
|
||||
async images(id: number): Promise<{ id: number; profiles: Image[] }> {
|
||||
return await this.api.get<{ id: number; profiles: Image[] }>(
|
||||
`${BASE_PERSON}/${id}/images`
|
||||
);
|
||||
async images(id: number): Promise<PeopleImages> {
|
||||
return await this.api.get<PeopleImages>(`${BASE_PERSON}/${id}/images`);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
async taggedImages(id: number, options?: PageOption): Promise<TaggedImages> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<TaggedImages>(
|
||||
`${BASE_PERSON}/${id}/tagged_images?${params}`
|
||||
`${BASE_PERSON}/${id}/tagged_images`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async translation(id: number): Promise<PeopleTranslations> {
|
||||
return await this.api.get<PeopleTranslations>(
|
||||
async translation(id: number): Promise<PersonTranslations> {
|
||||
return await this.api.get<PersonTranslations>(
|
||||
`${BASE_PERSON}/${id}/translations`
|
||||
);
|
||||
}
|
||||
|
||||
async latest(): Promise<PersonDetail> {
|
||||
return await this.api.get<PersonDetail>(`${BASE_PERSON}/latest`);
|
||||
async latest(): Promise<PersonDetails> {
|
||||
return await this.api.get<PersonDetails>(`${BASE_PERSON}/latest`);
|
||||
}
|
||||
|
||||
async popular(options?: PageOption): Promise<PopularPersons> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<PopularPersons>(
|
||||
`${BASE_PERSON}/popular?${params}`
|
||||
);
|
||||
async popular(options?: LanguageOption & PageOption): Promise<PopularPeople> {
|
||||
return await this.api.get<PopularPeople>(`${BASE_PERSON}/popular`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
import { BaseEndpoint } from './base';
|
||||
import { Search } from '../types/search';
|
||||
import { Collection, Company, Movie, Person, TV } from '../types';
|
||||
import { parseOptions } from '../utils';
|
||||
import { MultiSearchResult, Search } from '../types/search';
|
||||
import {
|
||||
Collection,
|
||||
Company,
|
||||
LanguageOption,
|
||||
Movie,
|
||||
PageOption,
|
||||
Person,
|
||||
RegionOption,
|
||||
TV,
|
||||
} from '../types';
|
||||
|
||||
const BASE_SEARCH = '/search';
|
||||
|
||||
@@ -10,18 +18,44 @@ export interface SearchOptions {
|
||||
page?: number;
|
||||
}
|
||||
|
||||
export interface MovieSearchOptions extends SearchOptions {
|
||||
export interface MovieSearchOptions
|
||||
extends SearchOptions,
|
||||
LanguageOption,
|
||||
PageOption,
|
||||
RegionOption {
|
||||
include_adult?: boolean;
|
||||
year?: number;
|
||||
primary_release_year?: number;
|
||||
}
|
||||
|
||||
export interface TvSearchOptions extends SearchOptions {
|
||||
export interface CollectionSearchOptions
|
||||
extends SearchOptions,
|
||||
LanguageOption,
|
||||
PageOption,
|
||||
RegionOption {
|
||||
include_adult?: boolean;
|
||||
}
|
||||
|
||||
export interface TvSearchOptions
|
||||
extends SearchOptions,
|
||||
LanguageOption,
|
||||
PageOption {
|
||||
include_adult?: boolean;
|
||||
year?: number;
|
||||
first_air_date_year?: number;
|
||||
}
|
||||
|
||||
export interface PeopleSearchOptions extends SearchOptions {
|
||||
export interface PeopleSearchOptions
|
||||
extends SearchOptions,
|
||||
LanguageOption,
|
||||
PageOption {
|
||||
include_adult?: boolean;
|
||||
}
|
||||
|
||||
export interface MultiSearchOptions
|
||||
extends SearchOptions,
|
||||
LanguageOption,
|
||||
PageOption {
|
||||
include_adult?: boolean;
|
||||
}
|
||||
|
||||
@@ -31,44 +65,44 @@ export class SearchEndpoint extends BaseEndpoint {
|
||||
}
|
||||
|
||||
async companies(options: SearchOptions): Promise<Search<Company>> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<Search<Company>>(
|
||||
`${BASE_SEARCH}/company?${params}`
|
||||
`${BASE_SEARCH}/company`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async collections(options: SearchOptions): Promise<Search<Collection>> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<Search<Collection>>(
|
||||
`${BASE_SEARCH}/collection?${params}`
|
||||
`${BASE_SEARCH}/collection`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async keywords(
|
||||
options: SearchOptions
|
||||
): Promise<Search<{ id: string; name: string }>> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<Search<{ id: string; name: string }>>(
|
||||
`${BASE_SEARCH}/keyword?${params}`
|
||||
`${BASE_SEARCH}/keyword`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async movies(options: MovieSearchOptions): Promise<Search<Movie>> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<Search<Movie>>(`${BASE_SEARCH}/movie?${params}`);
|
||||
return await this.api.get<Search<Movie>>(`${BASE_SEARCH}/movie`, options);
|
||||
}
|
||||
|
||||
async people(options: PeopleSearchOptions): Promise<Search<Person>> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<Search<Person>>(
|
||||
`${BASE_SEARCH}/person?${params}`
|
||||
);
|
||||
return await this.api.get<Search<Person>>(`${BASE_SEARCH}/person`, options);
|
||||
}
|
||||
|
||||
// TODO: Multi search
|
||||
|
||||
async tvShows(options: TvSearchOptions): Promise<Search<TV>> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<Search<TV>>(`${BASE_SEARCH}/tv?${params}`);
|
||||
return await this.api.get<Search<TV>>(`${BASE_SEARCH}/tv`, options);
|
||||
}
|
||||
|
||||
async multi(options: MultiSearchOptions): Promise<Search<MultiSearchResult>> {
|
||||
return await this.api.get<Search<MultiSearchResult>>(
|
||||
`${BASE_SEARCH}/multi`,
|
||||
options
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { MediaType, TimeWindow, TrendingResults } from '../types';
|
||||
import {
|
||||
TrendingMediaType,
|
||||
TimeWindow,
|
||||
TrendingResults,
|
||||
LanguageOption,
|
||||
PageOption,
|
||||
} from '../types';
|
||||
import { BaseEndpoint } from './base';
|
||||
|
||||
export class TrendingEndpoint extends BaseEndpoint {
|
||||
@@ -6,12 +12,14 @@ export class TrendingEndpoint extends BaseEndpoint {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async trending<T extends MediaType>(
|
||||
async trending<T extends TrendingMediaType>(
|
||||
mediaType: T,
|
||||
timeWindow: TimeWindow
|
||||
timeWindow: TimeWindow,
|
||||
options?: LanguageOption & PageOption
|
||||
): Promise<TrendingResults<T>> {
|
||||
return await this.api.get<TrendingResults<T>>(
|
||||
`/trending/${mediaType}/${timeWindow}`
|
||||
`/trending/${mediaType}/${timeWindow}`,
|
||||
options
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
111
src/endpoints/tv-episode.ts
Normal file
111
src/endpoints/tv-episode.ts
Normal file
@@ -0,0 +1,111 @@
|
||||
import {
|
||||
Episode,
|
||||
EpisodeSelection,
|
||||
LanguageOption,
|
||||
ChangeOption,
|
||||
TvEpisodeCredit,
|
||||
ExternalIds,
|
||||
Images,
|
||||
TvEpisodeTranslations,
|
||||
Videos,
|
||||
AppendToResponse,
|
||||
Changes,
|
||||
TvEpisodeChangeValue,
|
||||
AppendToResponseTvEpisodeKey,
|
||||
} from '..';
|
||||
import { BaseEndpoint } from './base';
|
||||
|
||||
const BASE_EPISODE = (episodeSelection: EpisodeSelection): string => {
|
||||
return `/tv/${episodeSelection.tvShowID}/season/${episodeSelection.seasonNumber}/episode/${episodeSelection.episodeNumber}`;
|
||||
};
|
||||
|
||||
export interface TvEpisodeImageSearchOptions extends LanguageOption {
|
||||
/**
|
||||
* a list of ISO-639-1 values to query
|
||||
*/
|
||||
include_image_language?: string[];
|
||||
}
|
||||
|
||||
export interface TvEpisodeVideoSearchOptions extends LanguageOption {
|
||||
/**
|
||||
* a list of ISO-639-1 values to query
|
||||
*/
|
||||
include_video_language?: string[];
|
||||
}
|
||||
|
||||
export class TvEpisodesEndpoint extends BaseEndpoint {
|
||||
constructor(accessToken: string) {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async details<T extends AppendToResponseTvEpisodeKey[] | undefined>(
|
||||
episodeSelection: EpisodeSelection,
|
||||
appendToResponse?: T,
|
||||
options?: LanguageOption
|
||||
) {
|
||||
const combinedOptions = {
|
||||
append_to_response: appendToResponse
|
||||
? appendToResponse.join(',')
|
||||
: undefined,
|
||||
...options,
|
||||
};
|
||||
|
||||
return await this.api.get<
|
||||
AppendToResponse<Omit<Episode, 'show_id'>, T, 'tvEpisode'>
|
||||
>(`${BASE_EPISODE(episodeSelection)}`, combinedOptions);
|
||||
}
|
||||
|
||||
async changes(episodeID: number, options?: ChangeOption) {
|
||||
return await this.api.get<Changes<TvEpisodeChangeValue>>(
|
||||
`/tv/episode/${episodeID}/changes`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async credits(episodeSelection: EpisodeSelection, options?: LanguageOption) {
|
||||
return await this.api.get<TvEpisodeCredit>(
|
||||
`${BASE_EPISODE(episodeSelection)}/credits`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async externalIds(episodeSelection: EpisodeSelection) {
|
||||
return await this.api.get<ExternalIds>(
|
||||
`${BASE_EPISODE(episodeSelection)}/external_ids`
|
||||
);
|
||||
}
|
||||
|
||||
async images(
|
||||
episodeSelection: EpisodeSelection,
|
||||
options?: TvEpisodeImageSearchOptions
|
||||
) {
|
||||
const computedOptions = {
|
||||
include_image_language: options?.include_image_language?.join(','),
|
||||
language: options?.language,
|
||||
};
|
||||
return await this.api.get<Images>(
|
||||
`${BASE_EPISODE(episodeSelection)}/images`,
|
||||
computedOptions
|
||||
);
|
||||
}
|
||||
|
||||
async translations(episodeSelection: EpisodeSelection) {
|
||||
return await this.api.get<TvEpisodeTranslations>(
|
||||
`${BASE_EPISODE(episodeSelection)}/translations`
|
||||
);
|
||||
}
|
||||
|
||||
async videos(
|
||||
episodeSelection: EpisodeSelection,
|
||||
options?: TvEpisodeVideoSearchOptions
|
||||
) {
|
||||
const computedOptions = {
|
||||
include_video_language: options?.include_video_language?.join(','),
|
||||
language: options?.language,
|
||||
};
|
||||
return await this.api.get<Videos>(
|
||||
`${BASE_EPISODE(episodeSelection)}/videos`,
|
||||
computedOptions
|
||||
);
|
||||
}
|
||||
}
|
||||
131
src/endpoints/tv-seasons.ts
Normal file
131
src/endpoints/tv-seasons.ts
Normal file
@@ -0,0 +1,131 @@
|
||||
import {
|
||||
ChangeOption,
|
||||
Changes,
|
||||
Credits,
|
||||
ExternalIds,
|
||||
Images,
|
||||
LanguageOption,
|
||||
TvSeasonChangeValue,
|
||||
SeasonDetails,
|
||||
SeasonSelection,
|
||||
Translations,
|
||||
Videos,
|
||||
AppendToResponseTvSeasonKey,
|
||||
AppendToResponse,
|
||||
AggregateCredits,
|
||||
} from '..';
|
||||
import { BaseEndpoint } from './base';
|
||||
|
||||
const BASE_SEASON = (seasonSelection: SeasonSelection): string => {
|
||||
return `/tv/${seasonSelection.tvShowID}/season/${seasonSelection.seasonNumber}`;
|
||||
};
|
||||
|
||||
export interface TvSeasonImageSearchOptions extends LanguageOption {
|
||||
/**
|
||||
* a list of ISO-639-1 values to query
|
||||
*/
|
||||
include_image_language?: string[];
|
||||
}
|
||||
|
||||
export interface TvSeasonVideoSearchOptions extends LanguageOption {
|
||||
/**
|
||||
* a list of ISO-639-1 values to query
|
||||
*/
|
||||
include_video_language?: string[];
|
||||
}
|
||||
|
||||
export class TvSeasonsEndpoint extends BaseEndpoint {
|
||||
constructor(accessToken: string) {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async details<T extends AppendToResponseTvSeasonKey[] | undefined>(
|
||||
seasonSelection: SeasonSelection,
|
||||
appendToResponse?: T,
|
||||
options?: LanguageOption
|
||||
) {
|
||||
const combinedOptions = {
|
||||
append_to_response: appendToResponse
|
||||
? appendToResponse.join(',')
|
||||
: undefined,
|
||||
...options,
|
||||
};
|
||||
|
||||
return await this.api.get<AppendToResponse<SeasonDetails, T, 'tvSeason'>>(
|
||||
`${BASE_SEASON(seasonSelection)}`,
|
||||
combinedOptions
|
||||
);
|
||||
}
|
||||
|
||||
async aggregateCredits(
|
||||
seasonSelection: SeasonSelection,
|
||||
options?: LanguageOption
|
||||
) {
|
||||
return await this.api.get<AggregateCredits>(
|
||||
`${BASE_SEASON(seasonSelection)}/aggregate_credits`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async changes(seasonId: number, options?: ChangeOption) {
|
||||
return await this.api.get<Changes<TvSeasonChangeValue>>(
|
||||
`/tv/season/${seasonId}/changes`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async credits(seasonSelection: SeasonSelection, options?: LanguageOption) {
|
||||
return await this.api.get<Credits>(
|
||||
`${BASE_SEASON(seasonSelection)}/credits`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async externalIds(
|
||||
seasonSelection: SeasonSelection,
|
||||
options?: LanguageOption
|
||||
) {
|
||||
return await this.api.get<ExternalIds>(
|
||||
`${BASE_SEASON(seasonSelection)}/external_ids`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async images(
|
||||
seasonSelection: SeasonSelection,
|
||||
options?: TvSeasonImageSearchOptions
|
||||
) {
|
||||
const computedOptions = {
|
||||
include_image_language: options?.include_image_language?.join(','),
|
||||
language: options?.language,
|
||||
};
|
||||
return await this.api.get<Images>(
|
||||
`${BASE_SEASON(seasonSelection)}/images`,
|
||||
computedOptions
|
||||
);
|
||||
}
|
||||
|
||||
async videos(
|
||||
seasonSelection: SeasonSelection,
|
||||
options?: TvSeasonVideoSearchOptions
|
||||
) {
|
||||
const computedOptions = {
|
||||
include_video_language: options?.include_video_language?.join(','),
|
||||
language: options?.language,
|
||||
};
|
||||
return await this.api.get<Videos>(
|
||||
`${BASE_SEASON(seasonSelection)}/videos`,
|
||||
computedOptions
|
||||
);
|
||||
}
|
||||
|
||||
async translations(
|
||||
seasonSelection: SeasonSelection,
|
||||
options?: LanguageOption
|
||||
) {
|
||||
return await this.api.get<Translations>(
|
||||
`${BASE_SEASON(seasonSelection)}/translations`,
|
||||
options
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
import { BaseEndpoint } from './base';
|
||||
import {
|
||||
AggregateCredits,
|
||||
AlternativeTitles,
|
||||
ChangeOptions,
|
||||
AppendToResponse,
|
||||
AppendToResponseTvKey,
|
||||
ChangeOption,
|
||||
Changes,
|
||||
ContentRatings,
|
||||
Credits,
|
||||
EpisodeGroups,
|
||||
@@ -14,20 +18,21 @@ import {
|
||||
PageOption,
|
||||
PopularTvShows,
|
||||
Recommendations,
|
||||
RegionOption,
|
||||
Reviews,
|
||||
ScreenedTheatrically,
|
||||
SeasonDetails,
|
||||
SimilarTvShows,
|
||||
TimezoneOption,
|
||||
TopRatedTvShows,
|
||||
Translations,
|
||||
TvShowChanges,
|
||||
TvShowImageOptions,
|
||||
TvShowVideoOptions,
|
||||
TvShowChangeValue,
|
||||
TvShowDetails,
|
||||
TvShowsAiringToday,
|
||||
Videos,
|
||||
WatchProviders,
|
||||
} from '../types';
|
||||
import { parseOptions } from '../utils';
|
||||
|
||||
const BASE_TV = '/tv';
|
||||
|
||||
@@ -36,8 +41,21 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async details(id: number): Promise<TvShowDetails> {
|
||||
return await this.api.get<TvShowDetails>(`${BASE_TV}/${id}`);
|
||||
async details<T extends AppendToResponseTvKey[] | undefined>(
|
||||
id: number,
|
||||
appendToResponse?: T,
|
||||
language?: string
|
||||
) {
|
||||
const options = {
|
||||
append_to_response: appendToResponse
|
||||
? appendToResponse.join(',')
|
||||
: undefined,
|
||||
language: language,
|
||||
};
|
||||
return await this.api.get<AppendToResponse<TvShowDetails, T, 'tvShow'>>(
|
||||
`${BASE_TV}/${id}`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async alternativeTitles(id: number): Promise<AlternativeTitles> {
|
||||
@@ -46,10 +64,13 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
||||
);
|
||||
}
|
||||
|
||||
async changes(id: number, options?: ChangeOptions): Promise<TvShowChanges> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<TvShowChanges>(
|
||||
`${BASE_TV}/${id}/changes?${params}`
|
||||
async changes(
|
||||
id: number,
|
||||
options?: ChangeOption
|
||||
): Promise<Changes<TvShowChangeValue>> {
|
||||
return await this.api.get<Changes<TvShowChangeValue>>(
|
||||
`${BASE_TV}/${id}/changes`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
@@ -59,8 +80,18 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
||||
);
|
||||
}
|
||||
|
||||
async credits(id: number): Promise<Credits> {
|
||||
return await this.api.get<Credits>(`${BASE_TV}/${id}/credits`);
|
||||
async aggregateCredits(
|
||||
id: number,
|
||||
options?: LanguageOption
|
||||
): Promise<AggregateCredits> {
|
||||
return await this.api.get<AggregateCredits>(
|
||||
`${BASE_TV}/${id}/aggregate_credits`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async credits(id: number, options?: LanguageOption): Promise<Credits> {
|
||||
return await this.api.get<Credits>(`${BASE_TV}/${id}/credits`, options);
|
||||
}
|
||||
|
||||
async season(tvId: number, seasonNumber: number): Promise<SeasonDetails> {
|
||||
@@ -77,8 +108,15 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
||||
return await this.api.get<ExternalIds>(`${BASE_TV}/${id}/external_ids`);
|
||||
}
|
||||
|
||||
async images(id: number): Promise<Images> {
|
||||
return await this.api.get<Images>(`${BASE_TV}/${id}/images`);
|
||||
async images(id: number, options?: TvShowImageOptions): Promise<Images> {
|
||||
const computedOptions = {
|
||||
include_image_language: options?.include_image_language?.join(','),
|
||||
language: options?.language,
|
||||
};
|
||||
return await this.api.get<Images>(
|
||||
`${BASE_TV}/${id}/images`,
|
||||
computedOptions
|
||||
);
|
||||
}
|
||||
|
||||
async keywords(id: number): Promise<Keywords> {
|
||||
@@ -87,17 +125,19 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
||||
|
||||
async recommendations(
|
||||
id: number,
|
||||
options?: PageOption
|
||||
options?: LanguageOption & PageOption
|
||||
): Promise<Recommendations> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<Recommendations>(
|
||||
`${BASE_TV}/${id}/recommendations?${params}`
|
||||
`${BASE_TV}/${id}/recommendations`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async reviews(id: number, options?: PageOption): Promise<Reviews> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<Reviews>(`${BASE_TV}/${id}/reviews?${params}`);
|
||||
async reviews(
|
||||
id: number,
|
||||
options?: LanguageOption & PageOption
|
||||
): Promise<Reviews> {
|
||||
return await this.api.get<Reviews>(`${BASE_TV}/${id}/reviews`, options);
|
||||
}
|
||||
|
||||
async screenedTheatrically(id: number): Promise<ScreenedTheatrically> {
|
||||
@@ -106,10 +146,13 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
||||
);
|
||||
}
|
||||
|
||||
async similar(id: number, options?: PageOption): Promise<SimilarTvShows> {
|
||||
const params = parseOptions(options);
|
||||
async similar(
|
||||
id: number,
|
||||
options?: LanguageOption & PageOption
|
||||
): Promise<SimilarTvShows> {
|
||||
return await this.api.get<SimilarTvShows>(
|
||||
`${BASE_TV}/${id}/similar?${params}`
|
||||
`${BASE_TV}/${id}/similar`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
@@ -117,8 +160,15 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
||||
return await this.api.get<Translations>(`${BASE_TV}/${id}/translations`);
|
||||
}
|
||||
|
||||
async videos(id: number): Promise<Videos> {
|
||||
return await this.api.get<Videos>(`${BASE_TV}/${id}/videos`);
|
||||
async videos(id: number, options?: TvShowVideoOptions): Promise<Videos> {
|
||||
const computedOptions = {
|
||||
include_video_language: options?.include_video_language?.join(','),
|
||||
language: options?.language,
|
||||
};
|
||||
return await this.api.get<Videos>(
|
||||
`${BASE_TV}/${id}/videos`,
|
||||
computedOptions
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,32 +185,30 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
||||
return await this.api.get<LatestTvShows>(`${BASE_TV}/latest`);
|
||||
}
|
||||
|
||||
async onTheAir(): Promise<OnTheAir> {
|
||||
return await this.api.get<OnTheAir>(`${BASE_TV}/on_the_air`);
|
||||
async onTheAir(
|
||||
options?: PageOption & LanguageOption & TimezoneOption
|
||||
): Promise<OnTheAir> {
|
||||
return await this.api.get<OnTheAir>(`${BASE_TV}/on_the_air`, options);
|
||||
}
|
||||
|
||||
async airingToday(
|
||||
options?: PageOption & LanguageOption & RegionOption
|
||||
options?: PageOption & LanguageOption & TimezoneOption
|
||||
): Promise<TvShowsAiringToday> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<TvShowsAiringToday>(
|
||||
`${BASE_TV}/airing_today?${params}`
|
||||
`${BASE_TV}/airing_today`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async popular(
|
||||
options?: PageOption & LanguageOption & RegionOption
|
||||
options?: PageOption & LanguageOption
|
||||
): Promise<PopularTvShows> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<PopularTvShows>(`${BASE_TV}/popular?${params}`);
|
||||
return await this.api.get<PopularTvShows>(`${BASE_TV}/popular`, options);
|
||||
}
|
||||
|
||||
async topRated(
|
||||
options?: PageOption & LanguageOption & RegionOption
|
||||
options?: PageOption & LanguageOption
|
||||
): Promise<TopRatedTvShows> {
|
||||
const params = parseOptions(options);
|
||||
return await this.api.get<TopRatedTvShows>(
|
||||
`${BASE_TV}/top_rated?${params}`
|
||||
);
|
||||
return await this.api.get<TopRatedTvShows>(`${BASE_TV}/top_rated`, options);
|
||||
}
|
||||
}
|
||||
|
||||
40
src/endpoints/watch-providers.ts
Normal file
40
src/endpoints/watch-providers.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import TMDB from './tmdb';
|
||||
import { TMDB } from './tmdb';
|
||||
|
||||
export * from './types';
|
||||
export * from './utils';
|
||||
|
||||
export default TMDB;
|
||||
export { TMDB };
|
||||
|
||||
27
src/tmdb.ts
27
src/tmdb.ts
@@ -15,9 +15,14 @@ import {
|
||||
FindEndpoint,
|
||||
KeywordsEndpoint,
|
||||
CollectionsEndpoint,
|
||||
TvSeasonsEndpoint,
|
||||
TvEpisodesEndpoint,
|
||||
WatchProvidersEndpoint,
|
||||
} from './endpoints';
|
||||
import { CompaniesEndpoint } from './endpoints/companies';
|
||||
import { NetworksEndpoint } from './endpoints/networks';
|
||||
|
||||
export default class TMDB {
|
||||
export class TMDB {
|
||||
private readonly accessToken: string;
|
||||
|
||||
constructor(accessToken: string) {
|
||||
@@ -44,6 +49,14 @@ export default class TMDB {
|
||||
return new CreditsEndpoint(this.accessToken);
|
||||
}
|
||||
|
||||
get companies(): CompaniesEndpoint {
|
||||
return new CompaniesEndpoint(this.accessToken);
|
||||
}
|
||||
|
||||
get networks(): NetworksEndpoint {
|
||||
return new NetworksEndpoint(this.accessToken);
|
||||
}
|
||||
|
||||
get search(): SearchEndpoint {
|
||||
return new SearchEndpoint(this.accessToken);
|
||||
}
|
||||
@@ -60,6 +73,10 @@ export default class TMDB {
|
||||
return new TvShowsEndpoint(this.accessToken);
|
||||
}
|
||||
|
||||
get tvEpisode(): TvEpisodesEndpoint {
|
||||
return new TvEpisodesEndpoint(this.accessToken);
|
||||
}
|
||||
|
||||
get discover(): DiscoverEndpoint {
|
||||
return new DiscoverEndpoint(this.accessToken);
|
||||
}
|
||||
@@ -87,4 +104,12 @@ export default class TMDB {
|
||||
get collections(): CollectionsEndpoint {
|
||||
return new CollectionsEndpoint(this.accessToken);
|
||||
}
|
||||
|
||||
get tvSeasons(): TvSeasonsEndpoint {
|
||||
return new TvSeasonsEndpoint(this.accessToken);
|
||||
}
|
||||
|
||||
get watchProviders(): WatchProvidersEndpoint {
|
||||
return new WatchProvidersEndpoint(this.accessToken);
|
||||
}
|
||||
}
|
||||
|
||||
19
src/types/account.ts
Normal file
19
src/types/account.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
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;
|
||||
}
|
||||
@@ -6,14 +6,56 @@ export interface Certification {
|
||||
|
||||
export interface Certifications {
|
||||
certifications: {
|
||||
US: Certification[];
|
||||
CA: Certification[];
|
||||
DE: Certification[];
|
||||
GB: Certification[];
|
||||
AR: Certification[];
|
||||
AT: Certification[];
|
||||
AU: Certification[];
|
||||
BG: Certification[];
|
||||
BR: Certification[];
|
||||
CA: Certification[];
|
||||
'CA-QC': Certification[];
|
||||
CH: Certification[];
|
||||
CL: Certification[];
|
||||
CZ: Certification[];
|
||||
DE: Certification[];
|
||||
DK: Certification[];
|
||||
ES: Certification[];
|
||||
FI: Certification[];
|
||||
FR: Certification[];
|
||||
NZ: 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[];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,17 +1,29 @@
|
||||
export interface Change {
|
||||
export interface MediaChange {
|
||||
id: number;
|
||||
adult: boolean | undefined;
|
||||
adult?: boolean;
|
||||
}
|
||||
|
||||
export interface Changes {
|
||||
results: Change[];
|
||||
export interface MediaChanges {
|
||||
results: MediaChange[];
|
||||
page: number;
|
||||
total_pages: number;
|
||||
total_results: number;
|
||||
}
|
||||
|
||||
export interface ChangeOptions {
|
||||
end_date?: string;
|
||||
start_date?: string;
|
||||
page?: number;
|
||||
export interface Changes<T> {
|
||||
changes: Change<T>[];
|
||||
}
|
||||
|
||||
export interface Change<T> {
|
||||
key: string;
|
||||
items: ChangeItem<T>[];
|
||||
}
|
||||
|
||||
export interface ChangeItem<T> {
|
||||
id: string;
|
||||
action: string;
|
||||
time: string;
|
||||
value: T;
|
||||
iso_639_1: string;
|
||||
original_value: T;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
import { Movie } from '.';
|
||||
import { LanguageOption, Movie } from '.';
|
||||
|
||||
export interface Collection {
|
||||
id: number;
|
||||
backdrop_path: string;
|
||||
name: string;
|
||||
poster_path: string;
|
||||
adult: boolean;
|
||||
original_language: string;
|
||||
original_name: string;
|
||||
overview: string;
|
||||
poster_path: string;
|
||||
backdrop_path: string;
|
||||
}
|
||||
|
||||
export interface DetailedCollection extends Collection {
|
||||
export interface CollectionDetails extends Collection {
|
||||
parts: Movie[];
|
||||
}
|
||||
|
||||
export interface CollectionImageOptions extends LanguageOption {
|
||||
/**
|
||||
* a list of ISO-639-1 values to query
|
||||
*/
|
||||
include_image_language?: string[];
|
||||
}
|
||||
|
||||
33
src/types/companies.ts
Normal file
33
src/types/companies.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Image } from '.';
|
||||
|
||||
export interface CompanyDetails {
|
||||
description: string;
|
||||
headquarters: string;
|
||||
homepage: string;
|
||||
id: number;
|
||||
logo_path: string;
|
||||
name: string;
|
||||
origin_country: string;
|
||||
parent_company?: ParentCompany;
|
||||
}
|
||||
|
||||
export interface ParentCompany {
|
||||
name: string;
|
||||
id: number;
|
||||
logo_path: string;
|
||||
}
|
||||
|
||||
export interface AlternativeNames {
|
||||
id: number;
|
||||
results: Name[];
|
||||
}
|
||||
|
||||
export interface Name {
|
||||
name: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface CompanyImages {
|
||||
id: number;
|
||||
logos: Image[];
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
export interface Images {
|
||||
import { CountryCode } from '../types';
|
||||
|
||||
export interface ImageConfiguration {
|
||||
base_url: string;
|
||||
secure_base_url: string;
|
||||
backdrop_sizes: BackdropSizes[];
|
||||
@@ -9,103 +11,157 @@ export interface Images {
|
||||
}
|
||||
|
||||
export interface Configuration {
|
||||
images: Images;
|
||||
images: ImageConfiguration;
|
||||
change_keys: ChangeKeys[];
|
||||
}
|
||||
|
||||
export const enum BackdropSizes {
|
||||
W300 = 'w300',
|
||||
W780 = 'w780',
|
||||
W1280 = 'w1280',
|
||||
ORIGINAL = 'original',
|
||||
export interface CountryConfiguration {
|
||||
iso_3166_1: CountryCode;
|
||||
english_name: string;
|
||||
native_name: string;
|
||||
}
|
||||
|
||||
export const enum LogoSizes {
|
||||
W45 = 'w45',
|
||||
W92 = 'w92',
|
||||
W154 = 'w154',
|
||||
W185 = 'w185',
|
||||
W300 = 'w300',
|
||||
W500 = 'w500',
|
||||
ORIGINAL = 'original',
|
||||
export interface LanguageConfiguration {
|
||||
iso_639_1: string;
|
||||
english_name: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export const enum PosterSizes {
|
||||
W92 = 'w92',
|
||||
W154 = 'w154',
|
||||
W185 = 'w185',
|
||||
W300 = 'w300',
|
||||
W500 = 'w500',
|
||||
W780 = 'w780',
|
||||
ORIGINAL = 'original',
|
||||
export interface JobConfiguration {
|
||||
department: string;
|
||||
jobs: string[];
|
||||
}
|
||||
|
||||
export const enum ProfileSizes {
|
||||
W45 = 'w45',
|
||||
W185 = 'w185',
|
||||
W632 = 'w632',
|
||||
ORIGINAL = 'original',
|
||||
export interface TimezoneConfiguration {
|
||||
iso_3166_1: CountryCode;
|
||||
zones: string[];
|
||||
}
|
||||
|
||||
export const enum StillSizes {
|
||||
W92 = 'w92',
|
||||
W185 = 'w185',
|
||||
W300 = 'w300',
|
||||
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 enum ChangeKeys {
|
||||
ADULT = 'adult',
|
||||
AIR_DATE = 'air_date',
|
||||
ALSO_KNOWN_AS = 'also_known_as',
|
||||
ALTERNATIVE_TITLES = 'alternative_titles',
|
||||
BIOGRAPHY = 'biography',
|
||||
BIRTHDAY = 'birthday',
|
||||
BUDGET = 'budget',
|
||||
CAST = 'cast',
|
||||
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',
|
||||
}
|
||||
export const BackdropSize = {
|
||||
W45: 'w45',
|
||||
W92: 'w92',
|
||||
W154: 'w154',
|
||||
W185: 'w185',
|
||||
W300: 'w300',
|
||||
W500: 'w500',
|
||||
W780: 'w780',
|
||||
W1280: 'w1280',
|
||||
ORIGINAL: 'original',
|
||||
} as const;
|
||||
|
||||
type BackdropSizes = (typeof BackdropSize)[keyof typeof BackdropSize];
|
||||
|
||||
export const LogoSize = {
|
||||
W45: 'w45',
|
||||
W92: 'w92',
|
||||
W154: 'w154',
|
||||
W185: 'w185',
|
||||
W300: 'w300',
|
||||
W500: 'w500',
|
||||
ORIGINAL: 'original',
|
||||
} as const;
|
||||
|
||||
type LogoSizes = (typeof LogoSize)[keyof typeof LogoSize];
|
||||
|
||||
export const PosterSize = {
|
||||
W92: 'w92',
|
||||
W154: 'w154',
|
||||
W185: 'w185',
|
||||
W300: 'w300',
|
||||
W342: 'w342',
|
||||
W500: 'w500',
|
||||
W780: 'w780',
|
||||
ORIGINAL: 'original',
|
||||
} as const;
|
||||
|
||||
type PosterSizes = (typeof PosterSize)[keyof typeof PosterSize];
|
||||
|
||||
export const ProfileSize = {
|
||||
W45: 'w45',
|
||||
W185: 'w185',
|
||||
W632: 'w632',
|
||||
ORIGINAL: 'original',
|
||||
} as const;
|
||||
|
||||
type ProfileSizes = (typeof ProfileSize)[keyof typeof ProfileSize];
|
||||
|
||||
export const StillSize = {
|
||||
W92: 'w92',
|
||||
W185: 'w185',
|
||||
W300: 'w300',
|
||||
ORIGINAL: 'original',
|
||||
} as const;
|
||||
|
||||
type StillSizes = (typeof StillSize)[keyof typeof StillSize];
|
||||
|
||||
export const ChangeKey = {
|
||||
ADULT: 'adult',
|
||||
AIR_DATE: 'air_date',
|
||||
ALSO_KNOWN_AS: 'also_known_as',
|
||||
ALTERNATIVE_TITLES: 'alternative_titles',
|
||||
BIOGRAPHY: 'biography',
|
||||
BIRTHDAY: 'birthday',
|
||||
BUDGET: 'budget',
|
||||
CAST: 'cast',
|
||||
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];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Image, Person } from './';
|
||||
import { CountryCode, Image, Person } from './';
|
||||
|
||||
export interface CreditSeason {
|
||||
air_date?: string;
|
||||
@@ -7,7 +7,7 @@ export interface CreditSeason {
|
||||
}
|
||||
|
||||
export interface Media {
|
||||
i?: number;
|
||||
id?: number;
|
||||
name?: string;
|
||||
first_air_date?: string;
|
||||
vote_count?: number;
|
||||
@@ -15,6 +15,8 @@ export interface Media {
|
||||
vote_average?: number;
|
||||
backdrop_path?: string;
|
||||
genre_ids?: number[];
|
||||
media_type: string;
|
||||
adult: boolean;
|
||||
original_name?: string;
|
||||
origin_country?: string[];
|
||||
poster_path?: string;
|
||||
@@ -36,7 +38,7 @@ export interface CreditResponse {
|
||||
}
|
||||
|
||||
export interface Title {
|
||||
iso_3166_1: string;
|
||||
iso_3166_1: CountryCode;
|
||||
title: string;
|
||||
type: string;
|
||||
}
|
||||
@@ -89,7 +91,7 @@ export interface ImageCollection {
|
||||
export interface Video {
|
||||
id: string;
|
||||
iso_639_1: string;
|
||||
iso_3166_1: string;
|
||||
iso_3166_1: CountryCode;
|
||||
key: string;
|
||||
name: string;
|
||||
site: string;
|
||||
@@ -101,3 +103,49 @@ export interface Videos {
|
||||
id: number;
|
||||
results: Video[];
|
||||
}
|
||||
|
||||
export interface AggregateCredits {
|
||||
id: number;
|
||||
cast: AggregateCast[];
|
||||
crew: AggregateCrew[];
|
||||
}
|
||||
|
||||
export interface CastRole {
|
||||
credit_id: string;
|
||||
character: string;
|
||||
episode_count: number;
|
||||
}
|
||||
|
||||
export interface AggregateCast {
|
||||
adult: boolean;
|
||||
gender: number;
|
||||
id: number;
|
||||
known_for_department: string;
|
||||
name: string;
|
||||
original_name: string;
|
||||
popularity: number;
|
||||
profile_path: string;
|
||||
roles: CastRole[];
|
||||
total_episode_count: number;
|
||||
order: number;
|
||||
}
|
||||
|
||||
export interface CrewJob {
|
||||
credit_id: string;
|
||||
job: string;
|
||||
episode_count: number;
|
||||
}
|
||||
|
||||
export interface AggregateCrew {
|
||||
adult: boolean;
|
||||
gender: number;
|
||||
id: number;
|
||||
known_for_department: string;
|
||||
name: string;
|
||||
original_name: string;
|
||||
popularity: number;
|
||||
profile_path: string;
|
||||
jobs: CrewJob[];
|
||||
department: string;
|
||||
total_episode_count: number;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,67 @@
|
||||
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 =
|
||||
| 'first_air_date.asc'
|
||||
| 'first_air_date.desc'
|
||||
| 'popularity.asc'
|
||||
| 'popularity.desc'
|
||||
| 'release_date.asc'
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
export * from './options';
|
||||
export * from './certification';
|
||||
export * from './credits';
|
||||
export * from './companies';
|
||||
export * from './networks';
|
||||
export * from './configuration';
|
||||
export * from './changes';
|
||||
export * from './movies';
|
||||
@@ -14,6 +16,16 @@ export * from './trending';
|
||||
export * from './find';
|
||||
export * from './keywords';
|
||||
export * from './collections';
|
||||
export * from './tv-episode';
|
||||
export * from './tv-seasons';
|
||||
|
||||
export interface ErrorResponse {
|
||||
status_code: number;
|
||||
status_message: string;
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
export type MediaType = 'movie' | 'tv' | 'person';
|
||||
|
||||
export interface AuthorDetails {
|
||||
name: string;
|
||||
@@ -22,27 +34,12 @@ export interface AuthorDetails {
|
||||
rating?: number;
|
||||
}
|
||||
|
||||
export interface KnownFor {
|
||||
id: number;
|
||||
overview: string;
|
||||
release_date: string;
|
||||
video: boolean;
|
||||
adult: boolean;
|
||||
backdrop_path: string;
|
||||
media_type: string;
|
||||
genre_ids: number[];
|
||||
title: string;
|
||||
original_language: string;
|
||||
original_title: string;
|
||||
poster_path: string;
|
||||
vote_count: number;
|
||||
vote_average: number;
|
||||
popularity: number;
|
||||
}
|
||||
export type KnownFor = MovieWithMediaType | TVWithMediaType;
|
||||
|
||||
export interface Person {
|
||||
id: number;
|
||||
name: string;
|
||||
original_name: string;
|
||||
known_for: KnownFor[];
|
||||
profile_path: string;
|
||||
adult: boolean;
|
||||
@@ -51,6 +48,10 @@ export interface Person {
|
||||
popularity: number;
|
||||
}
|
||||
|
||||
export interface PersonWithMediaType extends Person {
|
||||
media_type: 'person';
|
||||
}
|
||||
|
||||
export interface Movie {
|
||||
id: number;
|
||||
poster_path: string;
|
||||
@@ -68,6 +69,10 @@ export interface Movie {
|
||||
vote_average: number;
|
||||
}
|
||||
|
||||
export interface MovieWithMediaType extends Movie {
|
||||
media_type: 'movie';
|
||||
}
|
||||
|
||||
export interface Company {
|
||||
id: number;
|
||||
logo_path: string;
|
||||
@@ -77,6 +82,7 @@ export interface Company {
|
||||
|
||||
export interface TV {
|
||||
id: number;
|
||||
adult: boolean;
|
||||
name: string;
|
||||
first_air_date: string;
|
||||
backdrop_path: string;
|
||||
@@ -91,6 +97,10 @@ export interface TV {
|
||||
vote_average: number;
|
||||
}
|
||||
|
||||
export interface TVWithMediaType extends TV {
|
||||
media_type: 'tv';
|
||||
}
|
||||
|
||||
export interface Genre {
|
||||
id: number;
|
||||
name: string;
|
||||
@@ -101,6 +111,13 @@ export interface ExternalIds {
|
||||
facebook_id: string;
|
||||
instagram_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;
|
||||
}
|
||||
|
||||
@@ -112,7 +129,7 @@ export interface ProductionCompany {
|
||||
}
|
||||
|
||||
export interface ProductionCountry {
|
||||
iso_3166_1: string;
|
||||
iso_3166_1: CountryCode;
|
||||
name: string;
|
||||
}
|
||||
|
||||
@@ -128,20 +145,21 @@ export interface ContentRatings {
|
||||
}
|
||||
|
||||
export interface ContentRatingsResult {
|
||||
iso_3166_1: string;
|
||||
descriptor: unknown[];
|
||||
iso_3166_1: CountryCode;
|
||||
rating: string;
|
||||
}
|
||||
|
||||
export interface Recommendation {
|
||||
adult: boolean;
|
||||
backdrop_path?: any;
|
||||
backdrop_path?: string;
|
||||
genre_ids: number[];
|
||||
id: number;
|
||||
original_language: string;
|
||||
original_title: string;
|
||||
overview: string;
|
||||
release_date: string;
|
||||
poster_path?: any;
|
||||
poster_path?: string;
|
||||
popularity: number;
|
||||
title: string;
|
||||
video: boolean;
|
||||
@@ -160,9 +178,9 @@ export interface Review {
|
||||
author: string;
|
||||
author_details: AuthorDetails;
|
||||
content: string;
|
||||
created_at: Date;
|
||||
created_at: string;
|
||||
id: string;
|
||||
updated_at: Date;
|
||||
updated_at: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
@@ -181,7 +199,7 @@ export interface TranslationData {
|
||||
}
|
||||
|
||||
export interface Translation {
|
||||
iso_3166_1: string;
|
||||
iso_3166_1: CountryCode;
|
||||
iso_639_1: string;
|
||||
name: string;
|
||||
english_name: string;
|
||||
@@ -202,3 +220,78 @@ export interface Image {
|
||||
vote_count: 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];
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Movie } from '.';
|
||||
import { PageOption } from './options';
|
||||
|
||||
export interface KeywordsOptions {
|
||||
export interface KeywordsOptions extends PageOption {
|
||||
include_adult?: boolean;
|
||||
language?: string;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
CountryCode,
|
||||
Genre,
|
||||
Movie,
|
||||
ProductionCompany,
|
||||
@@ -6,20 +7,27 @@ import {
|
||||
SpokenLanguage,
|
||||
} from './';
|
||||
|
||||
export interface BelongsToCollection {
|
||||
id: number;
|
||||
name: string;
|
||||
poster_path: string;
|
||||
backdrop_path: string;
|
||||
}
|
||||
|
||||
export interface MovieDetails {
|
||||
adult: boolean;
|
||||
backdrop_path: string;
|
||||
belongs_to_collection?: any;
|
||||
belongs_to_collection?: BelongsToCollection;
|
||||
budget: number;
|
||||
genres: Genre[];
|
||||
homepage: string;
|
||||
id: number;
|
||||
imdb_id: string;
|
||||
imdb_id: string | null;
|
||||
original_language: string;
|
||||
original_title: string;
|
||||
overview: string;
|
||||
popularity: number;
|
||||
poster_path?: any;
|
||||
poster_path?: string;
|
||||
production_companies: ProductionCompany[];
|
||||
production_countries: ProductionCountry[];
|
||||
release_date: string;
|
||||
@@ -45,14 +53,15 @@ export enum ReleaseDateType {
|
||||
|
||||
export interface ReleaseDate {
|
||||
certification: string;
|
||||
descriptors: string[];
|
||||
iso_639_1: string;
|
||||
release_date: Date;
|
||||
release_date: string;
|
||||
type: ReleaseDateType;
|
||||
note: string;
|
||||
}
|
||||
|
||||
export interface ReleaseDateResult {
|
||||
iso_3166_1: string;
|
||||
iso_3166_1: CountryCode;
|
||||
release_dates: ReleaseDate[];
|
||||
}
|
||||
|
||||
@@ -87,44 +96,26 @@ export interface MovieLists {
|
||||
total_results: number;
|
||||
}
|
||||
|
||||
export interface MovieChangeItem {
|
||||
id: string;
|
||||
action: string;
|
||||
time: string;
|
||||
iso_639_1: string;
|
||||
value: string;
|
||||
original_value: string;
|
||||
}
|
||||
|
||||
export interface MovieChange {
|
||||
key: string;
|
||||
items: MovieChangeItem[];
|
||||
}
|
||||
|
||||
export interface MovieChanges {
|
||||
changes: MovieChange[];
|
||||
}
|
||||
|
||||
export interface LatestMovie {
|
||||
adult: boolean;
|
||||
backdrop_path?: any;
|
||||
belongs_to_collection?: any;
|
||||
backdrop_path?: string;
|
||||
belongs_to_collection?: BelongsToCollection;
|
||||
budget: number;
|
||||
genres: Genre[];
|
||||
homepage: string;
|
||||
id: number;
|
||||
imdb_id: string;
|
||||
imdb_id: string | null;
|
||||
original_language: string;
|
||||
original_title: string;
|
||||
overview: string;
|
||||
popularity: number;
|
||||
poster_path: string;
|
||||
production_companies: any[];
|
||||
production_countries: any[];
|
||||
production_companies: ProductionCompany[];
|
||||
production_countries: ProductionCountry[];
|
||||
release_date: string;
|
||||
revenue: number;
|
||||
runtime: number;
|
||||
spoken_languages: any[];
|
||||
spoken_languages: SpokenLanguage[];
|
||||
status: string;
|
||||
tagline: string;
|
||||
title: string;
|
||||
@@ -166,3 +157,14 @@ export interface UpcomingMovies {
|
||||
total_results: number;
|
||||
total_pages: number;
|
||||
}
|
||||
|
||||
export type MovieChangeValue =
|
||||
| string
|
||||
| {
|
||||
person_id: number;
|
||||
character: string;
|
||||
order: number;
|
||||
cast_id: number;
|
||||
credit_id: string;
|
||||
}
|
||||
| unknown;
|
||||
|
||||
15
src/types/networks.ts
Normal file
15
src/types/networks.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Image } from '.';
|
||||
|
||||
export interface NetworkDetails {
|
||||
headquarters: string;
|
||||
homepage: string;
|
||||
id: number;
|
||||
logo_path: string;
|
||||
name: string;
|
||||
origin_country: string;
|
||||
}
|
||||
|
||||
export interface NetworkImages {
|
||||
id: number;
|
||||
logos: Image[];
|
||||
}
|
||||
@@ -1,11 +1,389 @@
|
||||
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 {
|
||||
language?: string;
|
||||
language?: AvailableLanguage;
|
||||
}
|
||||
|
||||
export interface WatchRegionOption {
|
||||
watch_region?: CountryCode;
|
||||
}
|
||||
|
||||
export interface RegionOption {
|
||||
region?: string;
|
||||
}
|
||||
|
||||
export interface TimezoneOption {
|
||||
timezone?: string;
|
||||
}
|
||||
|
||||
export interface PageOption {
|
||||
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);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Movie, Person, TV } from '.';
|
||||
import { CountryCode, Image, Movie, Person, TV } from '.';
|
||||
|
||||
interface Cast {
|
||||
character: string;
|
||||
@@ -79,7 +79,7 @@ export interface PersonCombinedCredits {
|
||||
id: number;
|
||||
}
|
||||
|
||||
export interface PersonDetail {
|
||||
export interface PersonDetails {
|
||||
birthday: string;
|
||||
known_for_department: string;
|
||||
deathday: string;
|
||||
@@ -96,30 +96,26 @@ export interface PersonDetail {
|
||||
homepage: string;
|
||||
}
|
||||
|
||||
export interface PersonChange {
|
||||
id: string;
|
||||
action: string;
|
||||
time: string;
|
||||
iso_639_1: string;
|
||||
iso_3166_1: string;
|
||||
value: string | { profile: { file_path: string } };
|
||||
original_value: string | { profile: { file_path: string } };
|
||||
}
|
||||
export type PersonChangeValue =
|
||||
| string
|
||||
| {
|
||||
profile: {
|
||||
file_path: string;
|
||||
};
|
||||
};
|
||||
|
||||
export interface PersonChanges {
|
||||
changes: {
|
||||
key: string;
|
||||
items: PersonChange[];
|
||||
}[];
|
||||
}
|
||||
|
||||
export interface PopularPersons {
|
||||
export interface PopularPeople {
|
||||
page: number;
|
||||
results: Person[];
|
||||
total_results: number;
|
||||
total_pages: number;
|
||||
}
|
||||
|
||||
export interface PeopleImages {
|
||||
id: number;
|
||||
profiles: Image[];
|
||||
}
|
||||
|
||||
export interface TaggedImage {
|
||||
aspect_ratio: number;
|
||||
file_path: string;
|
||||
@@ -141,10 +137,10 @@ export interface TaggedImages {
|
||||
total_pages: number;
|
||||
}
|
||||
|
||||
export interface PeopleTranslations {
|
||||
export interface PersonTranslations {
|
||||
id: number;
|
||||
translations: {
|
||||
iso_3166_1: string;
|
||||
iso_3166_1: CountryCode;
|
||||
iso_639_1: string;
|
||||
name: string;
|
||||
english_name: string;
|
||||
|
||||
7
src/types/regions.ts
Normal file
7
src/types/regions.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { CountryCode } from '../types';
|
||||
|
||||
export interface Region {
|
||||
iso_3166_1: CountryCode;
|
||||
english_name: string;
|
||||
native_name: string;
|
||||
}
|
||||
@@ -1,6 +1,13 @@
|
||||
import { MovieWithMediaType, PersonWithMediaType, TVWithMediaType } from '.';
|
||||
|
||||
export interface Search<T> {
|
||||
page: number;
|
||||
results: T[];
|
||||
total_pages: number;
|
||||
total_results: number;
|
||||
}
|
||||
|
||||
export type MultiSearchResult =
|
||||
| MovieWithMediaType
|
||||
| TVWithMediaType
|
||||
| PersonWithMediaType;
|
||||
|
||||
@@ -1,19 +1,28 @@
|
||||
import { Movie, Person, TV } from '.';
|
||||
export type MediaType = 'all' | 'movie' | 'tv' | 'person';
|
||||
import {
|
||||
Movie,
|
||||
Person,
|
||||
TV,
|
||||
MediaType,
|
||||
MovieWithMediaType,
|
||||
TVWithMediaType,
|
||||
PersonWithMediaType,
|
||||
} from '.';
|
||||
|
||||
export type TimeWindow = 'day' | 'week';
|
||||
|
||||
type TrendingResult<T extends MediaType> = T extends 'tv'
|
||||
export type TrendingMediaType = MediaType | 'all';
|
||||
|
||||
type TrendingResult<T extends TrendingMediaType> = T extends 'tv'
|
||||
? TV
|
||||
: T extends 'movie'
|
||||
? Movie
|
||||
: T extends 'person'
|
||||
? Person
|
||||
: TV | Movie | Person;
|
||||
? Movie
|
||||
: T extends 'person'
|
||||
? Person
|
||||
: TVWithMediaType | MovieWithMediaType | PersonWithMediaType;
|
||||
|
||||
export interface TrendingResults<T extends MediaType> {
|
||||
export interface TrendingResults<T extends TrendingMediaType> {
|
||||
page: number;
|
||||
results: (TrendingResult<T> & { media_type: MediaType })[];
|
||||
results: TrendingResult<T>[];
|
||||
total_pages: number;
|
||||
total_results: number;
|
||||
}
|
||||
|
||||
58
src/types/tv-episode.ts
Normal file
58
src/types/tv-episode.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
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;
|
||||
23
src/types/tv-seasons.ts
Normal file
23
src/types/tv-seasons.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Episode } from '.';
|
||||
|
||||
export interface SeasonSelection {
|
||||
tvShowID: number;
|
||||
seasonNumber: number;
|
||||
}
|
||||
|
||||
export interface SeasonDetails {
|
||||
air_date: string;
|
||||
episodes: Episode[];
|
||||
name: string;
|
||||
overview: string;
|
||||
id: number;
|
||||
poster_path: string | null;
|
||||
season_number: number;
|
||||
}
|
||||
|
||||
export type TvSeasonChangeValue =
|
||||
| string
|
||||
| {
|
||||
episode_id: number;
|
||||
episode_number: number;
|
||||
};
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
ProductionCompany,
|
||||
ProductionCountry,
|
||||
SpokenLanguage,
|
||||
Crew,
|
||||
LanguageOption,
|
||||
} from './';
|
||||
|
||||
export interface CreatedBy {
|
||||
@@ -14,6 +14,21 @@ export interface CreatedBy {
|
||||
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 {
|
||||
air_date: string;
|
||||
episode_number: number;
|
||||
@@ -57,7 +72,7 @@ export interface TvShowDetails {
|
||||
last_air_date: string;
|
||||
last_episode_to_air: LastEpisodeToAir;
|
||||
name: string;
|
||||
next_episode_to_air?: any;
|
||||
next_episode_to_air?: NextEpisodeToAir;
|
||||
networks: Network[];
|
||||
number_of_episodes: number;
|
||||
number_of_seasons: number;
|
||||
@@ -78,65 +93,6 @@ export interface TvShowDetails {
|
||||
vote_count: number;
|
||||
}
|
||||
|
||||
export interface GuestStar {
|
||||
credit_id: string;
|
||||
order: number;
|
||||
character: string;
|
||||
adult: boolean;
|
||||
gender: number | null;
|
||||
id: number;
|
||||
known_for_department: string;
|
||||
name: string;
|
||||
original_name: string;
|
||||
popularity: number;
|
||||
profile_path: string | null;
|
||||
}
|
||||
|
||||
export interface Episode {
|
||||
air_date: string;
|
||||
episode_number: number;
|
||||
crew: Crew[];
|
||||
guest_stars: GuestStar[];
|
||||
id: number;
|
||||
name: string;
|
||||
overview: string;
|
||||
production_code: string;
|
||||
season_number: number;
|
||||
still_path: string;
|
||||
vote_average: number;
|
||||
vote_count: number;
|
||||
show_id: number;
|
||||
runtime: number;
|
||||
}
|
||||
|
||||
export interface SeasonDetails {
|
||||
air_date: string;
|
||||
episodes: Episode[];
|
||||
name: string;
|
||||
overview: string;
|
||||
id: number;
|
||||
poster_path: string | null;
|
||||
season_number: number;
|
||||
}
|
||||
|
||||
export interface TvShowItem {
|
||||
id: string;
|
||||
action: string;
|
||||
time: string;
|
||||
value: any;
|
||||
iso_639_1: string;
|
||||
original_value: any;
|
||||
}
|
||||
|
||||
export interface TvShowChange {
|
||||
key: string;
|
||||
items: TvShowItem[];
|
||||
}
|
||||
|
||||
export interface TvShowChanges {
|
||||
changes: TvShowChange[];
|
||||
}
|
||||
|
||||
export interface Network {
|
||||
id: number;
|
||||
logo_path: string;
|
||||
@@ -194,8 +150,8 @@ export interface SimilarTvShows {
|
||||
}
|
||||
|
||||
export interface LatestTvShows {
|
||||
backdrop_path?: any;
|
||||
created_by: any[];
|
||||
backdrop_path?: string;
|
||||
created_by: CreatedBy[];
|
||||
episode_run_time: number[];
|
||||
first_air_date: string;
|
||||
genres: Genre[];
|
||||
@@ -211,10 +167,10 @@ export interface LatestTvShows {
|
||||
origin_country: string[];
|
||||
original_language: string;
|
||||
original_name: string;
|
||||
overview?: any;
|
||||
overview?: string;
|
||||
popularity: number;
|
||||
poster_path?: any;
|
||||
production_companies: any[];
|
||||
poster_path?: string;
|
||||
production_companies: ProductionCompany[];
|
||||
seasons: Season[];
|
||||
status: string;
|
||||
type: string;
|
||||
@@ -313,3 +269,22 @@ export interface TopRatedTvShows {
|
||||
total_results: number;
|
||||
total_pages: number;
|
||||
}
|
||||
|
||||
export interface TvShowChangeValue {
|
||||
season_id: number;
|
||||
season_number: number;
|
||||
}
|
||||
|
||||
export interface TvShowImageOptions extends LanguageOption {
|
||||
/**
|
||||
* a list of ISO-639-1 values to query
|
||||
*/
|
||||
include_image_language?: string[];
|
||||
}
|
||||
|
||||
export interface TvShowVideoOptions extends LanguageOption {
|
||||
/**
|
||||
* a list of ISO-639-1 values to query
|
||||
*/
|
||||
include_video_language?: string[];
|
||||
}
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
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 {
|
||||
display_priority: number;
|
||||
logo_path: string;
|
||||
|
||||
@@ -12,7 +12,7 @@ export const getFullImagePath = (
|
||||
baseUrl: string,
|
||||
fileSize: string,
|
||||
imagePath: string,
|
||||
svg = false
|
||||
svg: boolean = false
|
||||
): string => {
|
||||
const imagePathArr = imagePath.split('.');
|
||||
const imageFormat = svg ? 'svg' : imagePathArr[1];
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
export function parseOptions(options?: { [s: string]: any }): string {
|
||||
return options ? new URLSearchParams(Object.entries(options)).toString() : '';
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
export function parseOptions(options?: Record<string, any>): string {
|
||||
return options
|
||||
? new URLSearchParams(
|
||||
Object.entries(options).filter(([, v]) => v) // remove undefined
|
||||
).toString()
|
||||
: '';
|
||||
}
|
||||
|
||||
@@ -1,28 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"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'. */,
|
||||
"target": "esnext" /* 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'. */,
|
||||
"moduleResolution": "bundler",
|
||||
"sourceMap": true /* Generates corresponding '.map' file. */,
|
||||
"outDir": "dist" /* Redirect output structure to the directory. */,
|
||||
"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"],
|
||||
"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. */,
|
||||
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
|
||||
"typeRoots": [
|
||||
"./src/types"
|
||||
]
|
||||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
|
||||
"typeRoots": ["./src/types", "./node_modules/@types"]
|
||||
},
|
||||
"types": ["node"],
|
||||
"include": [
|
||||
"src"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"dist",
|
||||
"./src/types/*.ts"
|
||||
]
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "dist", "./src/types/*.ts"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user