base tv-episode integration
This commit is contained in:
@@ -14,3 +14,5 @@ export * from './trending';
|
|||||||
export * from './find';
|
export * from './find';
|
||||||
export * from './keywords';
|
export * from './keywords';
|
||||||
export * from './collections';
|
export * from './collections';
|
||||||
|
export * from './tv-episode';
|
||||||
|
|
||||||
|
|||||||
83
src/endpoints/tv-episode.ts
Normal file
83
src/endpoints/tv-episode.ts
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
import {
|
||||||
|
Episode,
|
||||||
|
EpisodeSelection,
|
||||||
|
LanguageOption,
|
||||||
|
PageOption,
|
||||||
|
ChangeOption,
|
||||||
|
TvEpisodeChanges,
|
||||||
|
TvEpisodeCredit,
|
||||||
|
ExternalIds,
|
||||||
|
Images,
|
||||||
|
TvEpisodeTranslations,
|
||||||
|
Videos,
|
||||||
|
AppendToResponseMovieKey,
|
||||||
|
AppendToResponse,
|
||||||
|
} from '..';
|
||||||
|
import { BaseEndpoint } from './base';
|
||||||
|
|
||||||
|
const BASE_EPISODE = (episodeSelection: EpisodeSelection): string => {
|
||||||
|
return `/tv/${episodeSelection.tvShowID}/season/${episodeSelection.seasonNumber}/episode/${episodeSelection.episodeNumber}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
export class TvEpisodesEndpoint extends BaseEndpoint {
|
||||||
|
constructor(accessToken: string) {
|
||||||
|
super(accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
async details<T extends AppendToResponseMovieKey[] | undefined>(
|
||||||
|
episodeSelection: EpisodeSelection,
|
||||||
|
appendToResponse?: T,
|
||||||
|
options?: LanguageOption
|
||||||
|
) {
|
||||||
|
const combinedOptions = {
|
||||||
|
append_to_response: appendToResponse
|
||||||
|
? appendToResponse.join(',')
|
||||||
|
: undefined,
|
||||||
|
...options,
|
||||||
|
};
|
||||||
|
|
||||||
|
return await this.api.get<
|
||||||
|
AppendToResponse<Omit<Episode, 'show_id'>, T, 'movie'>
|
||||||
|
>(`${BASE_EPISODE(episodeSelection)}`, combinedOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
async changes(episodeID: number, options?: PageOption & ChangeOption) {
|
||||||
|
return await this.api.get<TvEpisodeChanges>(
|
||||||
|
`/tv/episode/${episodeID}/changes`,
|
||||||
|
options
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async credits(episodeSelection: EpisodeSelection, options?: LanguageOption) {
|
||||||
|
return await this.api.get<TvEpisodeCredit>(
|
||||||
|
`${BASE_EPISODE(episodeSelection)}/credits`,
|
||||||
|
options
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async externalIds(episodeSelection: EpisodeSelection) {
|
||||||
|
return await this.api.get<ExternalIds>(
|
||||||
|
`${BASE_EPISODE(episodeSelection)}/external_ids`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async images(episodeSelection: EpisodeSelection) {
|
||||||
|
return await this.api.get<Images>(
|
||||||
|
`${BASE_EPISODE(episodeSelection)}/images`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async translations(episodeSelection: EpisodeSelection) {
|
||||||
|
return await this.api.get<TvEpisodeTranslations>(
|
||||||
|
`${BASE_EPISODE(episodeSelection)}/translations`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async videos(episodeSelection: EpisodeSelection, options?: LanguageOption) {
|
||||||
|
return await this.api.get<Videos>(
|
||||||
|
`${BASE_EPISODE(episodeSelection)}/videos`,
|
||||||
|
options
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
FindEndpoint,
|
FindEndpoint,
|
||||||
KeywordsEndpoint,
|
KeywordsEndpoint,
|
||||||
CollectionsEndpoint,
|
CollectionsEndpoint,
|
||||||
|
TvEpisodesEndpoint,
|
||||||
} from './endpoints';
|
} from './endpoints';
|
||||||
|
|
||||||
export class TMDB {
|
export class TMDB {
|
||||||
@@ -60,6 +61,10 @@ export class TMDB {
|
|||||||
return new TvShowsEndpoint(this.accessToken);
|
return new TvShowsEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get tvEpisode(): TvEpisodesEndpoint {
|
||||||
|
return new TvEpisodesEndpoint(this.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
get discover(): DiscoverEndpoint {
|
get discover(): DiscoverEndpoint {
|
||||||
return new DiscoverEndpoint(this.accessToken);
|
return new DiscoverEndpoint(this.accessToken);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export * from './trending';
|
|||||||
export * from './find';
|
export * from './find';
|
||||||
export * from './keywords';
|
export * from './keywords';
|
||||||
export * from './collections';
|
export * from './collections';
|
||||||
|
export * from './tv-episode';
|
||||||
|
|
||||||
export type MediaType = 'movie' | 'tv' | 'person';
|
export type MediaType = 'movie' | 'tv' | 'person';
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ export interface PageOption {
|
|||||||
page?: number;
|
page?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ChangeOption extends PageOption {
|
||||||
|
start_date?: Date;
|
||||||
|
end_date?: Date;
|
||||||
|
}
|
||||||
|
|
||||||
export type AppendToResponseMovieKey =
|
export type AppendToResponseMovieKey =
|
||||||
| 'images'
|
| 'images'
|
||||||
| 'videos'
|
| 'videos'
|
||||||
|
|||||||
74
src/types/tv-episode.ts
Normal file
74
src/types/tv-episode.ts
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
import { Credits, Crew } from '.';
|
||||||
|
|
||||||
|
export interface EpisodeSelection {
|
||||||
|
tvShowID: number;
|
||||||
|
seasonNumber: number;
|
||||||
|
episodeNumber: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Episode {
|
||||||
|
air_date: string;
|
||||||
|
episode_number: number;
|
||||||
|
crew: Crew[];
|
||||||
|
guest_stars: GuestStar[];
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
overview: string;
|
||||||
|
production_code: string;
|
||||||
|
season_number: number;
|
||||||
|
still_path: string;
|
||||||
|
vote_average: number;
|
||||||
|
vote_count: number;
|
||||||
|
runtime: number;
|
||||||
|
show_id: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GuestStar {
|
||||||
|
credit_id: string;
|
||||||
|
order: number;
|
||||||
|
character: string;
|
||||||
|
adult: boolean;
|
||||||
|
gender: number | null;
|
||||||
|
id: number;
|
||||||
|
known_for_department: string;
|
||||||
|
name: string;
|
||||||
|
original_name: string;
|
||||||
|
popularity: number;
|
||||||
|
profile_path: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TvEpisodeChangeItem {
|
||||||
|
id: string;
|
||||||
|
action: string;
|
||||||
|
time: string;
|
||||||
|
iso_639_1: string;
|
||||||
|
iso_3166_1: string;
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TvEpisodeChange {
|
||||||
|
key: string;
|
||||||
|
items: TvEpisodeChangeItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TvEpisodeChanges {
|
||||||
|
changes: TvEpisodeChange[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TvEpisodeCredit extends Credits {
|
||||||
|
guest_stars: GuestStar[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TvEpisodeTranslations {
|
||||||
|
id: number;
|
||||||
|
translations: {
|
||||||
|
iso_3166_1: string;
|
||||||
|
iso_639_1: string;
|
||||||
|
name: string;
|
||||||
|
english_name: string;
|
||||||
|
data: {
|
||||||
|
name: string;
|
||||||
|
overview: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
ProductionCompany,
|
ProductionCompany,
|
||||||
ProductionCountry,
|
ProductionCountry,
|
||||||
SpokenLanguage,
|
SpokenLanguage,
|
||||||
Crew,
|
Episode,
|
||||||
} from './';
|
} from './';
|
||||||
|
|
||||||
export interface CreatedBy {
|
export interface CreatedBy {
|
||||||
@@ -93,37 +93,6 @@ export interface TvShowDetails {
|
|||||||
vote_count: number;
|
vote_count: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GuestStar {
|
|
||||||
credit_id: string;
|
|
||||||
order: number;
|
|
||||||
character: string;
|
|
||||||
adult: boolean;
|
|
||||||
gender: number | null;
|
|
||||||
id: number;
|
|
||||||
known_for_department: string;
|
|
||||||
name: string;
|
|
||||||
original_name: string;
|
|
||||||
popularity: number;
|
|
||||||
profile_path: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Episode {
|
|
||||||
air_date: string;
|
|
||||||
episode_number: number;
|
|
||||||
crew: Crew[];
|
|
||||||
guest_stars: GuestStar[];
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
overview: string;
|
|
||||||
production_code: string;
|
|
||||||
season_number: number;
|
|
||||||
still_path: string;
|
|
||||||
vote_average: number;
|
|
||||||
vote_count: number;
|
|
||||||
show_id: number;
|
|
||||||
runtime: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SeasonDetails {
|
export interface SeasonDetails {
|
||||||
air_date: string;
|
air_date: string;
|
||||||
episodes: Episode[];
|
episodes: Episode[];
|
||||||
|
|||||||
Reference in New Issue
Block a user