Compare commits
32 Commits
chore/v1.6
...
chore/bump
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
@@ -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"],
|
||||
};
|
||||
20
.github/workflows/npm-publish.yml
vendored
20
.github/workflows/npm-publish.yml
vendored
@@ -5,29 +5,29 @@ name: Node.js Package
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 16
|
||||
node-version: '20.x'
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
|
||||
publish-npm:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 16
|
||||
node-version: '20.x'
|
||||
registry-url: https://registry.npmjs.org/
|
||||
- run: npm ci
|
||||
- run: npm publish
|
||||
- run: npm run compile
|
||||
- run: npm publish --provenance --access public
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
||||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,3 +4,4 @@
|
||||
dist
|
||||
/.npmignore
|
||||
.idea
|
||||
.DS_Store
|
||||
@@ -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
|
||||
|
||||
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,
|
||||
];
|
||||
3886
package-lock.json
generated
3886
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
41
package.json
41
package.json
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "tmdb-ts",
|
||||
"version": "1.6.0",
|
||||
"version": "2.0.2",
|
||||
"description": "TMDB v3 library wrapper",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"compile": "rm -rf dist && tsc -d",
|
||||
"lint": "eslint --ext .ts src/",
|
||||
"lint:fix": "eslint --ext .ts src/ --fix",
|
||||
"format": "npx prettier --write src",
|
||||
"lint": "eslint src/",
|
||||
"lint:fix": "eslint --fix",
|
||||
"format": "prettier --write src",
|
||||
"pre-commit": "npm run lint"
|
||||
},
|
||||
"bugs": {
|
||||
@@ -29,27 +29,22 @@
|
||||
"author": "Blake Joynes",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.15.11",
|
||||
"@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": "^10.9.1",
|
||||
"typescript": "^4.9.5"
|
||||
"@eslint/js": "^9.4.0",
|
||||
"@types/eslint__js": "^8.42.3",
|
||||
"@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",
|
||||
"husky": "^9.0.11",
|
||||
"prettier": "^3.3.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.4.5",
|
||||
"typescript-eslint": "^7.12.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"cross-fetch": "^3.1.4"
|
||||
},
|
||||
"volta": {
|
||||
"node": "18.16.0",
|
||||
"yarn": "1.22.4",
|
||||
"npm": "9.5.1"
|
||||
"cross-fetch": "^4.0.0"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
|
||||
10
src/api.ts
10
src/api.ts
@@ -1,13 +1,14 @@
|
||||
import fetch from 'cross-fetch';
|
||||
import { parseOptions } from './utils';
|
||||
|
||||
const BASE_URL_V3 = 'https://api.themoviedb.org/3';
|
||||
import { ErrorResponse } from './types';
|
||||
import { BASE_URL_V3 } from './common/constants';
|
||||
|
||||
export class Api {
|
||||
constructor(private accessToken: string) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
/* 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}`, {
|
||||
@@ -17,6 +18,11 @@ export class Api {
|
||||
'Content-Type': 'application/json;charset=utf-8',
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
return Promise.reject((await response.json()) as ErrorResponse);
|
||||
}
|
||||
|
||||
return (await response.json()) as T;
|
||||
}
|
||||
}
|
||||
|
||||
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';
|
||||
@@ -15,6 +15,6 @@ export class ChangeEndpoint extends BaseEndpoint {
|
||||
}
|
||||
|
||||
async person(options?: ChangeOption): Promise<MediaChanges> {
|
||||
return await this.api.get<MediaChanges>(`/person/change`, options);
|
||||
return await this.api.get<MediaChanges>(`/person/changes`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
CollectionDetails,
|
||||
CollectionImageOptions,
|
||||
DetailedCollection,
|
||||
ImageCollection,
|
||||
LanguageOption,
|
||||
Translations,
|
||||
@@ -17,14 +17,17 @@ export class CollectionsEndpoint extends BaseEndpoint {
|
||||
async details(
|
||||
id: number,
|
||||
options?: LanguageOption
|
||||
): Promise<DetailedCollection> {
|
||||
return await this.api.get<DetailedCollection>(
|
||||
): Promise<CollectionDetails> {
|
||||
return await this.api.get<CollectionDetails>(
|
||||
`${BASE_COLLECTION}/${id}`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async images(id: number, options?: CollectionImageOptions): Promise<ImageCollection> {
|
||||
async images(
|
||||
id: number,
|
||||
options?: CollectionImageOptions
|
||||
): Promise<ImageCollection> {
|
||||
const computedOptions = {
|
||||
include_image_language: options?.include_image_language?.join(','),
|
||||
language: options?.language,
|
||||
|
||||
@@ -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,68 +1,13 @@
|
||||
import {
|
||||
MovieDiscoverResult,
|
||||
SortOption,
|
||||
MovieQueryOptions,
|
||||
TvShowDiscoverResult,
|
||||
TvShowQueryOptions,
|
||||
} from '../types';
|
||||
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);
|
||||
|
||||
@@ -6,10 +6,10 @@ export class FindEndpoint extends BaseEndpoint {
|
||||
super(accessToken);
|
||||
}
|
||||
|
||||
async byId(
|
||||
externalId: string,
|
||||
async byExternalId(
|
||||
id: string,
|
||||
options: ExternalIdOptions
|
||||
): Promise<FindResult> {
|
||||
return await this.api.get<FindResult>(`/find/${externalId}`, options);
|
||||
return await this.api.get<FindResult>(`/find/${id}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,3 +16,4 @@ export * from './keywords';
|
||||
export * from './collections';
|
||||
export * from './tv-seasons';
|
||||
export * from './tv-episode';
|
||||
export * from './watch-providers';
|
||||
|
||||
@@ -12,6 +12,10 @@ export class KeywordsEndpoint extends BaseEndpoint {
|
||||
return await this.api.get<Keyword>(`${BASE_Keyword}/${keywordId}`);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
async belongingMovies(
|
||||
keywordId: number,
|
||||
options?: KeywordsOptions
|
||||
|
||||
@@ -35,7 +35,7 @@ export interface MoviesImageSearchOptions extends LanguageOption {
|
||||
/**
|
||||
* a list of ISO-639-1 values to query
|
||||
*/
|
||||
include_image_language?: string[],
|
||||
include_image_language?: string[];
|
||||
}
|
||||
|
||||
export class MoviesEndpoint extends BaseEndpoint {
|
||||
@@ -85,12 +85,18 @@ export class MoviesEndpoint extends BaseEndpoint {
|
||||
return await this.api.get<ExternalIds>(`${BASE_MOVIE}/${id}/external_ids`);
|
||||
}
|
||||
|
||||
async images(id: number, options?: MoviesImageSearchOptions): Promise<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);
|
||||
return await this.api.get<Images>(
|
||||
`${BASE_MOVIE}/${id}/images`,
|
||||
computedOptions
|
||||
);
|
||||
}
|
||||
|
||||
async keywords(id: number): Promise<Keywords> {
|
||||
@@ -120,11 +126,17 @@ export class MoviesEndpoint extends BaseEndpoint {
|
||||
);
|
||||
}
|
||||
|
||||
async reviews(id: number, options?: LanguageOption & PageOption): Promise<Reviews> {
|
||||
async reviews(
|
||||
id: number,
|
||||
options?: LanguageOption & PageOption
|
||||
): Promise<Reviews> {
|
||||
return await this.api.get<Reviews>(`${BASE_MOVIE}/${id}/reviews`, options);
|
||||
}
|
||||
|
||||
async similar(id: number, options?: LanguageOption & PageOption): Promise<SimilarMovies> {
|
||||
async similar(
|
||||
id: number,
|
||||
options?: LanguageOption & PageOption
|
||||
): Promise<SimilarMovies> {
|
||||
return await this.api.get<SimilarMovies>(
|
||||
`${BASE_MOVIE}/${id}/similar`,
|
||||
options
|
||||
|
||||
@@ -10,11 +10,11 @@ import {
|
||||
PersonDetails,
|
||||
PersonMovieCredit,
|
||||
PersonTvShowCredit,
|
||||
PopularPersons,
|
||||
TaggedImages,
|
||||
Changes,
|
||||
PersonChangeValue,
|
||||
LanguageOption,
|
||||
PopularPeople,
|
||||
} from '../types';
|
||||
import { BaseEndpoint } from './base';
|
||||
|
||||
@@ -34,7 +34,7 @@ export class PeopleEndpoint extends BaseEndpoint {
|
||||
append_to_response: appendToResponse
|
||||
? appendToResponse.join(',')
|
||||
: undefined,
|
||||
language: language
|
||||
language: language,
|
||||
};
|
||||
return await this.api.get<AppendToResponse<PersonDetails, T, 'person'>>(
|
||||
`${BASE_PERSON}/${id}`,
|
||||
@@ -52,21 +52,30 @@ export class PeopleEndpoint extends BaseEndpoint {
|
||||
);
|
||||
}
|
||||
|
||||
async movieCredits(id: number, options?: LanguageOption): Promise<PersonMovieCredit> {
|
||||
async movieCredits(
|
||||
id: number,
|
||||
options?: LanguageOption
|
||||
): Promise<PersonMovieCredit> {
|
||||
return await this.api.get<PersonMovieCredit>(
|
||||
`${BASE_PERSON}/${id}/movie_credits`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async tvShowCredits(id: number, options?: LanguageOption): Promise<PersonTvShowCredit> {
|
||||
async tvShowCredits(
|
||||
id: number,
|
||||
options?: LanguageOption
|
||||
): Promise<PersonTvShowCredit> {
|
||||
return await this.api.get<PersonTvShowCredit>(
|
||||
`${BASE_PERSON}/${id}/tv_credits`,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async combinedCredits(id: number, options?: LanguageOption): Promise<PersonCombinedCredits> {
|
||||
async combinedCredits(
|
||||
id: number,
|
||||
options?: LanguageOption
|
||||
): Promise<PersonCombinedCredits> {
|
||||
return await this.api.get<PersonCombinedCredits>(
|
||||
`${BASE_PERSON}/${id}/combined_credits`,
|
||||
options
|
||||
@@ -81,6 +90,9 @@ export class PeopleEndpoint extends BaseEndpoint {
|
||||
return await this.api.get<PeopleImages>(`${BASE_PERSON}/${id}/images`);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
async taggedImages(id: number, options?: PageOption): Promise<TaggedImages> {
|
||||
return await this.api.get<TaggedImages>(
|
||||
`${BASE_PERSON}/${id}/tagged_images`,
|
||||
@@ -98,10 +110,7 @@ export class PeopleEndpoint extends BaseEndpoint {
|
||||
return await this.api.get<PersonDetails>(`${BASE_PERSON}/latest`);
|
||||
}
|
||||
|
||||
async popular(options?: LanguageOption & PageOption): Promise<PopularPersons> {
|
||||
return await this.api.get<PopularPersons>(
|
||||
`${BASE_PERSON}/popular`,
|
||||
options
|
||||
);
|
||||
async popular(options?: LanguageOption & PageOption): Promise<PopularPeople> {
|
||||
return await this.api.get<PopularPeople>(`${BASE_PERSON}/popular`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
import { BaseEndpoint } from './base';
|
||||
import { MultiSearchResult, Search } from '../types/search';
|
||||
import { Collection, Company, LanguageOption, Movie, PageOption, Person, RegionOption, TV } from '../types';
|
||||
import {
|
||||
Collection,
|
||||
Company,
|
||||
LanguageOption,
|
||||
Movie,
|
||||
PageOption,
|
||||
Person,
|
||||
RegionOption,
|
||||
TV,
|
||||
} from '../types';
|
||||
|
||||
const BASE_SEARCH = '/search';
|
||||
|
||||
@@ -9,27 +18,44 @@ export interface SearchOptions {
|
||||
page?: number;
|
||||
}
|
||||
|
||||
export interface MovieSearchOptions extends SearchOptions, LanguageOption, PageOption, RegionOption {
|
||||
export interface MovieSearchOptions
|
||||
extends SearchOptions,
|
||||
LanguageOption,
|
||||
PageOption,
|
||||
RegionOption {
|
||||
include_adult?: boolean;
|
||||
year?: number;
|
||||
primary_release_year?: number;
|
||||
}
|
||||
|
||||
export interface CollectionSearchOptions extends SearchOptions, LanguageOption, PageOption, RegionOption {
|
||||
export interface CollectionSearchOptions
|
||||
extends SearchOptions,
|
||||
LanguageOption,
|
||||
PageOption,
|
||||
RegionOption {
|
||||
include_adult?: boolean;
|
||||
}
|
||||
|
||||
export interface TvSearchOptions extends SearchOptions, LanguageOption, PageOption {
|
||||
export interface TvSearchOptions
|
||||
extends SearchOptions,
|
||||
LanguageOption,
|
||||
PageOption {
|
||||
include_adult?: boolean;
|
||||
year?: number;
|
||||
first_air_date_year?: number;
|
||||
}
|
||||
|
||||
export interface PeopleSearchOptions extends SearchOptions, LanguageOption, PageOption {
|
||||
export interface PeopleSearchOptions
|
||||
extends SearchOptions,
|
||||
LanguageOption,
|
||||
PageOption {
|
||||
include_adult?: boolean;
|
||||
}
|
||||
|
||||
export interface MultiSearchOptions extends SearchOptions, LanguageOption, PageOption {
|
||||
export interface MultiSearchOptions
|
||||
extends SearchOptions,
|
||||
LanguageOption,
|
||||
PageOption {
|
||||
include_adult?: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { TrendingMediaType, TimeWindow, TrendingResults, LanguageOption } from '../types';
|
||||
import {
|
||||
TrendingMediaType,
|
||||
TimeWindow,
|
||||
TrendingResults,
|
||||
LanguageOption,
|
||||
PageOption,
|
||||
} from '../types';
|
||||
import { BaseEndpoint } from './base';
|
||||
|
||||
export class TrendingEndpoint extends BaseEndpoint {
|
||||
@@ -9,7 +15,7 @@ export class TrendingEndpoint extends BaseEndpoint {
|
||||
async trending<T extends TrendingMediaType>(
|
||||
mediaType: T,
|
||||
timeWindow: TimeWindow,
|
||||
options?: LanguageOption
|
||||
options?: LanguageOption & PageOption
|
||||
): Promise<TrendingResults<T>> {
|
||||
return await this.api.get<TrendingResults<T>>(
|
||||
`/trending/${mediaType}/${timeWindow}`,
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
Images,
|
||||
TvEpisodeTranslations,
|
||||
Videos,
|
||||
AppendToResponseMovieKey,
|
||||
AppendToResponse,
|
||||
Changes,
|
||||
TvEpisodeChangeValue,
|
||||
@@ -24,14 +23,14 @@ export interface TvEpisodeImageSearchOptions extends LanguageOption {
|
||||
/**
|
||||
* a list of ISO-639-1 values to query
|
||||
*/
|
||||
include_image_language?: string[],
|
||||
include_image_language?: string[];
|
||||
}
|
||||
|
||||
export interface TvEpisodeVideoSearchOptions extends LanguageOption {
|
||||
/**
|
||||
* a list of ISO-639-1 values to query
|
||||
*/
|
||||
include_video_language?: string[],
|
||||
include_video_language?: string[];
|
||||
}
|
||||
|
||||
export class TvEpisodesEndpoint extends BaseEndpoint {
|
||||
@@ -76,7 +75,10 @@ export class TvEpisodesEndpoint extends BaseEndpoint {
|
||||
);
|
||||
}
|
||||
|
||||
async images(episodeSelection: EpisodeSelection, options?: TvEpisodeImageSearchOptions) {
|
||||
async images(
|
||||
episodeSelection: EpisodeSelection,
|
||||
options?: TvEpisodeImageSearchOptions
|
||||
) {
|
||||
const computedOptions = {
|
||||
include_image_language: options?.include_image_language?.join(','),
|
||||
language: options?.language,
|
||||
@@ -93,7 +95,10 @@ export class TvEpisodesEndpoint extends BaseEndpoint {
|
||||
);
|
||||
}
|
||||
|
||||
async videos(episodeSelection: EpisodeSelection, options?: TvEpisodeVideoSearchOptions) {
|
||||
async videos(
|
||||
episodeSelection: EpisodeSelection,
|
||||
options?: TvEpisodeVideoSearchOptions
|
||||
) {
|
||||
const computedOptions = {
|
||||
include_video_language: options?.include_video_language?.join(','),
|
||||
language: options?.language,
|
||||
|
||||
@@ -24,14 +24,14 @@ export interface TvSeasonImageSearchOptions extends LanguageOption {
|
||||
/**
|
||||
* a list of ISO-639-1 values to query
|
||||
*/
|
||||
include_image_language?: string[],
|
||||
include_image_language?: string[];
|
||||
}
|
||||
|
||||
export interface TvSeasonVideoSearchOptions extends LanguageOption {
|
||||
/**
|
||||
* a list of ISO-639-1 values to query
|
||||
*/
|
||||
include_video_language?: string[],
|
||||
include_video_language?: string[];
|
||||
}
|
||||
|
||||
export class TvSeasonsEndpoint extends BaseEndpoint {
|
||||
@@ -91,7 +91,10 @@ export class TvSeasonsEndpoint extends BaseEndpoint {
|
||||
);
|
||||
}
|
||||
|
||||
async images(seasonSelection: SeasonSelection, options?: TvSeasonImageSearchOptions) {
|
||||
async images(
|
||||
seasonSelection: SeasonSelection,
|
||||
options?: TvSeasonImageSearchOptions
|
||||
) {
|
||||
const computedOptions = {
|
||||
include_image_language: options?.include_image_language?.join(','),
|
||||
language: options?.language,
|
||||
@@ -102,7 +105,10 @@ export class TvSeasonsEndpoint extends BaseEndpoint {
|
||||
);
|
||||
}
|
||||
|
||||
async videos(seasonSelection: SeasonSelection, options?: TvSeasonVideoSearchOptions) {
|
||||
async videos(
|
||||
seasonSelection: SeasonSelection,
|
||||
options?: TvSeasonVideoSearchOptions
|
||||
) {
|
||||
const computedOptions = {
|
||||
include_video_language: options?.include_video_language?.join(','),
|
||||
language: options?.language,
|
||||
|
||||
@@ -80,7 +80,10 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
||||
);
|
||||
}
|
||||
|
||||
async aggregateCredits(id: number, options?: LanguageOption): Promise<AggregateCredits> {
|
||||
async aggregateCredits(
|
||||
id: number,
|
||||
options?: LanguageOption
|
||||
): Promise<AggregateCredits> {
|
||||
return await this.api.get<AggregateCredits>(
|
||||
`${BASE_TV}/${id}/aggregate_credits`,
|
||||
options
|
||||
@@ -110,7 +113,10 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
||||
include_image_language: options?.include_image_language?.join(','),
|
||||
language: options?.language,
|
||||
};
|
||||
return await this.api.get<Images>(`${BASE_TV}/${id}/images`, computedOptions);
|
||||
return await this.api.get<Images>(
|
||||
`${BASE_TV}/${id}/images`,
|
||||
computedOptions
|
||||
);
|
||||
}
|
||||
|
||||
async keywords(id: number): Promise<Keywords> {
|
||||
@@ -127,7 +133,10 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
||||
);
|
||||
}
|
||||
|
||||
async reviews(id: number, options?: LanguageOption & PageOption): Promise<Reviews> {
|
||||
async reviews(
|
||||
id: number,
|
||||
options?: LanguageOption & PageOption
|
||||
): Promise<Reviews> {
|
||||
return await this.api.get<Reviews>(`${BASE_TV}/${id}/reviews`, options);
|
||||
}
|
||||
|
||||
@@ -137,7 +146,10 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
||||
);
|
||||
}
|
||||
|
||||
async similar(id: number, options?: LanguageOption & PageOption): Promise<SimilarTvShows> {
|
||||
async similar(
|
||||
id: number,
|
||||
options?: LanguageOption & PageOption
|
||||
): Promise<SimilarTvShows> {
|
||||
return await this.api.get<SimilarTvShows>(
|
||||
`${BASE_TV}/${id}/similar`,
|
||||
options
|
||||
@@ -153,7 +165,10 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
||||
include_video_language: options?.include_video_language?.join(','),
|
||||
language: options?.language,
|
||||
};
|
||||
return await this.api.get<Videos>(`${BASE_TV}/${id}/videos`, computedOptions);
|
||||
return await this.api.get<Videos>(
|
||||
`${BASE_TV}/${id}/videos`,
|
||||
computedOptions
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
CollectionsEndpoint,
|
||||
TvSeasonsEndpoint,
|
||||
TvEpisodesEndpoint,
|
||||
WatchProvidersEndpoint,
|
||||
} from './endpoints';
|
||||
import { CompaniesEndpoint } from './endpoints/companies';
|
||||
import { NetworksEndpoint } from './endpoints/networks';
|
||||
@@ -107,4 +108,8 @@ export class TMDB {
|
||||
get tvSeasons(): TvSeasonsEndpoint {
|
||||
return new TvSeasonsEndpoint(this.accessToken);
|
||||
}
|
||||
|
||||
get watchProviders(): WatchProvidersEndpoint {
|
||||
return new WatchProvidersEndpoint(this.accessToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { CountryCode } from '../types';
|
||||
|
||||
export interface Gravatar {
|
||||
hash: string;
|
||||
}
|
||||
@@ -10,7 +12,7 @@ export interface AccountDetails {
|
||||
avatar: Avatar;
|
||||
id: number;
|
||||
include_adult: boolean;
|
||||
iso_3166_1: string;
|
||||
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,6 +1,6 @@
|
||||
export interface MediaChange {
|
||||
id: number;
|
||||
adult: boolean | undefined;
|
||||
adult?: boolean;
|
||||
}
|
||||
|
||||
export interface MediaChanges {
|
||||
|
||||
@@ -2,16 +2,13 @@ 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[];
|
||||
}
|
||||
|
||||
@@ -19,5 +16,5 @@ export interface CollectionImageOptions extends LanguageOption {
|
||||
/**
|
||||
* a list of ISO-639-1 values to query
|
||||
*/
|
||||
include_image_language?: string[],
|
||||
}
|
||||
include_image_language?: string[];
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ export interface CompanyDetails {
|
||||
logo_path: string;
|
||||
name: string;
|
||||
origin_country: string;
|
||||
parent_company: ParentCompany;
|
||||
parent_company?: ParentCompany;
|
||||
}
|
||||
|
||||
export interface ParentCompany {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { CountryCode } from '../types';
|
||||
|
||||
export interface ImageConfiguration {
|
||||
base_url: string;
|
||||
secure_base_url: string;
|
||||
@@ -13,99 +15,153 @@ export interface Configuration {
|
||||
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;
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -19,6 +19,12 @@ 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 {
|
||||
@@ -33,6 +39,7 @@ export type KnownFor = MovieWithMediaType | TVWithMediaType;
|
||||
export interface Person {
|
||||
id: number;
|
||||
name: string;
|
||||
original_name: string;
|
||||
known_for: KnownFor[];
|
||||
profile_path: string;
|
||||
adult: boolean;
|
||||
@@ -75,6 +82,7 @@ export interface Company {
|
||||
|
||||
export interface TV {
|
||||
id: number;
|
||||
adult: boolean;
|
||||
name: string;
|
||||
first_air_date: string;
|
||||
backdrop_path: string;
|
||||
@@ -103,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;
|
||||
}
|
||||
|
||||
@@ -114,7 +129,7 @@ export interface ProductionCompany {
|
||||
}
|
||||
|
||||
export interface ProductionCountry {
|
||||
iso_3166_1: string;
|
||||
iso_3166_1: CountryCode;
|
||||
name: string;
|
||||
}
|
||||
|
||||
@@ -131,7 +146,7 @@ export interface ContentRatings {
|
||||
|
||||
export interface ContentRatingsResult {
|
||||
descriptor: unknown[];
|
||||
iso_3166_1: string;
|
||||
iso_3166_1: CountryCode;
|
||||
rating: string;
|
||||
}
|
||||
|
||||
@@ -163,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;
|
||||
}
|
||||
|
||||
@@ -184,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;
|
||||
@@ -212,3 +227,71 @@ export interface Images {
|
||||
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,4 +1,5 @@
|
||||
import {
|
||||
CountryCode,
|
||||
Genre,
|
||||
Movie,
|
||||
ProductionCompany,
|
||||
@@ -21,7 +22,7 @@ export interface MovieDetails {
|
||||
genres: Genre[];
|
||||
homepage: string;
|
||||
id: number;
|
||||
imdb_id: string;
|
||||
imdb_id: string | null;
|
||||
original_language: string;
|
||||
original_title: string;
|
||||
overview: string;
|
||||
@@ -52,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[];
|
||||
}
|
||||
|
||||
@@ -102,7 +104,7 @@ export interface LatestMovie {
|
||||
genres: Genre[];
|
||||
homepage: string;
|
||||
id: number;
|
||||
imdb_id: string;
|
||||
imdb_id: string | null;
|
||||
original_language: string;
|
||||
original_title: string;
|
||||
overview: string;
|
||||
|
||||
@@ -30,10 +30,157 @@ import {
|
||||
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 {
|
||||
@@ -49,8 +196,8 @@ export interface PageOption {
|
||||
}
|
||||
|
||||
export interface ChangeOption extends PageOption {
|
||||
start_date?: Date;
|
||||
end_date?: Date;
|
||||
start_date?: string;
|
||||
end_date?: string;
|
||||
}
|
||||
|
||||
export type AppendToResponseMovieKey =
|
||||
@@ -129,112 +276,114 @@ export type AppendToResponseMediaType =
|
||||
export type AppendToResponse<
|
||||
K,
|
||||
T extends AppendToResponseAllKeys[] | undefined,
|
||||
Media extends AppendToResponseMediaType
|
||||
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]
|
||||
? ('credits' extends T[number]
|
||||
? {
|
||||
images: Omit<
|
||||
Media extends 'person' ? PeopleImages : Images,
|
||||
'id'
|
||||
>;
|
||||
credits: Media extends 'tvEpisode'
|
||||
? TvEpisodeCredit
|
||||
: Omit<Credits, '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
|
||||
('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'
|
||||
? 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);
|
||||
? 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 { Image, Movie, Person, TV } from '.';
|
||||
import { CountryCode, Image, Movie, Person, TV } from '.';
|
||||
|
||||
interface Cast {
|
||||
character: string;
|
||||
@@ -104,7 +104,7 @@ export type PersonChangeValue =
|
||||
};
|
||||
};
|
||||
|
||||
export interface PopularPersons {
|
||||
export interface PopularPeople {
|
||||
page: number;
|
||||
results: Person[];
|
||||
total_results: number;
|
||||
@@ -140,7 +140,7 @@ export interface TaggedImages {
|
||||
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;
|
||||
}
|
||||
@@ -15,10 +15,10 @@ export type TrendingMediaType = MediaType | 'all';
|
||||
type TrendingResult<T extends TrendingMediaType> = T extends 'tv'
|
||||
? TV
|
||||
: T extends 'movie'
|
||||
? Movie
|
||||
: T extends 'person'
|
||||
? Person
|
||||
: TVWithMediaType | MovieWithMediaType | PersonWithMediaType;
|
||||
? Movie
|
||||
: T extends 'person'
|
||||
? Person
|
||||
: TVWithMediaType | MovieWithMediaType | PersonWithMediaType;
|
||||
|
||||
export interface TrendingResults<T extends TrendingMediaType> {
|
||||
page: number;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Credits, Crew } from '.';
|
||||
import { CountryCode, Credits, Crew } from '.';
|
||||
|
||||
export interface EpisodeSelection {
|
||||
tvShowID: number;
|
||||
@@ -44,7 +44,7 @@ export interface TvEpisodeCredit extends Credits {
|
||||
export interface TvEpisodeTranslations {
|
||||
id: number;
|
||||
translations: {
|
||||
iso_3166_1: string;
|
||||
iso_3166_1: CountryCode;
|
||||
iso_639_1: string;
|
||||
name: string;
|
||||
english_name: string;
|
||||
|
||||
@@ -279,12 +279,12 @@ export interface TvShowImageOptions extends LanguageOption {
|
||||
/**
|
||||
* a list of ISO-639-1 values to query
|
||||
*/
|
||||
include_image_language?: string[],
|
||||
include_image_language?: string[];
|
||||
}
|
||||
|
||||
export interface TvShowVideoOptions extends LanguageOption {
|
||||
/**
|
||||
* a list of ISO-639-1 values to query
|
||||
*/
|
||||
include_video_language?: string[],
|
||||
}
|
||||
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,4 +1,8 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
export function parseOptions(options?: Record<string, any>): string {
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
return options ? new URLSearchParams(Object.entries(options)).toString() : '';
|
||||
return options
|
||||
? new URLSearchParams(
|
||||
Object.entries(options).filter(([, v]) => v) // remove undefined
|
||||
).toString()
|
||||
: '';
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', '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": "node16",
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true /* Generates corresponding '.map' file. */,
|
||||
"outDir": "dist" /* Redirect output structure to the directory. */,
|
||||
"strict": true /* Enable all strict type-checking options. */,
|
||||
|
||||
Reference in New Issue
Block a user