Compare commits
12 Commits
feat/add_l
...
feat/publi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e111921b5 | ||
|
|
c95a66baae | ||
|
|
f3f4868ef8 | ||
|
|
6bcddc62f1 | ||
|
|
2b26b7b848 | ||
|
|
6c361002bf | ||
|
|
6fd471b921 | ||
|
|
60a2f8e00e | ||
|
|
933ebf25a3 | ||
|
|
5d38a76997 | ||
|
|
562864a70f | ||
|
|
1200064194 |
33
.github/workflows/npm-publish.yml
vendored
Normal file
33
.github/workflows/npm-publish.yml
vendored
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
||||||
|
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
||||||
|
|
||||||
|
name: Node.js Package
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
|
||||||
|
publish-npm:
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16
|
||||||
|
registry-url: https://registry.npmjs.org/
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm publish
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tmdb-ts",
|
"name": "tmdb-ts",
|
||||||
"version": "0.1.8",
|
"version": "0.2.0",
|
||||||
"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",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
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';
|
||||||
|
|
||||||
@@ -7,8 +8,9 @@ export default class Api {
|
|||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
async get<T>(path: string): Promise<T> {
|
async get<T>(path: string, options?: Record<string, any>): Promise<T> {
|
||||||
const response = await fetch(`${BASE_URL_V3}${path}`, {
|
const params = parseOptions(options);
|
||||||
|
const response = await fetch(`${BASE_URL_V3}${path}?${params}`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${this.accessToken}`,
|
Authorization: `Bearer ${this.accessToken}`,
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
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<any> {
|
async details(): Promise<AccountDetails> {
|
||||||
return await this.api.get('/account');
|
return await this.api.get('/account');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
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) {
|
||||||
@@ -8,17 +7,14 @@ export class ChangeEndpoint extends BaseEndpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async movies(options?: ChangeOptions): Promise<Changes> {
|
async movies(options?: ChangeOptions): Promise<Changes> {
|
||||||
const params = parseOptions(options);
|
return await this.api.get<Changes>(`/movie/changes`, options);
|
||||||
return await this.api.get<Changes>(`/movie/changes?${params}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async tvShows(options?: ChangeOptions): Promise<Changes> {
|
async tvShows(options?: ChangeOptions): Promise<Changes> {
|
||||||
const params = parseOptions(options);
|
return await this.api.get<Changes>(`/tv/changes`, options);
|
||||||
return await this.api.get<Changes>(`/tv/changes?${params}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async person(options?: ChangeOptions): Promise<Changes> {
|
async person(options?: ChangeOptions): Promise<Changes> {
|
||||||
const params = parseOptions(options);
|
return await this.api.get<Changes>(`/person/change`, options);
|
||||||
return await this.api.get<Changes>(`/person/changes${params}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import {
|
|||||||
LanguageOption,
|
LanguageOption,
|
||||||
Translations,
|
Translations,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { parseOptions } from '../utils';
|
|
||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
|
|
||||||
const BASE_COLLECTION = '/collection';
|
const BASE_COLLECTION = '/collection';
|
||||||
@@ -18,16 +17,16 @@ export class CollectionsEndpoint extends BaseEndpoint {
|
|||||||
id: number,
|
id: number,
|
||||||
options?: LanguageOption
|
options?: LanguageOption
|
||||||
): Promise<DetailedCollection> {
|
): Promise<DetailedCollection> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<DetailedCollection>(
|
return await this.api.get<DetailedCollection>(
|
||||||
`${BASE_COLLECTION}/${id}?${params}`
|
`${BASE_COLLECTION}/${id}`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async images(id: number, options?: LanguageOption): Promise<ImageCollection> {
|
async images(id: number, options?: LanguageOption): Promise<ImageCollection> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<ImageCollection>(
|
return await this.api.get<ImageCollection>(
|
||||||
`${BASE_COLLECTION}/${id}/images?${params}`
|
`${BASE_COLLECTION}/${id}/images`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,9 +34,9 @@ export class CollectionsEndpoint extends BaseEndpoint {
|
|||||||
id: number,
|
id: number,
|
||||||
options?: LanguageOption
|
options?: LanguageOption
|
||||||
): Promise<Translations> {
|
): Promise<Translations> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<Translations>(
|
return await this.api.get<Translations>(
|
||||||
`${BASE_COLLECTION}/${id}/translations?${params}`
|
`${BASE_COLLECTION}/${id}/translations`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import {
|
|||||||
SortOption,
|
SortOption,
|
||||||
TvShowDiscoverResult,
|
TvShowDiscoverResult,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { parseOptions } from '../utils';
|
|
||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
|
|
||||||
const BASE_DISCOVER = '/discover';
|
const BASE_DISCOVER = '/discover';
|
||||||
@@ -70,16 +69,16 @@ export class DiscoverEndpoint extends BaseEndpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async movie(options?: MovieQueryOptions): Promise<MovieDiscoverResult> {
|
async movie(options?: MovieQueryOptions): Promise<MovieDiscoverResult> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<MovieDiscoverResult>(
|
return await this.api.get<MovieDiscoverResult>(
|
||||||
`${BASE_DISCOVER}/movie?${params}`
|
`${BASE_DISCOVER}/movie`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async tvShow(options?: TvShowQueryOptions): Promise<TvShowDiscoverResult> {
|
async tvShow(options?: TvShowQueryOptions): Promise<TvShowDiscoverResult> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<TvShowDiscoverResult>(
|
return await this.api.get<TvShowDiscoverResult>(
|
||||||
`${BASE_DISCOVER}/tv?${params}`
|
`${BASE_DISCOVER}/tv`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
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) {
|
||||||
@@ -11,7 +10,6 @@ export class FindEndpoint extends BaseEndpoint {
|
|||||||
externalId: string,
|
externalId: string,
|
||||||
options: ExternalIdOptions
|
options: ExternalIdOptions
|
||||||
): Promise<FindResult> {
|
): Promise<FindResult> {
|
||||||
const params = parseOptions(options);
|
return await this.api.get<FindResult>(`/find/${externalId}`, options);
|
||||||
return await this.api.get<FindResult>(`/find/${externalId}?${params}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
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';
|
||||||
|
|
||||||
@@ -17,9 +16,9 @@ export class KeywordsEndpoint extends BaseEndpoint {
|
|||||||
keywordId: number,
|
keywordId: number,
|
||||||
options?: KeywordsOptions
|
options?: KeywordsOptions
|
||||||
): Promise<BelongingMovies> {
|
): Promise<BelongingMovies> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<BelongingMovies>(
|
return await this.api.get<BelongingMovies>(
|
||||||
`${BASE_Keyword}/${keywordId}/movies?${params}`
|
`${BASE_Keyword}/${keywordId}/movies`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import {
|
|||||||
Videos,
|
Videos,
|
||||||
WatchProviders,
|
WatchProviders,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { parseOptions } from '../utils';
|
|
||||||
|
|
||||||
const BASE_MOVIE = '/movie';
|
const BASE_MOVIE = '/movie';
|
||||||
|
|
||||||
@@ -45,9 +44,9 @@ export class MoviesEndpoint extends BaseEndpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async changes(id: number, options?: ChangeOptions): Promise<MovieChanges> {
|
async changes(id: number, options?: ChangeOptions): Promise<MovieChanges> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<MovieChanges>(
|
return await this.api.get<MovieChanges>(
|
||||||
`${BASE_MOVIE}/${id}/changes?${params}`
|
`${BASE_MOVIE}/${id}/changes`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,19 +70,16 @@ export class MoviesEndpoint extends BaseEndpoint {
|
|||||||
id: number,
|
id: number,
|
||||||
options?: LanguageOption | PageOption
|
options?: LanguageOption | PageOption
|
||||||
): Promise<MovieLists> {
|
): Promise<MovieLists> {
|
||||||
const params = parseOptions(options);
|
return await this.api.get<MovieLists>(`${BASE_MOVIE}/${id}/lists`, options);
|
||||||
return await this.api.get<MovieLists>(
|
|
||||||
`${BASE_MOVIE}/${id}/lists?${params}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async recommendations(
|
async recommendations(
|
||||||
id: number,
|
id: number,
|
||||||
options?: PageOption
|
options?: PageOption
|
||||||
): Promise<Recommendations> {
|
): Promise<Recommendations> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<Recommendations>(
|
return await this.api.get<Recommendations>(
|
||||||
`${BASE_MOVIE}/${id}/recommendations?${params}`
|
`${BASE_MOVIE}/${id}/recommendations`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,14 +90,13 @@ export class MoviesEndpoint extends BaseEndpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async reviews(id: number, options?: PageOption): Promise<Reviews> {
|
async reviews(id: number, options?: PageOption): Promise<Reviews> {
|
||||||
const params = parseOptions(options);
|
return await this.api.get<Reviews>(`${BASE_MOVIE}/${id}/reviews`, 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> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<SimilarMovies>(
|
return await this.api.get<SimilarMovies>(
|
||||||
`${BASE_MOVIE}/${id}/similar?${params}`
|
`${BASE_MOVIE}/${id}/similar`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,32 +125,31 @@ export class MoviesEndpoint extends BaseEndpoint {
|
|||||||
async nowPlaying(
|
async nowPlaying(
|
||||||
options?: PageOption & LanguageOption & RegionOption
|
options?: PageOption & LanguageOption & RegionOption
|
||||||
): Promise<MoviesPlayingNow> {
|
): Promise<MoviesPlayingNow> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<MoviesPlayingNow>(
|
return await this.api.get<MoviesPlayingNow>(
|
||||||
`${BASE_MOVIE}/now_playing?${params}`
|
`${BASE_MOVIE}/now_playing`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async popular(options?: PageOption): Promise<PopularMovies> {
|
async popular(options?: PageOption): Promise<PopularMovies> {
|
||||||
const params = parseOptions(options);
|
return await this.api.get<PopularMovies>(`${BASE_MOVIE}/popular`, options);
|
||||||
return await this.api.get<PopularMovies>(`${BASE_MOVIE}/popular?${params}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async topRated(
|
async topRated(
|
||||||
options?: PageOption & LanguageOption & RegionOption
|
options?: PageOption & LanguageOption & RegionOption
|
||||||
): Promise<TopRatedMovies> {
|
): Promise<TopRatedMovies> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<TopRatedMovies>(
|
return await this.api.get<TopRatedMovies>(
|
||||||
`${BASE_MOVIE}/top_rated?${params}`
|
`${BASE_MOVIE}/top_rated`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async upcoming(
|
async upcoming(
|
||||||
options?: PageOption & LanguageOption & RegionOption
|
options?: PageOption & LanguageOption & RegionOption
|
||||||
): Promise<UpcomingMovies> {
|
): Promise<UpcomingMovies> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<UpcomingMovies>(
|
return await this.api.get<UpcomingMovies>(
|
||||||
`${BASE_MOVIE}/upcoming?${params}`
|
`${BASE_MOVIE}/upcoming`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ 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';
|
||||||
@@ -27,9 +26,9 @@ export class PeopleEndpoint extends BaseEndpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async changes(id: number, options?: ChangeOptions): Promise<PersonChanges> {
|
async changes(id: number, options?: ChangeOptions): Promise<PersonChanges> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<PersonChanges>(
|
return await this.api.get<PersonChanges>(
|
||||||
`${BASE_PERSON}/${id}/changes?${params}`
|
`${BASE_PERSON}/${id}/changes`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,9 +61,9 @@ export class PeopleEndpoint extends BaseEndpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async taggedImages(id: number, options?: PageOption): Promise<TaggedImages> {
|
async taggedImages(id: number, options?: PageOption): Promise<TaggedImages> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<TaggedImages>(
|
return await this.api.get<TaggedImages>(
|
||||||
`${BASE_PERSON}/${id}/tagged_images?${params}`
|
`${BASE_PERSON}/${id}/tagged_images`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,9 +78,9 @@ export class PeopleEndpoint extends BaseEndpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async popular(options?: PageOption): Promise<PopularPersons> {
|
async popular(options?: PageOption): Promise<PopularPersons> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<PopularPersons>(
|
return await this.api.get<PopularPersons>(
|
||||||
`${BASE_PERSON}/popular?${params}`
|
`${BASE_PERSON}/popular`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
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';
|
||||||
|
|
||||||
@@ -31,44 +30,39 @@ export class SearchEndpoint extends BaseEndpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async companies(options: SearchOptions): Promise<Search<Company>> {
|
async companies(options: SearchOptions): Promise<Search<Company>> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<Search<Company>>(
|
return await this.api.get<Search<Company>>(
|
||||||
`${BASE_SEARCH}/company?${params}`
|
`${BASE_SEARCH}/company`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async collections(options: SearchOptions): Promise<Search<Collection>> {
|
async collections(options: SearchOptions): Promise<Search<Collection>> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<Search<Collection>>(
|
return await this.api.get<Search<Collection>>(
|
||||||
`${BASE_SEARCH}/collection?${params}`
|
`${BASE_SEARCH}/collection`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async keywords(
|
async keywords(
|
||||||
options: SearchOptions
|
options: SearchOptions
|
||||||
): Promise<Search<{ id: string; name: string }>> {
|
): Promise<Search<{ id: string; name: string }>> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<Search<{ id: string; name: string }>>(
|
return await this.api.get<Search<{ id: string; name: string }>>(
|
||||||
`${BASE_SEARCH}/keyword?${params}`
|
`${BASE_SEARCH}/keyword`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async movies(options: MovieSearchOptions): Promise<Search<Movie>> {
|
async movies(options: MovieSearchOptions): Promise<Search<Movie>> {
|
||||||
const params = parseOptions(options);
|
return await this.api.get<Search<Movie>>(`${BASE_SEARCH}/movie`, 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>> {
|
||||||
const params = parseOptions(options);
|
return await this.api.get<Search<Person>>(`${BASE_SEARCH}/person`, 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>> {
|
||||||
const params = parseOptions(options);
|
return await this.api.get<Search<TV>>(`${BASE_SEARCH}/tv`, options);
|
||||||
return await this.api.get<Search<TV>>(`${BASE_SEARCH}/tv?${params}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import {
|
|||||||
Videos,
|
Videos,
|
||||||
WatchProviders,
|
WatchProviders,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { parseOptions } from '../utils';
|
|
||||||
|
|
||||||
const BASE_TV = '/tv';
|
const BASE_TV = '/tv';
|
||||||
|
|
||||||
@@ -47,9 +46,9 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async changes(id: number, options?: ChangeOptions): Promise<TvShowChanges> {
|
async changes(id: number, options?: ChangeOptions): Promise<TvShowChanges> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<TvShowChanges>(
|
return await this.api.get<TvShowChanges>(
|
||||||
`${BASE_TV}/${id}/changes?${params}`
|
`${BASE_TV}/${id}/changes`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,15 +88,14 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
|||||||
id: number,
|
id: number,
|
||||||
options?: PageOption
|
options?: PageOption
|
||||||
): Promise<Recommendations> {
|
): Promise<Recommendations> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<Recommendations>(
|
return await this.api.get<Recommendations>(
|
||||||
`${BASE_TV}/${id}/recommendations?${params}`
|
`${BASE_TV}/${id}/recommendations`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async reviews(id: number, options?: PageOption): Promise<Reviews> {
|
async reviews(id: number, options?: PageOption): Promise<Reviews> {
|
||||||
const params = parseOptions(options);
|
return await this.api.get<Reviews>(`${BASE_TV}/${id}/reviews`, options);
|
||||||
return await this.api.get<Reviews>(`${BASE_TV}/${id}/reviews?${params}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async screenedTheatrically(id: number): Promise<ScreenedTheatrically> {
|
async screenedTheatrically(id: number): Promise<ScreenedTheatrically> {
|
||||||
@@ -107,9 +105,9 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async similar(id: number, options?: PageOption): Promise<SimilarTvShows> {
|
async similar(id: number, options?: PageOption): Promise<SimilarTvShows> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<SimilarTvShows>(
|
return await this.api.get<SimilarTvShows>(
|
||||||
`${BASE_TV}/${id}/similar?${params}`
|
`${BASE_TV}/${id}/similar`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,25 +140,21 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
|||||||
async airingToday(
|
async airingToday(
|
||||||
options?: PageOption & LanguageOption & RegionOption
|
options?: PageOption & LanguageOption & RegionOption
|
||||||
): Promise<TvShowsAiringToday> {
|
): Promise<TvShowsAiringToday> {
|
||||||
const params = parseOptions(options);
|
|
||||||
return await this.api.get<TvShowsAiringToday>(
|
return await this.api.get<TvShowsAiringToday>(
|
||||||
`${BASE_TV}/airing_today?${params}`
|
`${BASE_TV}/airing_today`,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async popular(
|
async popular(
|
||||||
options?: PageOption & LanguageOption & RegionOption
|
options?: PageOption & LanguageOption & RegionOption
|
||||||
): Promise<PopularTvShows> {
|
): Promise<PopularTvShows> {
|
||||||
const params = parseOptions(options);
|
return await this.api.get<PopularTvShows>(`${BASE_TV}/popular`, options);
|
||||||
return await this.api.get<PopularTvShows>(`${BASE_TV}/popular?${params}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async topRated(
|
async topRated(
|
||||||
options?: PageOption & LanguageOption & RegionOption
|
options?: PageOption & LanguageOption & RegionOption
|
||||||
): Promise<TopRatedTvShows> {
|
): Promise<TopRatedTvShows> {
|
||||||
const params = parseOptions(options);
|
return await this.api.get<TopRatedTvShows>(`${BASE_TV}/top_rated`, options);
|
||||||
return await this.api.get<TopRatedTvShows>(
|
|
||||||
`${BASE_TV}/top_rated?${params}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
src/types/account.ts
Normal file
17
src/types/account.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
@@ -134,14 +134,14 @@ export interface ContentRatingsResult {
|
|||||||
|
|
||||||
export interface Recommendation {
|
export interface Recommendation {
|
||||||
adult: boolean;
|
adult: boolean;
|
||||||
backdrop_path?: any;
|
backdrop_path?: string;
|
||||||
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?: any;
|
poster_path?: string;
|
||||||
popularity: number;
|
popularity: number;
|
||||||
title: string;
|
title: string;
|
||||||
video: boolean;
|
video: boolean;
|
||||||
|
|||||||
@@ -6,10 +6,17 @@ import {
|
|||||||
SpokenLanguage,
|
SpokenLanguage,
|
||||||
} from './';
|
} 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?: any;
|
belongs_to_collection?: BelongsToCollection;
|
||||||
budget: number;
|
budget: number;
|
||||||
genres: Genre[];
|
genres: Genre[];
|
||||||
homepage: string;
|
homepage: string;
|
||||||
@@ -19,7 +26,7 @@ export interface MovieDetails {
|
|||||||
original_title: string;
|
original_title: string;
|
||||||
overview: string;
|
overview: string;
|
||||||
popularity: number;
|
popularity: number;
|
||||||
poster_path?: any;
|
poster_path?: string;
|
||||||
production_companies: ProductionCompany[];
|
production_companies: ProductionCompany[];
|
||||||
production_countries: ProductionCountry[];
|
production_countries: ProductionCountry[];
|
||||||
release_date: string;
|
release_date: string;
|
||||||
@@ -107,8 +114,8 @@ export interface MovieChanges {
|
|||||||
|
|
||||||
export interface LatestMovie {
|
export interface LatestMovie {
|
||||||
adult: boolean;
|
adult: boolean;
|
||||||
backdrop_path?: any;
|
backdrop_path?: string;
|
||||||
belongs_to_collection?: any;
|
belongs_to_collection?: BelongsToCollection;
|
||||||
budget: number;
|
budget: number;
|
||||||
genres: Genre[];
|
genres: Genre[];
|
||||||
homepage: string;
|
homepage: string;
|
||||||
@@ -119,12 +126,12 @@ export interface LatestMovie {
|
|||||||
overview: string;
|
overview: string;
|
||||||
popularity: number;
|
popularity: number;
|
||||||
poster_path: string;
|
poster_path: string;
|
||||||
production_companies: any[];
|
production_companies: ProductionCompany[];
|
||||||
production_countries: any[];
|
production_countries: ProductionCountry[];
|
||||||
release_date: string;
|
release_date: string;
|
||||||
revenue: number;
|
revenue: number;
|
||||||
runtime: number;
|
runtime: number;
|
||||||
spoken_languages: any[];
|
spoken_languages: SpokenLanguage[];
|
||||||
status: string;
|
status: string;
|
||||||
tagline: string;
|
tagline: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
|||||||
@@ -14,6 +14,21 @@ 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;
|
||||||
@@ -57,7 +72,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?: any;
|
next_episode_to_air?: NextEpisodeToAir;
|
||||||
networks: Network[];
|
networks: Network[];
|
||||||
number_of_episodes: number;
|
number_of_episodes: number;
|
||||||
number_of_seasons: number;
|
number_of_seasons: number;
|
||||||
@@ -123,9 +138,9 @@ export interface TvShowItem {
|
|||||||
id: string;
|
id: string;
|
||||||
action: string;
|
action: string;
|
||||||
time: string;
|
time: string;
|
||||||
value: any;
|
value: Array<number>;
|
||||||
iso_639_1: string;
|
iso_639_1: string;
|
||||||
original_value: any;
|
original_value: Array<number>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TvShowChange {
|
export interface TvShowChange {
|
||||||
@@ -194,8 +209,8 @@ export interface SimilarTvShows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface LatestTvShows {
|
export interface LatestTvShows {
|
||||||
backdrop_path?: any;
|
backdrop_path?: string;
|
||||||
created_by: any[];
|
created_by: CreatedBy[];
|
||||||
episode_run_time: number[];
|
episode_run_time: number[];
|
||||||
first_air_date: string;
|
first_air_date: string;
|
||||||
genres: Genre[];
|
genres: Genre[];
|
||||||
@@ -211,10 +226,10 @@ export interface LatestTvShows {
|
|||||||
origin_country: string[];
|
origin_country: string[];
|
||||||
original_language: string;
|
original_language: string;
|
||||||
original_name: string;
|
original_name: string;
|
||||||
overview?: any;
|
overview?: string;
|
||||||
popularity: number;
|
popularity: number;
|
||||||
poster_path?: any;
|
poster_path?: string;
|
||||||
production_companies: any[];
|
production_companies: ProductionCompany[];
|
||||||
seasons: Season[];
|
seasons: Season[];
|
||||||
status: string;
|
status: string;
|
||||||
type: string;
|
type: string;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
export function parseOptions(options?: { [s: string]: any }): string {
|
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)).toString() : '';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user