Compare commits
1 Commits
blakejoy-p
...
blakejoy-n
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77d3a6cea7 |
41
.eslintrc.js
41
.eslintrc.js
@@ -2,21 +2,42 @@ module.exports = {
|
|||||||
env: {
|
env: {
|
||||||
browser: false,
|
browser: false,
|
||||||
es2021: true,
|
es2021: true,
|
||||||
node: true,
|
|
||||||
},
|
},
|
||||||
extends: [
|
extends: [
|
||||||
"eslint:recommended",
|
'plugin:@typescript-eslint/recommended',
|
||||||
"plugin:@typescript-eslint/eslint-recommended",
|
|
||||||
"plugin:@typescript-eslint/recommended",
|
|
||||||
"prettier",
|
|
||||||
],
|
],
|
||||||
parser: "@typescript-eslint/parser",
|
parser: '@typescript-eslint/parser',
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
ecmaVersion: 12,
|
ecmaVersion: 12,
|
||||||
sourceType: "module",
|
sourceType: 'module',
|
||||||
},
|
},
|
||||||
rules:{
|
plugins: [
|
||||||
'linebreak-style': ['off', 'unix'],
|
'@typescript-eslint',
|
||||||
|
],
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/no-var-requires': 'off',
|
||||||
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
|
'@typescript-eslint/interface-name-prefix': 'off',
|
||||||
|
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||||
|
'@typescript-eslint/no-use-before-define': 'off',
|
||||||
|
'@typescript-eslint/no-empty-interface': 'off',
|
||||||
|
'@typescript-eslint/explicit-function-return-type': ['warn', { allowExpressions: true }],
|
||||||
|
indent: 'off',
|
||||||
|
'@typescript-eslint/indent': ['error', 2],
|
||||||
|
'no-trailing-spaces': 'error',
|
||||||
|
quotes: ['error', 'single', { allowTemplateLiterals: true }],
|
||||||
|
semi: ['error', 'always'],
|
||||||
|
'spaced-comment': ['error', 'always'],
|
||||||
|
'no-irregular-whitespace': ['error', { 'skipComments': true }],
|
||||||
|
'space-infix-ops': 'error',
|
||||||
|
'array-bracket-spacing': 'error',
|
||||||
|
'object-curly-spacing': ['error', 'always'],
|
||||||
|
'space-before-function-paren': ['error', {
|
||||||
|
named: 'never',
|
||||||
|
anonymous: 'never',
|
||||||
|
asyncArrow: 'always',
|
||||||
|
}],
|
||||||
|
'comma-dangle': ['warn', 'always-multiline'],
|
||||||
|
'no-multiple-empty-lines': 'error',
|
||||||
},
|
},
|
||||||
plugins: ["@typescript-eslint"],
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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"
|
|
||||||
}
|
|
||||||
@@ -14,10 +14,8 @@ Installation:
|
|||||||
npm install --save tmdb-ts
|
npm install --save tmdb-ts
|
||||||
``
|
``
|
||||||
|
|
||||||
Version 1.0 removed the default import so make sure you update accordingly!
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import { TMDB } from 'tmdb-ts';
|
import TMDB from 'tmdb-ts';
|
||||||
|
|
||||||
const tmdb = new TMDB('accessToken');
|
const tmdb = new TMDB('accessToken');
|
||||||
|
|
||||||
|
|||||||
4126
package-lock.json
generated
4126
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
35
package.json
35
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tmdb-ts",
|
"name": "tmdb-ts",
|
||||||
"version": "1.0.0",
|
"version": "0.1.8",
|
||||||
"description": "TMDB v3 library wrapper",
|
"description": "TMDB v3 library wrapper",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@@ -8,8 +8,7 @@
|
|||||||
"compile": "rm -rf dist && tsc -d && npm run copy-types",
|
"compile": "rm -rf dist && tsc -d && npm run copy-types",
|
||||||
"lint": "eslint --ext .ts src/",
|
"lint": "eslint --ext .ts src/",
|
||||||
"lint:fix": "eslint --ext .ts src/ --fix",
|
"lint:fix": "eslint --ext .ts src/ --fix",
|
||||||
"format": "npx prettier --write src",
|
"prepublish": "tsc",
|
||||||
"pre-commit": "npm run lint",
|
|
||||||
"copy-types": "mkdir dist/types && cp src/types/*.d.ts dist/types"
|
"copy-types": "mkdir dist/types && cp src/types/*.d.ts dist/types"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
@@ -30,32 +29,24 @@
|
|||||||
"author": "Blake Joynes",
|
"author": "Blake Joynes",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^18.15.11",
|
"@types/node": "^15.3.0",
|
||||||
"@types/node-fetch": "^2.5.10",
|
"@types/node-fetch": "^2.5.10",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.58.0",
|
"@typescript-eslint/eslint-plugin": "^4.23.0",
|
||||||
"@typescript-eslint/parser": "^5.58.0",
|
"@typescript-eslint/parser": "^4.23.0",
|
||||||
"dotenv": "^9.0.2",
|
"dotenv": "^9.0.2",
|
||||||
"eslint": "^8.38.0",
|
"eslint": "^7.26.0",
|
||||||
"eslint-config-airbnb-typescript": "^17.0.0",
|
"eslint-config-airbnb-base": "^14.2.1",
|
||||||
"eslint-config-prettier": "^8.8.0",
|
"eslint-plugin-import": "^2.23.1",
|
||||||
"eslint-plugin-prettier": "^4.2.1",
|
"ts-node": "^9.1.1",
|
||||||
"husky": "^8.0.3",
|
"typescript": "^4.2.4"
|
||||||
"prettier": "^2.8.7",
|
|
||||||
"ts-node": "^10.9.1",
|
|
||||||
"typescript": "^4.9.5"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cross-fetch": "^3.1.4"
|
"cross-fetch": "^3.1.4"
|
||||||
},
|
},
|
||||||
"volta": {
|
"volta": {
|
||||||
"node": "18.16.0",
|
"node": "15.13.0",
|
||||||
"yarn": "1.22.4",
|
"yarn": "1.19.2",
|
||||||
"npm": "9.5.1"
|
"npm": "7.12.1"
|
||||||
},
|
|
||||||
"husky": {
|
|
||||||
"hooks": {
|
|
||||||
"pre-commit": "npm run pre-commit"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist"
|
||||||
|
|||||||
10
src/api.ts
10
src/api.ts
@@ -1,22 +1,20 @@
|
|||||||
import fetch from 'cross-fetch';
|
import fetch from 'cross-fetch';
|
||||||
import { parseOptions } from './utils';
|
|
||||||
|
|
||||||
const BASE_URL_V3 = 'https://api.themoviedb.org/3';
|
const BASE_URL_V3 = 'https://api.themoviedb.org/3';
|
||||||
|
|
||||||
export class Api {
|
export default class Api {
|
||||||
constructor(private accessToken: string) {
|
constructor(private accessToken: string) {
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
async get<T>(path: string, options?: Record<string, any>): Promise<T> {
|
async get<T>(path: string): Promise<T> {
|
||||||
const params = parseOptions(options);
|
const response = await fetch(`${BASE_URL_V3}${path}`, {
|
||||||
const response = await fetch(`${BASE_URL_V3}${path}?${params}`, {
|
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${this.accessToken}`,
|
Authorization: `Bearer ${this.accessToken}`,
|
||||||
'Content-Type': 'application/json;charset=utf-8',
|
'Content-Type': 'application/json;charset=utf-8',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return (await response.json()) as T;
|
return await response.json() as T;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
import { AccountDetails } from '../types/account';
|
|
||||||
|
|
||||||
export class AccountEndpoint extends BaseEndpoint {
|
export class AccountEndpoint extends BaseEndpoint {
|
||||||
constructor(accessToken: string) {
|
constructor(accessToken: string) {
|
||||||
super(accessToken);
|
super(accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
async details(): Promise<AccountDetails> {
|
async details(): Promise<any> {
|
||||||
return await this.api.get('/account');
|
return await this.api.get('/account');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Api } from '../api';
|
import Api from '../api';
|
||||||
|
|
||||||
export class BaseEndpoint {
|
export class BaseEndpoint {
|
||||||
protected api: Api;
|
protected api: Api;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
import { Certifications } from '../types/certification';
|
import { Certifications } from '../types/certification';
|
||||||
|
|
||||||
export class CertificationEndpoint extends BaseEndpoint {
|
export class CertificationEndpoint extends BaseEndpoint {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
import { ChangeOptions, Changes } from '../types/changes';
|
import { ChangeOptions, Changes } from '../types/changes';
|
||||||
|
import { parseOptions } from '../utils';
|
||||||
|
|
||||||
|
|
||||||
export class ChangeEndpoint extends BaseEndpoint {
|
export class ChangeEndpoint extends BaseEndpoint {
|
||||||
constructor(protected readonly accessToken: string) {
|
constructor(protected readonly accessToken: string) {
|
||||||
@@ -7,14 +9,17 @@ export class ChangeEndpoint extends BaseEndpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async movies(options?: ChangeOptions): Promise<Changes> {
|
async movies(options?: ChangeOptions): Promise<Changes> {
|
||||||
return await this.api.get<Changes>(`/movie/changes`, options);
|
const params = parseOptions(options);
|
||||||
|
return await this.api.get<Changes>(`/movie/changes?${params}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async tvShows(options?: ChangeOptions): Promise<Changes> {
|
async tvShows(options?: ChangeOptions): Promise<Changes> {
|
||||||
return await this.api.get<Changes>(`/tv/changes`, options);
|
const params = parseOptions(options);
|
||||||
|
return await this.api.get<Changes>(`/tv/changes?${params}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async person(options?: ChangeOptions): Promise<Changes> {
|
async person(options?: ChangeOptions): Promise<Changes> {
|
||||||
return await this.api.get<Changes>(`/person/change`, options);
|
const params = parseOptions(options);
|
||||||
|
return await this.api.get<Changes>(`/person/changes${params}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
import {
|
import { DetailedCollection, ImageCollection, LanguageOption, Translations } from '../types';
|
||||||
DetailedCollection,
|
import { parseOptions } from '../utils';
|
||||||
ImageCollection,
|
import { BaseEndpoint } from './base';
|
||||||
LanguageOption,
|
|
||||||
Translations,
|
|
||||||
} from '../types';
|
|
||||||
import { BaseEndpoint } from './base';
|
|
||||||
|
|
||||||
const BASE_COLLECTION = '/collection';
|
const BASE_COLLECTION = '/collection';
|
||||||
|
|
||||||
@@ -13,30 +9,18 @@ export class CollectionsEndpoint extends BaseEndpoint {
|
|||||||
super(accessToken);
|
super(accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
async details(
|
async details(id: number, options? : LanguageOption): Promise<DetailedCollection> {
|
||||||
id: number,
|
const params = parseOptions(options);
|
||||||
options?: LanguageOption
|
return await this.api.get<DetailedCollection>(`${BASE_COLLECTION}/${id}?${params}`);
|
||||||
): Promise<DetailedCollection> {
|
|
||||||
return await this.api.get<DetailedCollection>(
|
|
||||||
`${BASE_COLLECTION}/${id}`,
|
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async images(id: number, options?: LanguageOption): Promise<ImageCollection> {
|
async images(id: number, options? : LanguageOption): Promise<ImageCollection> {
|
||||||
return await this.api.get<ImageCollection>(
|
const params = parseOptions(options);
|
||||||
`${BASE_COLLECTION}/${id}/images`,
|
return await this.api.get<ImageCollection>(`${BASE_COLLECTION}/${id}/images?${params}`);
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async translations(
|
async translations(id: number, options? : LanguageOption): Promise<Translations> {
|
||||||
id: number,
|
const params = parseOptions(options);
|
||||||
options?: LanguageOption
|
return await this.api.get<Translations>(`${BASE_COLLECTION}/${id}/translations?${params}`);
|
||||||
): Promise<Translations> {
|
|
||||||
return await this.api.get<Translations>(
|
|
||||||
`${BASE_COLLECTION}/${id}/translations`,
|
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,4 +9,5 @@ export class ConfigurationEndpoint extends BaseEndpoint {
|
|||||||
async getCurrent(): Promise<Configuration> {
|
async getCurrent(): Promise<Configuration> {
|
||||||
return await this.api.get<Configuration>(`/configuration`);
|
return await this.api.get<Configuration>(`/configuration`);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
import { CreditResponse } from '../types/credits';
|
import { CreditResponse } from '../types/credits';
|
||||||
|
|
||||||
|
|
||||||
export class CreditsEndpoint extends BaseEndpoint {
|
export class CreditsEndpoint extends BaseEndpoint {
|
||||||
constructor(protected readonly accessToken: string) {
|
constructor(protected readonly accessToken: string) {
|
||||||
super(accessToken);
|
super(accessToken);
|
||||||
@@ -9,4 +10,5 @@ export class CreditsEndpoint extends BaseEndpoint {
|
|||||||
async getById(id: string): Promise<CreditResponse> {
|
async getById(id: string): Promise<CreditResponse> {
|
||||||
return await this.api.get<CreditResponse>(`/credit/${id}`);
|
return await this.api.get<CreditResponse>(`/credit/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
import {
|
import { MovieDiscoverResult, SortOption, TvShowDiscoverResult } from '../types';
|
||||||
MovieDiscoverResult,
|
import { parseOptions } from '../utils';
|
||||||
SortOption,
|
|
||||||
TvShowDiscoverResult,
|
|
||||||
} from '../types';
|
|
||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
|
|
||||||
const BASE_DISCOVER = '/discover';
|
const BASE_DISCOVER = '/discover';
|
||||||
@@ -29,7 +26,7 @@ interface DiscoverQueryOptions {
|
|||||||
with_companies?: string;
|
with_companies?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MovieQueryOptions extends DiscoverQueryOptions {
|
interface MovieQueryOptions extends DiscoverQueryOptions{
|
||||||
region?: string;
|
region?: string;
|
||||||
certification_country?: string;
|
certification_country?: string;
|
||||||
certification?: string;
|
certification?: string;
|
||||||
@@ -49,7 +46,7 @@ interface MovieQueryOptions extends DiscoverQueryOptions {
|
|||||||
with_people?: string;
|
with_people?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TvShowQueryOptions extends DiscoverQueryOptions {
|
interface TvShowQueryOptions extends DiscoverQueryOptions{
|
||||||
'air_date.gte'?: string;
|
'air_date.gte'?: string;
|
||||||
'air_date.lte'?: string;
|
'air_date.lte'?: string;
|
||||||
'first_air_date.gte'?: string;
|
'first_air_date.gte'?: string;
|
||||||
@@ -69,16 +66,12 @@ export class DiscoverEndpoint extends BaseEndpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async movie(options?: MovieQueryOptions): Promise<MovieDiscoverResult> {
|
async movie(options?: MovieQueryOptions): Promise<MovieDiscoverResult> {
|
||||||
return await this.api.get<MovieDiscoverResult>(
|
const params = parseOptions(options);
|
||||||
`${BASE_DISCOVER}/movie`,
|
return await this.api.get<MovieDiscoverResult>(`${BASE_DISCOVER}/movie?${params}`);
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async tvShow(options?: TvShowQueryOptions): Promise<TvShowDiscoverResult> {
|
async tvShow(options?: TvShowQueryOptions): Promise<TvShowDiscoverResult> {
|
||||||
return await this.api.get<TvShowDiscoverResult>(
|
const params = parseOptions(options);
|
||||||
`${BASE_DISCOVER}/tv`,
|
return await this.api.get<TvShowDiscoverResult>(`${BASE_DISCOVER}/tv?${params}`);
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
import { ExternalIdOptions, FindResult } from '../types';
|
import { ExternalIdOptions, FindResult } from '../types';
|
||||||
|
import { parseOptions } from '../utils';
|
||||||
|
|
||||||
export class FindEndpoint extends BaseEndpoint {
|
export class FindEndpoint extends BaseEndpoint {
|
||||||
constructor(accessToken: string) {
|
constructor(accessToken: string) {
|
||||||
super(accessToken);
|
super(accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
async byId(
|
async byId(externalId: string, options: ExternalIdOptions): Promise<FindResult> {
|
||||||
externalId: string,
|
const params = parseOptions(options);
|
||||||
options: ExternalIdOptions
|
return await this.api.get<FindResult>(`/find/${externalId}?${params}`);
|
||||||
): Promise<FindResult> {
|
|
||||||
return await this.api.get<FindResult>(`/find/${externalId}`, options);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
|
|
||||||
export interface Genres {
|
export interface Genres {
|
||||||
genres: Array<{ id: number; name: string }>;
|
genres: Array<{id: number, name: string}>
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GenreEndpoint extends BaseEndpoint {
|
export class GenreEndpoint extends BaseEndpoint {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
export * from './account';
|
export * from './account';
|
||||||
export * from './certification';
|
export * from './certification';
|
||||||
export * from './changes';
|
export * from './changes';
|
||||||
@@ -14,3 +16,4 @@ export * from './trending';
|
|||||||
export * from './find';
|
export * from './find';
|
||||||
export * from './keywords';
|
export * from './keywords';
|
||||||
export * from './collections';
|
export * from './collections';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
import { BelongingMovies, Keyword, KeywordsOptions } from '../types';
|
import { BelongingMovies, Keyword, KeywordsOptions } from '../types';
|
||||||
|
import { parseOptions } from '../utils';
|
||||||
|
|
||||||
const BASE_Keyword = '/keyword';
|
const BASE_Keyword = '/keyword';
|
||||||
|
|
||||||
@@ -8,17 +9,12 @@ export class KeywordsEndpoint extends BaseEndpoint {
|
|||||||
super(accessToken);
|
super(accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
async details(keywordId: number): Promise<Keyword> {
|
async details(keywordId : number): Promise<Keyword> {
|
||||||
return await this.api.get<Keyword>(`${BASE_Keyword}/${keywordId}`);
|
return await this.api.get<Keyword>(`${BASE_Keyword}/${keywordId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async belongingMovies(
|
async belongingMovies(keywordId : number, options?: KeywordsOptions): Promise<BelongingMovies> {
|
||||||
keywordId: number,
|
const params = parseOptions(options);
|
||||||
options?: KeywordsOptions
|
return await this.api.get<BelongingMovies>(`${BASE_Keyword}/${keywordId}/movies?${params}`);
|
||||||
): Promise<BelongingMovies> {
|
|
||||||
return await this.api.get<BelongingMovies>(
|
|
||||||
`${BASE_Keyword}/${keywordId}/movies`,
|
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,92 +19,78 @@ import {
|
|||||||
ReleaseDates,
|
ReleaseDates,
|
||||||
Reviews,
|
Reviews,
|
||||||
SimilarMovies,
|
SimilarMovies,
|
||||||
TopRatedMovies,
|
TopRatedMovies, Translations,
|
||||||
Translations,
|
|
||||||
UpcomingMovies,
|
UpcomingMovies,
|
||||||
Videos,
|
Videos,
|
||||||
WatchProviders,
|
WatchProviders,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
|
import { parseOptions } from '../utils';
|
||||||
|
|
||||||
const BASE_MOVIE = '/movie';
|
const BASE_MOVIE = '/movie';
|
||||||
|
|
||||||
export class MoviesEndpoint extends BaseEndpoint {
|
export class MoviesEndpoint extends BaseEndpoint{
|
||||||
constructor(protected readonly accessToken: string) {
|
constructor(protected readonly accessToken: string) {
|
||||||
super(accessToken);
|
super(accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
async details(id: number): Promise<MovieDetails> {
|
async details(id: number): Promise<MovieDetails>{
|
||||||
return await this.api.get<MovieDetails>(`${BASE_MOVIE}/${id}`);
|
return await this.api.get<MovieDetails>(`${BASE_MOVIE}/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async alternativeTitles(id: number): Promise<AlternativeTitles> {
|
async alternativeTitles(id: number): Promise<AlternativeTitles>{
|
||||||
return await this.api.get<AlternativeTitles>(
|
return await this.api.get<AlternativeTitles>(`${BASE_MOVIE}/${id}/alternative_titles`);
|
||||||
`${BASE_MOVIE}/${id}/alternative_titles`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async changes(id: number, options?: ChangeOptions): Promise<MovieChanges> {
|
async changes(id: number, options?: ChangeOptions): Promise<MovieChanges>{
|
||||||
return await this.api.get<MovieChanges>(
|
const params = parseOptions(options);
|
||||||
`${BASE_MOVIE}/${id}/changes`,
|
return await this.api.get<MovieChanges>(`${BASE_MOVIE}/${id}/changes?${params}`);
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async credits(id: number): Promise<Credits> {
|
async credits(id: number): Promise<Credits>{
|
||||||
return await this.api.get<Credits>(`${BASE_MOVIE}/${id}/credits`);
|
return await this.api.get<Credits>(`${BASE_MOVIE}/${id}/credits`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async externalIds(id: number): Promise<ExternalIds> {
|
async externalIds(id: number): Promise<ExternalIds>{
|
||||||
return await this.api.get<ExternalIds>(`${BASE_MOVIE}/${id}/external_ids`);
|
return await this.api.get<ExternalIds>(`${BASE_MOVIE}/${id}/external_ids`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async images(id: number): Promise<Images> {
|
async images(id: number): Promise<Images>{
|
||||||
return await this.api.get<Images>(`${BASE_MOVIE}/${id}/images`);
|
return await this.api.get<Images>(`${BASE_MOVIE}/${id}/images`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async keywords(id: number): Promise<Keywords> {
|
async keywords(id: number): Promise<Keywords>{
|
||||||
return await this.api.get<Keywords>(`${BASE_MOVIE}/${id}/keywords`);
|
return await this.api.get<Keywords>(`${BASE_MOVIE}/${id}/keywords`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async lists(
|
async lists(id: number, options?: LanguageOption | PageOption): Promise<MovieLists>{
|
||||||
id: number,
|
const params = parseOptions(options);
|
||||||
options?: LanguageOption | PageOption
|
return await this.api.get<MovieLists>(`${BASE_MOVIE}/${id}/lists?${params}`);
|
||||||
): Promise<MovieLists> {
|
|
||||||
return await this.api.get<MovieLists>(`${BASE_MOVIE}/${id}/lists`, options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async recommendations(
|
async recommendations(id: number, options?: PageOption): Promise<Recommendations>{
|
||||||
id: number,
|
const params = parseOptions(options);
|
||||||
options?: PageOption
|
return await this.api.get<Recommendations>(`${BASE_MOVIE}/${id}/recommendations?${params}`);
|
||||||
): Promise<Recommendations> {
|
|
||||||
return await this.api.get<Recommendations>(
|
|
||||||
`${BASE_MOVIE}/${id}/recommendations`,
|
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async releaseDates(id: number): Promise<ReleaseDates> {
|
async releaseDates(id: number): Promise<ReleaseDates>{
|
||||||
return await this.api.get<ReleaseDates>(
|
return await this.api.get<ReleaseDates>(`${BASE_MOVIE}/${id}/release_dates`);
|
||||||
`${BASE_MOVIE}/${id}/release_dates`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async reviews(id: number, options?: PageOption): Promise<Reviews> {
|
async reviews(id: number, options?: PageOption): Promise<Reviews>{
|
||||||
return await this.api.get<Reviews>(`${BASE_MOVIE}/${id}/reviews`, options);
|
const params = parseOptions(options);
|
||||||
|
return await this.api.get<Reviews>(`${BASE_MOVIE}/${id}/reviews?${params}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async similar(id: number, options?: PageOption): Promise<SimilarMovies> {
|
async similar(id: number, options?: PageOption): Promise<SimilarMovies>{
|
||||||
return await this.api.get<SimilarMovies>(
|
const params = parseOptions(options);
|
||||||
`${BASE_MOVIE}/${id}/similar`,
|
return await this.api.get<SimilarMovies>(`${BASE_MOVIE}/${id}/similar?${params}`);
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async translations(id: number): Promise<Translations> {
|
async translations(id: number): Promise<Translations>{
|
||||||
return await this.api.get<Translations>(`${BASE_MOVIE}/${id}/translations`);
|
return await this.api.get<Translations>(`${BASE_MOVIE}/${id}/translations`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async videos(id: number): Promise<Videos> {
|
async videos(id: number): Promise<Videos>{
|
||||||
return await this.api.get<Videos>(`${BASE_MOVIE}/${id}/videos`);
|
return await this.api.get<Videos>(`${BASE_MOVIE}/${id}/videos`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,44 +98,33 @@ export class MoviesEndpoint extends BaseEndpoint {
|
|||||||
* Powered by JustWatch
|
* Powered by JustWatch
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
async watchProviders(id: number): Promise<WatchProviders> {
|
async watchProviders(id: number): Promise<WatchProviders>{
|
||||||
return await this.api.get<WatchProviders>(
|
return await this.api.get<WatchProviders>(`${BASE_MOVIE}/${id}/watch/providers`);
|
||||||
`${BASE_MOVIE}/${id}/watch/providers`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async latest(): Promise<LatestMovie> {
|
async latest(): Promise<LatestMovie>{
|
||||||
return await this.api.get<LatestMovie>(`${BASE_MOVIE}/latest`);
|
return await this.api.get<LatestMovie>(`${BASE_MOVIE}/latest`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async nowPlaying(
|
async nowPlaying(options?: PageOption & LanguageOption & RegionOption): Promise<MoviesPlayingNow>{
|
||||||
options?: PageOption & LanguageOption & RegionOption
|
const params = parseOptions(options);
|
||||||
): Promise<MoviesPlayingNow> {
|
return await this.api.get<MoviesPlayingNow>(`${BASE_MOVIE}/now_playing?${params}`);
|
||||||
return await this.api.get<MoviesPlayingNow>(
|
|
||||||
`${BASE_MOVIE}/now_playing`,
|
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async popular(options?: PageOption): Promise<PopularMovies> {
|
async popular(options?: PageOption): Promise<PopularMovies>{
|
||||||
return await this.api.get<PopularMovies>(`${BASE_MOVIE}/popular`, options);
|
const params = parseOptions(options);
|
||||||
|
return await this.api.get<PopularMovies>(`${BASE_MOVIE}/popular?${params}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async topRated(
|
async topRated(options?: PageOption & LanguageOption & RegionOption): Promise<TopRatedMovies>{
|
||||||
options?: PageOption & LanguageOption & RegionOption
|
const params = parseOptions(options);
|
||||||
): Promise<TopRatedMovies> {
|
return await this.api.get<TopRatedMovies>(`${BASE_MOVIE}/top_rated?${params}`);
|
||||||
return await this.api.get<TopRatedMovies>(
|
|
||||||
`${BASE_MOVIE}/top_rated`,
|
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async upcoming(
|
async upcoming(options?: PageOption & LanguageOption & RegionOption): Promise<UpcomingMovies>{
|
||||||
options?: PageOption & LanguageOption & RegionOption
|
const params = parseOptions(options);
|
||||||
): Promise<UpcomingMovies> {
|
return await this.api.get<UpcomingMovies>(`${BASE_MOVIE}/upcoming?${params}`);
|
||||||
return await this.api.get<UpcomingMovies>(
|
|
||||||
`${BASE_MOVIE}/upcoming`,
|
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
PopularPersons,
|
PopularPersons,
|
||||||
TaggedImages,
|
TaggedImages,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
|
import { parseOptions } from '../utils';
|
||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
|
|
||||||
const BASE_PERSON = '/person';
|
const BASE_PERSON = '/person';
|
||||||
@@ -25,62 +26,46 @@ export class PeopleEndpoint extends BaseEndpoint {
|
|||||||
return await this.api.get<PersonDetail>(`${BASE_PERSON}/${id}`);
|
return await this.api.get<PersonDetail>(`${BASE_PERSON}/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async changes(id: number, options?: ChangeOptions): Promise<PersonChanges> {
|
async changes(id: number, options? : ChangeOptions): Promise<PersonChanges> {
|
||||||
return await this.api.get<PersonChanges>(
|
const params = parseOptions(options);
|
||||||
`${BASE_PERSON}/${id}/changes`,
|
return await this.api.get<PersonChanges>(`${BASE_PERSON}/${id}/changes?${params}`);
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async movieCredits(id: number): Promise<PersonMovieCredit> {
|
async movieCredits(id: number): Promise<PersonMovieCredit> {
|
||||||
return await this.api.get<PersonMovieCredit>(
|
return await this.api.get<PersonMovieCredit>(`${BASE_PERSON}/${id}/movie_credits`);
|
||||||
`${BASE_PERSON}/${id}/movie_credits`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async tvShowCredits(id: number): Promise<PersonTvShowCredit> {
|
async tvShowCredits(id: number): Promise<PersonTvShowCredit> {
|
||||||
return await this.api.get<PersonTvShowCredit>(
|
return await this.api.get<PersonTvShowCredit>(`${BASE_PERSON}/${id}/tv_credits`);
|
||||||
`${BASE_PERSON}/${id}/tv_credits`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async combinedCredits(id: number): Promise<PersonCombinedCredits> {
|
async combinedCredits(id: number) : Promise<PersonCombinedCredits> {
|
||||||
return await this.api.get<PersonCombinedCredits>(
|
return await this.api.get<PersonCombinedCredits>(`${BASE_PERSON}/${id}/combined_credits`);
|
||||||
`${BASE_PERSON}/${id}/combined_credits`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async externalId(id: number): Promise<ExternalIds> {
|
async externalId(id: number): Promise<ExternalIds>{
|
||||||
return await this.api.get<ExternalIds>(`${BASE_PERSON}/${id}/external_ids`);
|
return await this.api.get<ExternalIds>(`${BASE_PERSON}/${id}/external_ids`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async images(id: number): Promise<{ id: number; profiles: Image[] }> {
|
async images(id: number): Promise<{id: number, profiles: Image[]}>{
|
||||||
return await this.api.get<{ id: number; profiles: Image[] }>(
|
return await this.api.get<{id: number, profiles: Image[]}>(`${BASE_PERSON}/${id}/images`);
|
||||||
`${BASE_PERSON}/${id}/images`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async taggedImages(id: number, options?: PageOption): Promise<TaggedImages> {
|
async taggedImages(id: number, options?: PageOption): Promise<TaggedImages>{
|
||||||
return await this.api.get<TaggedImages>(
|
const params = parseOptions(options);
|
||||||
`${BASE_PERSON}/${id}/tagged_images`,
|
return await this.api.get<TaggedImages>(`${BASE_PERSON}/${id}/tagged_images?${params}`);
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async translation(id: number): Promise<PeopleTranslations> {
|
async translation(id: number) : Promise<PeopleTranslations>{
|
||||||
return await this.api.get<PeopleTranslations>(
|
return await this.api.get<PeopleTranslations>(`${BASE_PERSON}/${id}/translations`);
|
||||||
`${BASE_PERSON}/${id}/translations`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async latest(): Promise<PersonDetail> {
|
async latest(): Promise<PersonDetail>{
|
||||||
return await this.api.get<PersonDetail>(`${BASE_PERSON}/latest`);
|
return await this.api.get<PersonDetail>(`${BASE_PERSON}/latest`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async popular(options?: PageOption): Promise<PopularPersons> {
|
async popular(options?: PageOption): Promise<PopularPersons>{
|
||||||
return await this.api.get<PopularPersons>(
|
const params = parseOptions(options);
|
||||||
`${BASE_PERSON}/popular`,
|
return await this.api.get<PopularPersons>(`${BASE_PERSON}/popular?${params}`);
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
import { Search } from '../types/search';
|
import { Search } from '../types/search';
|
||||||
import { Collection, Company, Movie, Person, TV } from '../types';
|
import { Collection, Company, Movie, Person, TV } from '../types';
|
||||||
|
import { parseOptions } from '../utils';
|
||||||
|
|
||||||
const BASE_SEARCH = '/search';
|
const BASE_SEARCH = '/search';
|
||||||
|
|
||||||
@@ -15,12 +16,12 @@ export interface MovieSearchOptions extends SearchOptions {
|
|||||||
primary_release_year?: number;
|
primary_release_year?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TvSearchOptions extends SearchOptions {
|
export interface TvSearchOptions extends SearchOptions{
|
||||||
include_adult?: boolean;
|
include_adult?: boolean;
|
||||||
first_air_date_year?: number;
|
first_air_date_year?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PeopleSearchOptions extends SearchOptions {
|
export interface PeopleSearchOptions extends SearchOptions{
|
||||||
include_adult?: boolean;
|
include_adult?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,40 +30,35 @@ export class SearchEndpoint extends BaseEndpoint {
|
|||||||
super(accessToken);
|
super(accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
async companies(options: SearchOptions): Promise<Search<Company>> {
|
async companies(options: SearchOptions): Promise<Search<Company>>{
|
||||||
return await this.api.get<Search<Company>>(
|
const params = parseOptions(options);
|
||||||
`${BASE_SEARCH}/company`,
|
return await this.api.get<Search<Company>>(`${BASE_SEARCH}/company?${params}`);
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async collections(options: SearchOptions): Promise<Search<Collection>> {
|
async collections(options: SearchOptions): Promise<Search<Collection>>{
|
||||||
return await this.api.get<Search<Collection>>(
|
const params = parseOptions(options);
|
||||||
`${BASE_SEARCH}/collection`,
|
return await this.api.get<Search<Collection>>(`${BASE_SEARCH}/collection?${params}`);
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async keywords(
|
async keywords(options: SearchOptions): Promise<Search<{ id: string, name: string }>>{
|
||||||
options: SearchOptions
|
const params = parseOptions(options);
|
||||||
): Promise<Search<{ id: string; name: string }>> {
|
return await this.api.get<Search<{ id: string, name: string }>>(`${BASE_SEARCH}/keyword?${params}`);
|
||||||
return await this.api.get<Search<{ id: string; name: string }>>(
|
|
||||||
`${BASE_SEARCH}/keyword`,
|
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async movies(options: MovieSearchOptions): Promise<Search<Movie>> {
|
async movies(options: MovieSearchOptions): Promise<Search<Movie>>{
|
||||||
return await this.api.get<Search<Movie>>(`${BASE_SEARCH}/movie`, options);
|
const params = parseOptions(options);
|
||||||
|
return await this.api.get<Search<Movie>>(`${BASE_SEARCH}/movie?${params}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async people(options: PeopleSearchOptions): Promise<Search<Person>> {
|
async people(options: PeopleSearchOptions): Promise<Search<Person>>{
|
||||||
return await this.api.get<Search<Person>>(`${BASE_SEARCH}/person`, options);
|
const params = parseOptions(options);
|
||||||
|
return await this.api.get<Search<Person>>(`${BASE_SEARCH}/person?${params}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Multi search
|
// TODO: Multi search
|
||||||
|
|
||||||
async tvShows(options: TvSearchOptions): Promise<Search<TV>> {
|
async tvShows(options: TvSearchOptions): Promise<Search<TV>>{
|
||||||
return await this.api.get<Search<TV>>(`${BASE_SEARCH}/tv`, options);
|
const params = parseOptions(options);
|
||||||
|
return await this.api.get<Search<TV>>(`${BASE_SEARCH}/tv?${params}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { MediaType, TimeWindow, TrendingResults } from '../types';
|
import { MediaType, TimeWindow, TrendingResults } from '../types';
|
||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
|
|
||||||
export class TrendingEndpoint extends BaseEndpoint {
|
export class TrendingEndpoint extends BaseEndpoint {
|
||||||
@@ -6,12 +6,9 @@ export class TrendingEndpoint extends BaseEndpoint {
|
|||||||
super(accessToken);
|
super(accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
async trending<T extends MediaType>(
|
async trending<T extends MediaType>(mediaType : T, timeWindow: TimeWindow): Promise<TrendingResults<T>> {
|
||||||
mediaType: T,
|
return await this.api.get<TrendingResults<T>>(`/trending/${mediaType}/${timeWindow}`);
|
||||||
timeWindow: TimeWindow
|
|
||||||
): Promise<TrendingResults<T>> {
|
|
||||||
return await this.api.get<TrendingResults<T>>(
|
|
||||||
`/trending/${mediaType}/${timeWindow}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,134 +27,111 @@ import {
|
|||||||
Videos,
|
Videos,
|
||||||
WatchProviders,
|
WatchProviders,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
|
import { parseOptions } from '../utils';
|
||||||
|
|
||||||
const BASE_TV = '/tv';
|
const BASE_TV = '/tv';
|
||||||
|
|
||||||
export class TvShowsEndpoint extends BaseEndpoint {
|
export class TvShowsEndpoint extends BaseEndpoint{
|
||||||
constructor(protected readonly accessToken: string) {
|
constructor(protected readonly accessToken: string) {
|
||||||
super(accessToken);
|
super(accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
async details(id: number): Promise<TvShowDetails> {
|
async details(id: number): Promise<TvShowDetails>{
|
||||||
return await this.api.get<TvShowDetails>(`${BASE_TV}/${id}`);
|
return await this.api.get<TvShowDetails>(`${BASE_TV}/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async alternativeTitles(id: number): Promise<AlternativeTitles> {
|
async alternativeTitles(id: number): Promise<AlternativeTitles>{
|
||||||
return await this.api.get<AlternativeTitles>(
|
return await this.api.get<AlternativeTitles>(`${BASE_TV}/${id}/alternative_titles`);
|
||||||
`${BASE_TV}/${id}/alternative_titles`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async changes(id: number, options?: ChangeOptions): Promise<TvShowChanges> {
|
async changes(id: number, options?: ChangeOptions): Promise<TvShowChanges>{
|
||||||
return await this.api.get<TvShowChanges>(
|
const params = parseOptions(options);
|
||||||
`${BASE_TV}/${id}/changes`,
|
return await this.api.get<TvShowChanges>(`${BASE_TV}/${id}/changes?${params}`);
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async contentRatings(id: number): Promise<ContentRatings> {
|
async contentRatings(id: number): Promise<ContentRatings>{
|
||||||
return await this.api.get<ContentRatings>(
|
return await this.api.get<ContentRatings>(`${BASE_TV}/${id}/content_ratings`);
|
||||||
`${BASE_TV}/${id}/content_ratings`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async credits(id: number): Promise<Credits> {
|
async credits(id: number): Promise<Credits>{
|
||||||
return await this.api.get<Credits>(`${BASE_TV}/${id}/credits`);
|
return await this.api.get<Credits>(`${BASE_TV}/${id}/credits`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async season(tvId: number, seasonNumber: number): Promise<SeasonDetails> {
|
async season(tvId: number, seasonNumber: number): Promise<SeasonDetails>{
|
||||||
return await this.api.get<SeasonDetails>(
|
return await this.api.get<SeasonDetails>(`${BASE_TV}/${tvId}/season/${seasonNumber}`);
|
||||||
`${BASE_TV}/${tvId}/season/${seasonNumber}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async episodeGroups(id: number): Promise<EpisodeGroups> {
|
async episodeGroups(id: number): Promise<EpisodeGroups>{
|
||||||
return await this.api.get<EpisodeGroups>(`${BASE_TV}/${id}/episode_groups`);
|
return await this.api.get<EpisodeGroups>(`${BASE_TV}/${id}/episode_groups`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async externalIds(id: number): Promise<ExternalIds> {
|
async externalIds(id: number): Promise<ExternalIds>{
|
||||||
return await this.api.get<ExternalIds>(`${BASE_TV}/${id}/external_ids`);
|
return await this.api.get<ExternalIds>(`${BASE_TV}/${id}/external_ids`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async images(id: number): Promise<Images> {
|
async images(id: number): Promise<Images>{
|
||||||
return await this.api.get<Images>(`${BASE_TV}/${id}/images`);
|
return await this.api.get<Images>(`${BASE_TV}/${id}/images`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async keywords(id: number): Promise<Keywords> {
|
async keywords(id: number): Promise<Keywords>{
|
||||||
return await this.api.get<Keywords>(`${BASE_TV}/${id}/keywords`);
|
return await this.api.get<Keywords>(`${BASE_TV}/${id}/keywords`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async recommendations(
|
async recommendations(id: number, options?: PageOption): Promise<Recommendations>{
|
||||||
id: number,
|
const params = parseOptions(options);
|
||||||
options?: PageOption
|
return await this.api.get<Recommendations>(`${BASE_TV}/${id}/recommendations?${params}`);
|
||||||
): Promise<Recommendations> {
|
|
||||||
return await this.api.get<Recommendations>(
|
|
||||||
`${BASE_TV}/${id}/recommendations`,
|
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async reviews(id: number, options?: PageOption): Promise<Reviews> {
|
async reviews(id: number, options?: PageOption): Promise<Reviews>{
|
||||||
return await this.api.get<Reviews>(`${BASE_TV}/${id}/reviews`, options);
|
const params = parseOptions(options);
|
||||||
|
return await this.api.get<Reviews>(`${BASE_TV}/${id}/reviews?${params}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async screenedTheatrically(id: number): Promise<ScreenedTheatrically> {
|
async screenedTheatrically(id: number): Promise<ScreenedTheatrically>{
|
||||||
return await this.api.get<ScreenedTheatrically>(
|
return await this.api.get<ScreenedTheatrically>(`${BASE_TV}/${id}/screened_theatrically`);
|
||||||
`${BASE_TV}/${id}/screened_theatrically`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async similar(id: number, options?: PageOption): Promise<SimilarTvShows> {
|
async similar(id: number, options?: PageOption): Promise<SimilarTvShows>{
|
||||||
return await this.api.get<SimilarTvShows>(
|
const params = parseOptions(options);
|
||||||
`${BASE_TV}/${id}/similar`,
|
return await this.api.get<SimilarTvShows>(`${BASE_TV}/${id}/similar?${params}`);
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async translations(id: number): Promise<Translations> {
|
async translations(id: number): Promise<Translations>{
|
||||||
return await this.api.get<Translations>(`${BASE_TV}/${id}/translations`);
|
return await this.api.get<Translations>(`${BASE_TV}/${id}/translations`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async videos(id: number): Promise<Videos> {
|
async videos(id: number): Promise<Videos>{
|
||||||
return await this.api.get<Videos>(`${BASE_TV}/${id}/videos`);
|
return await this.api.get<Videos>(`${BASE_TV}/${id}/videos`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Powered by JustWatch
|
* Powered by JustWatch
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
async watchProviders(id: number): Promise<WatchProviders> {
|
async watchProviders(id: number): Promise<WatchProviders>{
|
||||||
return await this.api.get<WatchProviders>(
|
return await this.api.get<WatchProviders>(`${BASE_TV}/${id}/watch/providers`);
|
||||||
`${BASE_TV}/${id}/watch/providers`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async latest(): Promise<LatestTvShows> {
|
async latest(): Promise<LatestTvShows>{
|
||||||
return await this.api.get<LatestTvShows>(`${BASE_TV}/latest`);
|
return await this.api.get<LatestTvShows>(`${BASE_TV}/latest`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onTheAir(): Promise<OnTheAir> {
|
async onTheAir(): Promise<OnTheAir>{
|
||||||
return await this.api.get<OnTheAir>(`${BASE_TV}/on_the_air`);
|
return await this.api.get<OnTheAir>(`${BASE_TV}/on_the_air`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async airingToday(
|
async airingToday(options?: PageOption & LanguageOption & RegionOption): Promise<TvShowsAiringToday>{
|
||||||
options?: PageOption & LanguageOption & RegionOption
|
const params = parseOptions(options);
|
||||||
): Promise<TvShowsAiringToday> {
|
return await this.api.get<TvShowsAiringToday>(`${BASE_TV}/airing_today?${params}`);
|
||||||
return await this.api.get<TvShowsAiringToday>(
|
|
||||||
`${BASE_TV}/airing_today`,
|
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async popular(
|
async popular(options?: PageOption & LanguageOption & RegionOption): Promise<PopularTvShows>{
|
||||||
options?: PageOption & LanguageOption & RegionOption
|
const params = parseOptions(options);
|
||||||
): Promise<PopularTvShows> {
|
return await this.api.get<PopularTvShows>(`${BASE_TV}/popular?${params}`);
|
||||||
return await this.api.get<PopularTvShows>(`${BASE_TV}/popular`, options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async topRated(
|
async topRated(options?: PageOption & LanguageOption & RegionOption): Promise<TopRatedTvShows>{
|
||||||
options?: PageOption & LanguageOption & RegionOption
|
const params = parseOptions(options);
|
||||||
): Promise<TopRatedTvShows> {
|
return await this.api.get<TopRatedTvShows>(`${BASE_TV}/top_rated?${params}`);
|
||||||
return await this.api.get<TopRatedTvShows>(`${BASE_TV}/top_rated`, options);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { TMDB } from './tmdb';
|
import TMDB from './tmdb';
|
||||||
|
|
||||||
export * from './types';
|
export * from './types';
|
||||||
export * from './utils';
|
export * from './utils';
|
||||||
|
|
||||||
export { TMDB };
|
export default TMDB;
|
||||||
|
|||||||
24
src/tmdb.ts
24
src/tmdb.ts
@@ -17,7 +17,7 @@ import {
|
|||||||
CollectionsEndpoint,
|
CollectionsEndpoint,
|
||||||
} from './endpoints';
|
} from './endpoints';
|
||||||
|
|
||||||
export class TMDB {
|
export default class TMDB {
|
||||||
private readonly accessToken: string;
|
private readonly accessToken: string;
|
||||||
|
|
||||||
constructor(accessToken: string) {
|
constructor(accessToken: string) {
|
||||||
@@ -44,47 +44,47 @@ export class TMDB {
|
|||||||
return new CreditsEndpoint(this.accessToken);
|
return new CreditsEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
get search(): SearchEndpoint {
|
get search(): SearchEndpoint{
|
||||||
return new SearchEndpoint(this.accessToken);
|
return new SearchEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
get genres(): GenreEndpoint {
|
get genres(): GenreEndpoint{
|
||||||
return new GenreEndpoint(this.accessToken);
|
return new GenreEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
get movies(): MoviesEndpoint {
|
get movies(): MoviesEndpoint{
|
||||||
return new MoviesEndpoint(this.accessToken);
|
return new MoviesEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
get tvShows(): TvShowsEndpoint {
|
get tvShows(): TvShowsEndpoint{
|
||||||
return new TvShowsEndpoint(this.accessToken);
|
return new TvShowsEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
get discover(): DiscoverEndpoint {
|
get discover(): DiscoverEndpoint{
|
||||||
return new DiscoverEndpoint(this.accessToken);
|
return new DiscoverEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
get people(): PeopleEndpoint {
|
get people(): PeopleEndpoint{
|
||||||
return new PeopleEndpoint(this.accessToken);
|
return new PeopleEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
get review(): ReviewEndpoint {
|
get review(): ReviewEndpoint{
|
||||||
return new ReviewEndpoint(this.accessToken);
|
return new ReviewEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
get trending(): TrendingEndpoint {
|
get trending(): TrendingEndpoint{
|
||||||
return new TrendingEndpoint(this.accessToken);
|
return new TrendingEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
get find(): FindEndpoint {
|
get find() : FindEndpoint{
|
||||||
return new FindEndpoint(this.accessToken);
|
return new FindEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
get keywords(): KeywordsEndpoint {
|
get keywords() : KeywordsEndpoint{
|
||||||
return new KeywordsEndpoint(this.accessToken);
|
return new KeywordsEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
get collections(): CollectionsEndpoint {
|
get collections() : CollectionsEndpoint{
|
||||||
return new CollectionsEndpoint(this.accessToken);
|
return new CollectionsEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
export interface Gravatar {
|
|
||||||
hash: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Avatar {
|
|
||||||
gravatar: Gravatar;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AccountDetails {
|
|
||||||
avatar: Avatar;
|
|
||||||
id: number;
|
|
||||||
include_adult: boolean;
|
|
||||||
iso_3166_1: string;
|
|
||||||
iso_639_1: string;
|
|
||||||
name: string;
|
|
||||||
username: string;
|
|
||||||
}
|
|
||||||
@@ -6,14 +6,14 @@ export interface Certification {
|
|||||||
|
|
||||||
export interface Certifications {
|
export interface Certifications {
|
||||||
certifications: {
|
certifications: {
|
||||||
US: Certification[];
|
US: Certification[],
|
||||||
CA: Certification[];
|
CA: Certification[],
|
||||||
DE: Certification[];
|
DE: Certification[],
|
||||||
GB: Certification[];
|
GB: Certification[],
|
||||||
AU: Certification[];
|
AU: Certification[],
|
||||||
BR: Certification[];
|
BR: Certification[],
|
||||||
FR: Certification[];
|
FR: Certification[],
|
||||||
NZ: Certification[];
|
NZ: Certification[],
|
||||||
IN: Certification[];
|
IN: Certification[],
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ export interface Change {
|
|||||||
adult: boolean | undefined;
|
adult: boolean | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Changes {
|
export interface Changes{
|
||||||
results: Change[];
|
results: Change[];
|
||||||
page: number;
|
page: number;
|
||||||
total_pages: number;
|
total_pages: number;
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ export interface Collection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface DetailedCollection extends Collection {
|
export interface DetailedCollection extends Collection {
|
||||||
parts: Movie[];
|
parts: Movie[]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
export interface Images {
|
export interface Images {
|
||||||
base_url: string;
|
base_url: string;
|
||||||
secure_base_url: string;
|
secure_base_url: string;
|
||||||
@@ -13,45 +14,47 @@ export interface Configuration {
|
|||||||
change_keys: ChangeKeys[];
|
change_keys: ChangeKeys[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const enum BackdropSizes {
|
export const enum BackdropSizes {
|
||||||
W300 = 'w300',
|
W300 = 'w300',
|
||||||
W780 = 'w780',
|
W780 = 'w780',
|
||||||
W1280 = 'w1280',
|
W1280 = 'w1280',
|
||||||
ORIGINAL = 'original',
|
ORIGINAL = 'original'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum LogoSizes {
|
export const enum LogoSizes {
|
||||||
W45 = 'w45',
|
W45= 'w45',
|
||||||
W92 = 'w92',
|
W92= 'w92',
|
||||||
W154 = 'w154',
|
W154= 'w154',
|
||||||
W185 = 'w185',
|
W185= 'w185',
|
||||||
W300 = 'w300',
|
W300 = 'w300',
|
||||||
W500 = 'w500',
|
W500 = 'w500',
|
||||||
ORIGINAL = 'original',
|
ORIGINAL = 'original'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum PosterSizes {
|
export const enum PosterSizes {
|
||||||
W92 = 'w92',
|
W92= 'w92',
|
||||||
W154 = 'w154',
|
W154= 'w154',
|
||||||
W185 = 'w185',
|
W185='w185',
|
||||||
W300 = 'w300',
|
W300 = 'w300',
|
||||||
W500 = 'w500',
|
W500 = 'w500',
|
||||||
W780 = 'w780',
|
W780 = 'w780',
|
||||||
ORIGINAL = 'original',
|
ORIGINAL = 'original'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum ProfileSizes {
|
export const enum ProfileSizes {
|
||||||
W45 = 'w45',
|
W45 = 'w45',
|
||||||
W185 = 'w185',
|
W185 = 'w185',
|
||||||
W632 = 'w632',
|
W632 = 'w632',
|
||||||
ORIGINAL = 'original',
|
ORIGINAL = 'original'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const enum StillSizes {
|
export const enum StillSizes {
|
||||||
W92 = 'w92',
|
W92= 'w92',
|
||||||
W185 = 'w185',
|
W185 = 'w185',
|
||||||
W300 = 'w300',
|
W300 = 'w300',
|
||||||
ORIGINAL = 'original',
|
ORIGINAL = 'original'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum ChangeKeys {
|
export const enum ChangeKeys {
|
||||||
@@ -107,5 +110,5 @@ export const enum ChangeKeys {
|
|||||||
TVRAGE_ID = 'tvrage_id',
|
TVRAGE_ID = 'tvrage_id',
|
||||||
TYPE = 'type',
|
TYPE = 'type',
|
||||||
VIDEO = 'video',
|
VIDEO = 'video',
|
||||||
VIDEOS = 'videos',
|
VIDEOS = 'videos'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ export interface CreditSeason {
|
|||||||
season_number?: number;
|
season_number?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Media {
|
|
||||||
|
export interface Media{
|
||||||
i?: number;
|
i?: number;
|
||||||
name?: string;
|
name?:string;
|
||||||
first_air_date?: string;
|
first_air_date?: string;
|
||||||
vote_count?: number;
|
vote_count?: number;
|
||||||
overview?: string;
|
overview?: string;
|
||||||
@@ -86,6 +87,8 @@ export interface ImageCollection {
|
|||||||
backdrops: Image[];
|
backdrops: Image[];
|
||||||
posters: Image[];
|
posters: Image[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface Video {
|
export interface Video {
|
||||||
id: string;
|
id: string;
|
||||||
iso_639_1: string;
|
iso_639_1: string;
|
||||||
@@ -100,4 +103,4 @@ export interface Video {
|
|||||||
export interface Videos {
|
export interface Videos {
|
||||||
id: number;
|
id: number;
|
||||||
results: Video[];
|
results: Video[];
|
||||||
}
|
}
|
||||||
@@ -1,29 +1,29 @@
|
|||||||
import { Movie, TV } from '.';
|
import { Movie, TV } from '.';
|
||||||
|
|
||||||
export type SortOption =
|
export type SortOption =
|
||||||
| 'popularity.asc'
|
| 'popularity.asc'
|
||||||
| 'popularity.desc'
|
| 'popularity.desc'
|
||||||
| 'release_date.asc'
|
| 'release_date.asc'
|
||||||
| 'release_date.desc'
|
| 'release_date.desc'
|
||||||
| 'revenue.asc'
|
| 'revenue.asc'
|
||||||
| 'revenue.desc'
|
| 'revenue.desc'
|
||||||
| 'primary_release_date.asc'
|
| 'primary_release_date.asc'
|
||||||
| 'primary_release_date.desc'
|
| 'primary_release_date.desc'
|
||||||
| 'original_title.asc'
|
| 'original_title.asc'
|
||||||
| 'original_title.desc'
|
| 'original_title.desc'
|
||||||
| 'vote_average.asc'
|
| 'vote_average.asc'
|
||||||
| 'vote_average.desc'
|
| 'vote_average.desc'
|
||||||
| 'vote_count.asc'
|
| 'vote_count.asc'
|
||||||
| 'vote_count.desc';
|
| 'vote_count.desc';
|
||||||
|
|
||||||
export interface MovieDiscoverResult {
|
export interface MovieDiscoverResult{
|
||||||
page: number;
|
page: number;
|
||||||
results: Movie[];
|
results: Movie[];
|
||||||
total_results: number;
|
total_results: number;
|
||||||
total_pages: number;
|
total_pages: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TvShowDiscoverResult {
|
export interface TvShowDiscoverResult{
|
||||||
page: number;
|
page: number;
|
||||||
results: TV[];
|
results: TV[];
|
||||||
total_results: number;
|
total_results: number;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
export * from './options';
|
export * from './options';
|
||||||
export * from './certification';
|
export * from './certification';
|
||||||
export * from './credits';
|
export * from './credits';
|
||||||
export * from './configuration';
|
export * from './configuration';
|
||||||
export * from './changes';
|
export * from './changes';
|
||||||
export * from './movies';
|
export * from './movies';
|
||||||
export * from './search';
|
export * from './search';
|
||||||
export * from './tv-shows';
|
export * from './tv-shows';
|
||||||
@@ -77,7 +77,7 @@ export interface Company {
|
|||||||
|
|
||||||
export interface TV {
|
export interface TV {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name:string;
|
||||||
first_air_date: string;
|
first_air_date: string;
|
||||||
backdrop_path: string;
|
backdrop_path: string;
|
||||||
genre_ids: number[];
|
genre_ids: number[];
|
||||||
@@ -122,7 +122,7 @@ export interface SpokenLanguage {
|
|||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ContentRatings {
|
export interface ContentRatings{
|
||||||
results: ContentRatingsResult[];
|
results: ContentRatingsResult[];
|
||||||
id: number;
|
id: number;
|
||||||
}
|
}
|
||||||
@@ -132,16 +132,17 @@ export interface ContentRatingsResult {
|
|||||||
rating: string;
|
rating: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface Recommendation {
|
export interface Recommendation {
|
||||||
adult: boolean;
|
adult: boolean;
|
||||||
backdrop_path?: string;
|
backdrop_path?: any;
|
||||||
genre_ids: number[];
|
genre_ids: number[];
|
||||||
id: number;
|
id: number;
|
||||||
original_language: string;
|
original_language: string;
|
||||||
original_title: string;
|
original_title: string;
|
||||||
overview: string;
|
overview: string;
|
||||||
release_date: string;
|
release_date: string;
|
||||||
poster_path?: string;
|
poster_path?: any;
|
||||||
popularity: number;
|
popularity: number;
|
||||||
title: string;
|
title: string;
|
||||||
video: boolean;
|
video: boolean;
|
||||||
@@ -149,6 +150,7 @@ export interface Recommendation {
|
|||||||
vote_count: number;
|
vote_count: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface Recommendations {
|
export interface Recommendations {
|
||||||
page: number;
|
page: number;
|
||||||
results: Recommendation[];
|
results: Recommendation[];
|
||||||
@@ -174,6 +176,7 @@ export interface Reviews {
|
|||||||
total_results: number;
|
total_results: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface TranslationData {
|
export interface TranslationData {
|
||||||
title: string;
|
title: string;
|
||||||
overview: string;
|
overview: string;
|
||||||
@@ -193,7 +196,7 @@ export interface Translations {
|
|||||||
translations: Translation[];
|
translations: Translation[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Image {
|
export interface Image{
|
||||||
aspect_ratio: number;
|
aspect_ratio: number;
|
||||||
file_path: string;
|
file_path: string;
|
||||||
height: number;
|
height: number;
|
||||||
@@ -201,4 +204,4 @@ export interface Image {
|
|||||||
vote_average: number;
|
vote_average: number;
|
||||||
vote_count: number;
|
vote_count: number;
|
||||||
width: number;
|
width: number;
|
||||||
}
|
}
|
||||||
@@ -5,14 +5,14 @@ export interface KeywordsOptions {
|
|||||||
language?: string;
|
language?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BelongingMovies {
|
export interface BelongingMovies{
|
||||||
page: number;
|
page: number;
|
||||||
results: Movie[];
|
results: Movie[];
|
||||||
total_results: number;
|
total_results: number;
|
||||||
total_pages: number;
|
total_pages: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Keyword {
|
export interface Keyword{
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
@@ -20,4 +20,4 @@ export interface Keyword {
|
|||||||
export interface Keywords {
|
export interface Keywords {
|
||||||
id: number;
|
id: number;
|
||||||
keywords: Keyword[];
|
keywords: Keyword[];
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,9 @@
|
|||||||
import {
|
import { Genre, Movie, ProductionCompany, ProductionCountry, SpokenLanguage } from './';
|
||||||
Genre,
|
|
||||||
Movie,
|
|
||||||
ProductionCompany,
|
|
||||||
ProductionCountry,
|
|
||||||
SpokenLanguage,
|
|
||||||
} from './';
|
|
||||||
|
|
||||||
export interface BelongsToCollection {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
poster_path: string;
|
|
||||||
backdrop_path: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MovieDetails {
|
export interface MovieDetails {
|
||||||
adult: boolean;
|
adult: boolean;
|
||||||
backdrop_path: string;
|
backdrop_path: string;
|
||||||
belongs_to_collection?: BelongsToCollection;
|
belongs_to_collection?: any;
|
||||||
budget: number;
|
budget: number;
|
||||||
genres: Genre[];
|
genres: Genre[];
|
||||||
homepage: string;
|
homepage: string;
|
||||||
@@ -26,7 +13,7 @@ export interface MovieDetails {
|
|||||||
original_title: string;
|
original_title: string;
|
||||||
overview: string;
|
overview: string;
|
||||||
popularity: number;
|
popularity: number;
|
||||||
poster_path?: string;
|
poster_path?: any;
|
||||||
production_companies: ProductionCompany[];
|
production_companies: ProductionCompany[];
|
||||||
production_countries: ProductionCountry[];
|
production_countries: ProductionCountry[];
|
||||||
release_date: string;
|
release_date: string;
|
||||||
@@ -47,7 +34,7 @@ export enum ReleaseDateType {
|
|||||||
'Theatrical',
|
'Theatrical',
|
||||||
'Digital',
|
'Digital',
|
||||||
'Physical',
|
'Physical',
|
||||||
'TV',
|
'TV'
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ReleaseDate {
|
export interface ReleaseDate {
|
||||||
@@ -68,6 +55,7 @@ export interface ReleaseDates {
|
|||||||
results: ReleaseDateResult[];
|
results: ReleaseDateResult[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface SimilarMovies {
|
export interface SimilarMovies {
|
||||||
page: number;
|
page: number;
|
||||||
results: Movie[];
|
results: Movie[];
|
||||||
@@ -94,6 +82,7 @@ export interface MovieLists {
|
|||||||
total_results: number;
|
total_results: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface MovieChangeItem {
|
export interface MovieChangeItem {
|
||||||
id: string;
|
id: string;
|
||||||
action: string;
|
action: string;
|
||||||
@@ -114,8 +103,8 @@ export interface MovieChanges {
|
|||||||
|
|
||||||
export interface LatestMovie {
|
export interface LatestMovie {
|
||||||
adult: boolean;
|
adult: boolean;
|
||||||
backdrop_path?: string;
|
backdrop_path?: any;
|
||||||
belongs_to_collection?: BelongsToCollection;
|
belongs_to_collection?: any;
|
||||||
budget: number;
|
budget: number;
|
||||||
genres: Genre[];
|
genres: Genre[];
|
||||||
homepage: string;
|
homepage: string;
|
||||||
@@ -126,12 +115,12 @@ export interface LatestMovie {
|
|||||||
overview: string;
|
overview: string;
|
||||||
popularity: number;
|
popularity: number;
|
||||||
poster_path: string;
|
poster_path: string;
|
||||||
production_companies: ProductionCompany[];
|
production_companies: any[];
|
||||||
production_countries: ProductionCountry[];
|
production_countries: any[];
|
||||||
release_date: string;
|
release_date: string;
|
||||||
revenue: number;
|
revenue: number;
|
||||||
runtime: number;
|
runtime: number;
|
||||||
spoken_languages: SpokenLanguage[];
|
spoken_languages: any[];
|
||||||
status: string;
|
status: string;
|
||||||
tagline: string;
|
tagline: string;
|
||||||
title: string;
|
title: string;
|
||||||
@@ -140,6 +129,7 @@ export interface LatestMovie {
|
|||||||
vote_count: number;
|
vote_count: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface Dates {
|
export interface Dates {
|
||||||
maximum: string;
|
maximum: string;
|
||||||
minimum: string;
|
minimum: string;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Review } from './';
|
import { Review } from './';
|
||||||
|
|
||||||
export interface ReviewDetails extends Review {
|
export interface ReviewDetails extends Review{
|
||||||
iso_639_1: string;
|
iso_639_1: string;
|
||||||
media_id: number;
|
media_id: number;
|
||||||
media_title: number;
|
media_title: number;
|
||||||
media_type: number;
|
media_type: number;
|
||||||
}
|
}
|
||||||
@@ -4,3 +4,5 @@ export interface Search<T> {
|
|||||||
total_pages: number;
|
total_pages: number;
|
||||||
total_results: number;
|
total_results: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ export type TimeWindow = 'day' | 'week';
|
|||||||
type TrendingResult<T extends MediaType> = T extends 'tv'
|
type TrendingResult<T extends MediaType> = T extends 'tv'
|
||||||
? TV
|
? TV
|
||||||
: T extends 'movie'
|
: T extends 'movie'
|
||||||
? Movie
|
? Movie
|
||||||
: T extends 'person'
|
: T extends 'person'
|
||||||
? Person
|
? Person
|
||||||
: TV | Movie | Person;
|
: TV | Movie | Person;
|
||||||
|
|
||||||
export interface TrendingResults<T extends MediaType> {
|
export interface TrendingResults<T extends MediaType> {
|
||||||
page: number;
|
page: number;
|
||||||
results: (TrendingResult<T> & { media_type: MediaType })[];
|
results: (TrendingResult<T> & {media_type: MediaType})[];
|
||||||
total_pages: number;
|
total_pages: number;
|
||||||
total_results: number;
|
total_results: number;
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,4 @@
|
|||||||
import {
|
import { Genre, ProductionCompany, ProductionCountry, SpokenLanguage, Crew } from './';
|
||||||
Genre,
|
|
||||||
ProductionCompany,
|
|
||||||
ProductionCountry,
|
|
||||||
SpokenLanguage,
|
|
||||||
Crew,
|
|
||||||
} from './';
|
|
||||||
|
|
||||||
export interface CreatedBy {
|
export interface CreatedBy {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -14,21 +8,6 @@ export interface CreatedBy {
|
|||||||
profile_path: string;
|
profile_path: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NextEpisodeToAir {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
overview: string;
|
|
||||||
vote_average: number;
|
|
||||||
vote_count: number;
|
|
||||||
air_date: string;
|
|
||||||
episode_number: number;
|
|
||||||
production_code: string;
|
|
||||||
runtime: number;
|
|
||||||
season_number: number;
|
|
||||||
show_id: number;
|
|
||||||
still_path: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LastEpisodeToAir {
|
export interface LastEpisodeToAir {
|
||||||
air_date: string;
|
air_date: string;
|
||||||
episode_number: number;
|
episode_number: number;
|
||||||
@@ -72,7 +51,7 @@ export interface TvShowDetails {
|
|||||||
last_air_date: string;
|
last_air_date: string;
|
||||||
last_episode_to_air: LastEpisodeToAir;
|
last_episode_to_air: LastEpisodeToAir;
|
||||||
name: string;
|
name: string;
|
||||||
next_episode_to_air?: NextEpisodeToAir;
|
next_episode_to_air?: any;
|
||||||
networks: Network[];
|
networks: Network[];
|
||||||
number_of_episodes: number;
|
number_of_episodes: number;
|
||||||
number_of_seasons: number;
|
number_of_seasons: number;
|
||||||
@@ -94,53 +73,54 @@ export interface TvShowDetails {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface GuestStar {
|
export interface GuestStar {
|
||||||
credit_id: string;
|
credit_id: string
|
||||||
order: number;
|
order: number
|
||||||
character: string;
|
character: string
|
||||||
adult: boolean;
|
adult: boolean
|
||||||
gender: number | null;
|
gender: number | null
|
||||||
id: number;
|
id: number
|
||||||
known_for_department: string;
|
known_for_department: string
|
||||||
name: string;
|
name: string
|
||||||
original_name: string;
|
original_name: string
|
||||||
popularity: number;
|
popularity: number
|
||||||
profile_path: string | null;
|
profile_path: string | null
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Episode {
|
export interface Episode {
|
||||||
air_date: string;
|
air_date: string
|
||||||
episode_number: number;
|
episode_number: number
|
||||||
crew: Crew[];
|
crew: Crew[]
|
||||||
guest_stars: GuestStar[];
|
guest_stars: GuestStar[]
|
||||||
id: number;
|
id: number
|
||||||
name: string;
|
name: string
|
||||||
overview: string;
|
overview: string
|
||||||
production_code: string;
|
production_code: string
|
||||||
season_number: number;
|
season_number: number
|
||||||
still_path: string;
|
still_path: string
|
||||||
vote_average: number;
|
vote_average: number
|
||||||
vote_count: number;
|
vote_count: number
|
||||||
show_id: number;
|
show_id: number;
|
||||||
runtime: number;
|
runtime: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SeasonDetails {
|
export interface SeasonDetails {
|
||||||
air_date: string;
|
air_date: string
|
||||||
episodes: Episode[];
|
episodes: Episode[]
|
||||||
name: string;
|
name: string
|
||||||
overview: string;
|
overview: string
|
||||||
id: number;
|
id: number
|
||||||
poster_path: string | null;
|
poster_path: string | null
|
||||||
season_number: number;
|
season_number: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TvShowItem {
|
export interface TvShowItem {
|
||||||
id: string;
|
id: string;
|
||||||
action: string;
|
action: string;
|
||||||
time: string;
|
time: string;
|
||||||
value: Array<number>;
|
value: any;
|
||||||
iso_639_1: string;
|
iso_639_1: string;
|
||||||
original_value: Array<number>;
|
original_value: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TvShowChange {
|
export interface TvShowChange {
|
||||||
@@ -185,6 +165,7 @@ export interface ScreenedTheatrically {
|
|||||||
results: ScreenedTheatricallyResult[];
|
results: ScreenedTheatricallyResult[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface SimilarTvShow {
|
export interface SimilarTvShow {
|
||||||
backdrop_path: string;
|
backdrop_path: string;
|
||||||
first_air_date: string;
|
first_air_date: string;
|
||||||
@@ -209,8 +190,8 @@ export interface SimilarTvShows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface LatestTvShows {
|
export interface LatestTvShows {
|
||||||
backdrop_path?: string;
|
backdrop_path?: any;
|
||||||
created_by: CreatedBy[];
|
created_by: any[];
|
||||||
episode_run_time: number[];
|
episode_run_time: number[];
|
||||||
first_air_date: string;
|
first_air_date: string;
|
||||||
genres: Genre[];
|
genres: Genre[];
|
||||||
@@ -226,10 +207,10 @@ export interface LatestTvShows {
|
|||||||
origin_country: string[];
|
origin_country: string[];
|
||||||
original_language: string;
|
original_language: string;
|
||||||
original_name: string;
|
original_name: string;
|
||||||
overview?: string;
|
overview?: any;
|
||||||
popularity: number;
|
popularity: number;
|
||||||
poster_path?: string;
|
poster_path?: any;
|
||||||
production_companies: ProductionCompany[];
|
production_companies: any[];
|
||||||
seasons: Season[];
|
seasons: Season[];
|
||||||
status: string;
|
status: string;
|
||||||
type: string;
|
type: string;
|
||||||
@@ -237,6 +218,7 @@ export interface LatestTvShows {
|
|||||||
vote_count: number;
|
vote_count: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface OnTheAirResult {
|
export interface OnTheAirResult {
|
||||||
poster_path: string;
|
poster_path: string;
|
||||||
popularity: number;
|
popularity: number;
|
||||||
@@ -260,6 +242,7 @@ export interface OnTheAir {
|
|||||||
total_pages: number;
|
total_pages: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface AiringTodayResult {
|
export interface AiringTodayResult {
|
||||||
poster_path: string;
|
poster_path: string;
|
||||||
popularity: number;
|
popularity: number;
|
||||||
@@ -283,6 +266,7 @@ export interface TvShowsAiringToday {
|
|||||||
total_pages: number;
|
total_pages: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface PopularTvShowResult {
|
export interface PopularTvShowResult {
|
||||||
poster_path: string;
|
poster_path: string;
|
||||||
popularity: number;
|
popularity: number;
|
||||||
@@ -306,6 +290,7 @@ export interface PopularTvShows {
|
|||||||
total_pages: number;
|
total_pages: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface TopRatedTvShowResult {
|
export interface TopRatedTvShowResult {
|
||||||
poster_path: string;
|
poster_path: string;
|
||||||
popularity: number;
|
popularity: number;
|
||||||
@@ -328,3 +313,5 @@ export interface TopRatedTvShows {
|
|||||||
total_results: number;
|
total_results: number;
|
||||||
total_pages: number;
|
total_pages: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
export interface Flatrate {
|
export interface Flatrate {
|
||||||
display_priority: number;
|
display_priority: number;
|
||||||
logo_path: string;
|
logo_path: string;
|
||||||
@@ -19,6 +20,7 @@ export interface Buy {
|
|||||||
provider_name: string;
|
provider_name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface WatchLocale {
|
export interface WatchLocale {
|
||||||
AR: {
|
AR: {
|
||||||
link: string;
|
link: string;
|
||||||
@@ -296,3 +298,5 @@ export interface WatchProviders {
|
|||||||
id: number;
|
id: number;
|
||||||
results: WatchLocale;
|
results: WatchLocale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,12 +8,7 @@
|
|||||||
* @param {string} imagePath raw image path
|
* @param {string} imagePath raw image path
|
||||||
* @param {boolean} svg get svg version if true
|
* @param {boolean} svg get svg version if true
|
||||||
*/
|
*/
|
||||||
export const getFullImagePath = (
|
export const getFullImagePath = (baseUrl: string, fileSize: string, imagePath: string, svg = false): string => {
|
||||||
baseUrl: string,
|
|
||||||
fileSize: string,
|
|
||||||
imagePath: string,
|
|
||||||
svg = false
|
|
||||||
): string => {
|
|
||||||
const imagePathArr = imagePath.split('.');
|
const imagePathArr = imagePath.split('.');
|
||||||
const imageFormat = svg ? 'svg' : imagePathArr[1];
|
const imageFormat = svg ? 'svg' : imagePathArr[1];
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
export function parseOptions(options?: Record<string, any>): string {
|
export function parseOptions(
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
options?: { [s: string]: any },
|
||||||
return options ? new URLSearchParams(Object.entries(options)).toString() : '';
|
): string {
|
||||||
|
return options
|
||||||
|
? new URLSearchParams(Object.entries(options)).toString()
|
||||||
|
: '';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,28 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ES2022" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
|
"target": "es2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
|
||||||
"module": "CommonJS" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
|
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
|
||||||
"moduleResolution": "node16",
|
|
||||||
"sourceMap": true /* Generates corresponding '.map' file. */,
|
"sourceMap": true /* Generates corresponding '.map' file. */,
|
||||||
"outDir": "dist" /* Redirect output structure to the directory. */,
|
"outDir": "dist" /* Redirect output structure to the directory. */,
|
||||||
"strict": true /* Enable all strict type-checking options. */,
|
"strict": true /* Enable all strict type-checking options. */,
|
||||||
|
"allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||||
"types": ["node"],
|
"types": ["node"],
|
||||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
||||||
|
"experimentalDecorators": true /* Enables experimental support for ES7 decorators. */,
|
||||||
|
"emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */,
|
||||||
"skipLibCheck": true /* Skip type checking of declaration files. */,
|
"skipLibCheck": true /* Skip type checking of declaration files. */,
|
||||||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
|
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
|
||||||
"typeRoots": ["./src/types"]
|
"typeRoots": [
|
||||||
|
"./src/types"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"types": ["node"],
|
"types": ["node"],
|
||||||
"include": ["src"],
|
"include": [
|
||||||
"exclude": ["node_modules", "dist", "./src/types/*.ts"]
|
"src"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"dist",
|
||||||
|
"./src/types/*.ts"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user