Merge pull request #41 from benlei/master
Adding company data, network data, tv show aggregate credits
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "tmdb-ts",
|
"name": "tmdb-ts",
|
||||||
"version": "1.0.0",
|
"version": "1.5.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "tmdb-ts",
|
"name": "tmdb-ts",
|
||||||
"version": "1.0.0",
|
"version": "1.5.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cross-fetch": "^3.1.4"
|
"cross-fetch": "^3.1.4"
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "tmdb-ts",
|
"name": "tmdb-ts",
|
||||||
"version": "1.4.0",
|
"version": "1.5.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",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"compile": "rm -rf dist && tsc -d && npm run copy-types",
|
"compile": "rm -rf dist && tsc -d",
|
||||||
"lint": "eslint --ext .ts src/",
|
"lint": "eslint --ext .ts src/",
|
||||||
"lint:fix": "eslint --ext .ts src/ --fix",
|
"lint:fix": "eslint --ext .ts src/ --fix",
|
||||||
"format": "npx prettier --write src",
|
"format": "npx prettier --write src",
|
||||||
"pre-commit": "npm run lint",
|
"pre-commit": "npm run lint"
|
||||||
"copy-types": "mkdir dist/types && cp src/types/*.d.ts dist/types"
|
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/blakejoy/tmdb-ts/issues",
|
"url": "https://github.com/blakejoy/tmdb-ts/issues",
|
||||||
|
|||||||
26
src/endpoints/companies.ts
Normal file
26
src/endpoints/companies.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import {
|
||||||
|
CompanyDetails,
|
||||||
|
AlternativeNames,
|
||||||
|
CompanyImages,
|
||||||
|
} from './../types/companies';
|
||||||
|
import { BaseEndpoint } from './base';
|
||||||
|
|
||||||
|
export class CompaniesEndpoint extends BaseEndpoint {
|
||||||
|
constructor(protected readonly accessToken: string) {
|
||||||
|
super(accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
async details(id: number): Promise<CompanyDetails> {
|
||||||
|
return await this.api.get<CompanyDetails>(`/company/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async alternativeNames(id: number): Promise<AlternativeNames> {
|
||||||
|
return await this.api.get<AlternativeNames>(
|
||||||
|
`/company/${id}/alternative_names`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async images(id: number): Promise<CompanyImages> {
|
||||||
|
return await this.api.get<CompanyImages>(`/company/${id}/images`);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,4 +16,3 @@ export * from './keywords';
|
|||||||
export * from './collections';
|
export * from './collections';
|
||||||
export * from './tv-seasons';
|
export * from './tv-seasons';
|
||||||
export * from './tv-episode';
|
export * from './tv-episode';
|
||||||
|
|
||||||
|
|||||||
@@ -58,8 +58,14 @@ export class MoviesEndpoint extends BaseEndpoint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async changes(id: number, options?: ChangeOption): Promise<Changes<MovieChangeValue>> {
|
async changes(
|
||||||
return await this.api.get<Changes<MovieChangeValue>>(`${BASE_MOVIE}/${id}/changes`, options);
|
id: number,
|
||||||
|
options?: ChangeOption
|
||||||
|
): Promise<Changes<MovieChangeValue>> {
|
||||||
|
return await this.api.get<Changes<MovieChangeValue>>(
|
||||||
|
`${BASE_MOVIE}/${id}/changes`,
|
||||||
|
options
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async credits(id: number): Promise<Credits> {
|
async credits(id: number): Promise<Credits> {
|
||||||
|
|||||||
23
src/endpoints/networks.ts
Normal file
23
src/endpoints/networks.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { NetworkDetails, NetworkImages } from '..';
|
||||||
|
import { AlternativeNames } from './../types/companies';
|
||||||
|
import { BaseEndpoint } from './base';
|
||||||
|
|
||||||
|
export class NetworksEndpoint extends BaseEndpoint {
|
||||||
|
constructor(protected readonly accessToken: string) {
|
||||||
|
super(accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
async details(id: number): Promise<NetworkDetails> {
|
||||||
|
return await this.api.get<NetworkDetails>(`/network/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async alternativeNames(id: number): Promise<AlternativeNames> {
|
||||||
|
return await this.api.get<AlternativeNames>(
|
||||||
|
`/network/${id}/alternative_names`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async images(id: number): Promise<NetworkImages> {
|
||||||
|
return await this.api.get<NetworkImages>(`/network/${id}/images`);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
Videos,
|
Videos,
|
||||||
AppendToResponseTvSeasonKey,
|
AppendToResponseTvSeasonKey,
|
||||||
AppendToResponse,
|
AppendToResponse,
|
||||||
|
AggregateCredits,
|
||||||
} from '..';
|
} from '..';
|
||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ export class TvSeasonsEndpoint extends BaseEndpoint {
|
|||||||
seasonSelection: SeasonSelection,
|
seasonSelection: SeasonSelection,
|
||||||
options?: LanguageOption
|
options?: LanguageOption
|
||||||
) {
|
) {
|
||||||
return await this.api.get<Credits>(
|
return await this.api.get<AggregateCredits>(
|
||||||
`${BASE_SEASON(seasonSelection)}/aggregate_credits`,
|
`${BASE_SEASON(seasonSelection)}/aggregate_credits`,
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { BaseEndpoint } from './base';
|
import { BaseEndpoint } from './base';
|
||||||
import {
|
import {
|
||||||
|
AggregateCredits,
|
||||||
AlternativeTitles,
|
AlternativeTitles,
|
||||||
AppendToResponse,
|
AppendToResponse,
|
||||||
AppendToResponseTvKey,
|
AppendToResponseTvKey,
|
||||||
@@ -59,8 +60,14 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async changes(id: number, options?: ChangeOption): Promise<Changes<TvShowChangeValue>> {
|
async changes(
|
||||||
return await this.api.get<Changes<TvShowChangeValue>>(`${BASE_TV}/${id}/changes`, options);
|
id: number,
|
||||||
|
options?: ChangeOption
|
||||||
|
): Promise<Changes<TvShowChangeValue>> {
|
||||||
|
return await this.api.get<Changes<TvShowChangeValue>>(
|
||||||
|
`${BASE_TV}/${id}/changes`,
|
||||||
|
options
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async contentRatings(id: number): Promise<ContentRatings> {
|
async contentRatings(id: number): Promise<ContentRatings> {
|
||||||
@@ -69,6 +76,12 @@ export class TvShowsEndpoint extends BaseEndpoint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async aggregateCredits(id: number): Promise<AggregateCredits> {
|
||||||
|
return await this.api.get<AggregateCredits>(
|
||||||
|
`${BASE_TV}/${id}/aggregate_credits`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
async credits(id: number): Promise<Credits> {
|
async credits(id: number): Promise<Credits> {
|
||||||
return await this.api.get<Credits>(`${BASE_TV}/${id}/credits`);
|
return await this.api.get<Credits>(`${BASE_TV}/${id}/credits`);
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/tmdb.ts
12
src/tmdb.ts
@@ -18,6 +18,8 @@ import {
|
|||||||
TvSeasonsEndpoint,
|
TvSeasonsEndpoint,
|
||||||
TvEpisodesEndpoint,
|
TvEpisodesEndpoint,
|
||||||
} from './endpoints';
|
} from './endpoints';
|
||||||
|
import { CompaniesEndpoint } from './endpoints/companies';
|
||||||
|
import { NetworksEndpoint } from './endpoints/networks';
|
||||||
|
|
||||||
export class TMDB {
|
export class TMDB {
|
||||||
private readonly accessToken: string;
|
private readonly accessToken: string;
|
||||||
@@ -46,6 +48,14 @@ export class TMDB {
|
|||||||
return new CreditsEndpoint(this.accessToken);
|
return new CreditsEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get companies(): CompaniesEndpoint {
|
||||||
|
return new CompaniesEndpoint(this.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
get networks(): NetworksEndpoint {
|
||||||
|
return new NetworksEndpoint(this.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
get search(): SearchEndpoint {
|
get search(): SearchEndpoint {
|
||||||
return new SearchEndpoint(this.accessToken);
|
return new SearchEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
@@ -94,7 +104,7 @@ export class TMDB {
|
|||||||
return new CollectionsEndpoint(this.accessToken);
|
return new CollectionsEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
get tvSeasons() : TvSeasonsEndpoint {
|
get tvSeasons(): TvSeasonsEndpoint {
|
||||||
return new TvSeasonsEndpoint(this.accessToken);
|
return new TvSeasonsEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
33
src/types/companies.ts
Normal file
33
src/types/companies.ts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import { Image } from '.';
|
||||||
|
|
||||||
|
export interface CompanyDetails {
|
||||||
|
description: string;
|
||||||
|
headquarters: string;
|
||||||
|
homepage: string;
|
||||||
|
id: number;
|
||||||
|
logo_path: string;
|
||||||
|
name: string;
|
||||||
|
origin_country: string;
|
||||||
|
parent_company: ParentCompany;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ParentCompany {
|
||||||
|
name: string;
|
||||||
|
id: number;
|
||||||
|
logo_path: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AlternativeNames {
|
||||||
|
id: number;
|
||||||
|
results: Name[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Name {
|
||||||
|
name: string;
|
||||||
|
type: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CompanyImages {
|
||||||
|
id: number;
|
||||||
|
logos: Image[];
|
||||||
|
}
|
||||||
@@ -101,3 +101,49 @@ export interface Videos {
|
|||||||
id: number;
|
id: number;
|
||||||
results: Video[];
|
results: Video[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface AggregateCredits {
|
||||||
|
id: number;
|
||||||
|
cast: AggregateCast[];
|
||||||
|
crew: AggregateCrew[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CastRole {
|
||||||
|
credit_id: string;
|
||||||
|
character: string;
|
||||||
|
episode_count: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AggregateCast {
|
||||||
|
adult: boolean;
|
||||||
|
gender: number;
|
||||||
|
id: number;
|
||||||
|
known_for_department: string;
|
||||||
|
name: string;
|
||||||
|
original_name: string;
|
||||||
|
popularity: number;
|
||||||
|
profile_path: string;
|
||||||
|
roles: CastRole[];
|
||||||
|
total_episode_count: number;
|
||||||
|
order: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CrewJob {
|
||||||
|
credit_id: string;
|
||||||
|
job: string;
|
||||||
|
episode_count: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AggregateCrew {
|
||||||
|
adult: boolean;
|
||||||
|
gender: number;
|
||||||
|
id: number;
|
||||||
|
known_for_department: string;
|
||||||
|
name: string;
|
||||||
|
original_name: string;
|
||||||
|
popularity: number;
|
||||||
|
profile_path: string;
|
||||||
|
jobs: CrewJob[];
|
||||||
|
department: string;
|
||||||
|
total_episode_count: number;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
export * from './options';
|
export * from './options';
|
||||||
export * from './certification';
|
export * from './certification';
|
||||||
export * from './credits';
|
export * from './credits';
|
||||||
|
export * from './companies';
|
||||||
|
export * from './networks';
|
||||||
export * from './configuration';
|
export * from './configuration';
|
||||||
export * from './changes';
|
export * from './changes';
|
||||||
export * from './movies';
|
export * from './movies';
|
||||||
|
|||||||
15
src/types/networks.ts
Normal file
15
src/types/networks.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { Image } from '.';
|
||||||
|
|
||||||
|
export interface NetworkDetails {
|
||||||
|
headquarters: string;
|
||||||
|
homepage: string;
|
||||||
|
id: number;
|
||||||
|
logo_path: string;
|
||||||
|
name: string;
|
||||||
|
origin_country: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NetworkImages {
|
||||||
|
id: number;
|
||||||
|
logos: Image[];
|
||||||
|
}
|
||||||
@@ -165,8 +165,8 @@ export type AppendToResponse<
|
|||||||
: Media extends 'tvShow'
|
: Media extends 'tvShow'
|
||||||
? TvShowChangeValue
|
? TvShowChangeValue
|
||||||
: Media extends 'tvSeason'
|
: Media extends 'tvSeason'
|
||||||
? TvSeasonChangeValue :
|
? TvSeasonChangeValue
|
||||||
TvEpisodeChangeValue
|
: TvEpisodeChangeValue
|
||||||
>;
|
>;
|
||||||
}
|
}
|
||||||
: object) &
|
: object) &
|
||||||
|
|||||||
Reference in New Issue
Block a user