@tdanks2000/tmdb-wrapper 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +334 -148
- package/dist/@types/models/baseEndpoint.d.ts.map +1 -1
- package/dist/endpoints/account.d.ts.map +1 -1
- package/dist/endpoints/certification.d.ts.map +1 -1
- package/dist/endpoints/changes.d.ts.map +1 -1
- package/dist/endpoints/collections.d.ts.map +1 -1
- package/dist/endpoints/collections.js +1 -1
- package/dist/endpoints/companies.d.ts.map +1 -1
- package/dist/endpoints/configuration.d.ts.map +1 -1
- package/dist/endpoints/credits.d.ts.map +1 -1
- package/dist/endpoints/discover.d.ts.map +1 -1
- package/dist/endpoints/find.d.ts.map +1 -1
- package/dist/endpoints/genre.d.ts.map +1 -1
- package/dist/endpoints/index.d.ts +3 -0
- package/dist/endpoints/index.d.ts.map +1 -1
- package/dist/endpoints/index.js +3 -0
- package/dist/endpoints/keywords.d.ts.map +1 -1
- package/dist/endpoints/movies.d.ts.map +1 -1
- package/dist/endpoints/movies.js +1 -1
- package/dist/endpoints/networks.d.ts.map +1 -1
- package/dist/endpoints/people.d.ts.map +1 -1
- package/dist/endpoints/review.d.ts.map +1 -1
- package/dist/endpoints/search.d.ts.map +1 -1
- package/dist/endpoints/trending.d.ts.map +1 -1
- package/dist/endpoints/tvEpisodes.d.ts.map +1 -1
- package/dist/endpoints/tvEpisodes.js +2 -2
- package/dist/endpoints/tvSeasons.d.ts.map +1 -1
- package/dist/endpoints/tvSeasons.js +2 -2
- package/dist/endpoints/tvShows.d.ts.map +1 -1
- package/dist/endpoints/tvShows.js +2 -2
- package/dist/endpoints/watchProviders.d.ts +33 -0
- package/dist/endpoints/watchProviders.d.ts.map +1 -0
- package/dist/endpoints/watchProviders.js +63 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/utils/api.d.ts.map +1 -1
- package/dist/utils/getimagePath.d.ts +24 -4
- package/dist/utils/getimagePath.d.ts.map +1 -1
- package/dist/utils/getimagePath.js +39 -8
- package/package.json +28 -10
- package/src/@types/endpoints/account.ts +0 -17
- package/src/@types/endpoints/certification.ts +0 -19
- package/src/@types/endpoints/changes.ts +0 -29
- package/src/@types/endpoints/collection.ts +0 -23
- package/src/@types/endpoints/companies.ts +0 -33
- package/src/@types/endpoints/configuration.ts +0 -112
- package/src/@types/endpoints/credits.ts +0 -149
- package/src/@types/endpoints/discover.ts +0 -87
- package/src/@types/endpoints/find.ts +0 -28
- package/src/@types/endpoints/genre.ts +0 -3
- package/src/@types/endpoints/index.ts +0 -22
- package/src/@types/endpoints/keywords.ts +0 -24
- package/src/@types/endpoints/movies.ts +0 -169
- package/src/@types/endpoints/networks.ts +0 -15
- package/src/@types/endpoints/options.ts +0 -189
- package/src/@types/endpoints/people.ts +0 -151
- package/src/@types/endpoints/review.ts +0 -8
- package/src/@types/endpoints/search.ts +0 -39
- package/src/@types/endpoints/trending.ts +0 -20
- package/src/@types/endpoints/tvEpisode.ts +0 -72
- package/src/@types/endpoints/tvSeasons.ts +0 -37
- package/src/@types/endpoints/tvShows.ts +0 -284
- package/src/@types/endpoints/watchProviders.ts +0 -298
- package/src/@types/index.ts +0 -3
- package/src/@types/models/baseEndpoint.ts +0 -9
- package/src/@types/models/index.ts +0 -1
- package/src/@types/types.ts +0 -199
- package/src/endpoints/account.ts +0 -22
- package/src/endpoints/certification.ts +0 -30
- package/src/endpoints/changes.ts +0 -41
- package/src/endpoints/collections.ts +0 -57
- package/src/endpoints/companies.ts +0 -41
- package/src/endpoints/configuration.ts +0 -22
- package/src/endpoints/credits.ts +0 -23
- package/src/endpoints/discover.ts +0 -40
- package/src/endpoints/find.ts +0 -24
- package/src/endpoints/genre.ts +0 -32
- package/src/endpoints/index.ts +0 -18
- package/src/endpoints/keywords.ts +0 -35
- package/src/endpoints/movies.ts +0 -244
- package/src/endpoints/networks.ts +0 -41
- package/src/endpoints/people.ts +0 -147
- package/src/endpoints/review.ts +0 -23
- package/src/endpoints/search.ts +0 -93
- package/src/endpoints/trending.ts +0 -30
- package/src/endpoints/tvEpisodes.ts +0 -125
- package/src/endpoints/tvSeasons.ts +0 -138
- package/src/endpoints/tvShows.ts +0 -286
- package/src/index.ts +0 -66
- package/src/utils/api.ts +0 -31
- package/src/utils/getimagePath.ts +0 -16
- package/src/utils/index.ts +0 -2
- package/tsconfig.json +0 -108
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AppendToResponse,
|
|
3
|
-
AppendToResponseTvEpisodeKey,
|
|
4
|
-
BaseEndpoint,
|
|
5
|
-
ChangeOption,
|
|
6
|
-
Changes,
|
|
7
|
-
Episode,
|
|
8
|
-
EpisodeSelection,
|
|
9
|
-
ExternalIds,
|
|
10
|
-
Images,
|
|
11
|
-
LanguageOption,
|
|
12
|
-
TvEpisodeChangeValue,
|
|
13
|
-
TvEpisodeCredit,
|
|
14
|
-
TvEpisodeImageSearchOptions,
|
|
15
|
-
TvEpisodeTranslations,
|
|
16
|
-
TvEpisodeVideoSearchOptions,
|
|
17
|
-
Videos,
|
|
18
|
-
} from '@/@types';
|
|
19
|
-
|
|
20
|
-
const BASE_EPISODE = (episodeSelection: EpisodeSelection): string => {
|
|
21
|
-
return `/tv/${episodeSelection.tvShowID}/season/${episodeSelection.seasonNumber}/episode/${episodeSelection.episodeNumber}`;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Represents an endpoint for accessing TV episode-related information.
|
|
26
|
-
*/
|
|
27
|
-
export class TvEpisodesEndpoint extends BaseEndpoint {
|
|
28
|
-
/**
|
|
29
|
-
* Constructs a new TvEpisodesEndpoint instance.
|
|
30
|
-
* @param {string} access_token - The access token used for authentication.
|
|
31
|
-
*/
|
|
32
|
-
constructor(access_token: string) {
|
|
33
|
-
super(access_token);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Retrieves details of a specific TV episode asynchronously.
|
|
38
|
-
* @param {EpisodeSelection} episodeSelection - The selection criteria for the TV episode.
|
|
39
|
-
* @param {AppendToResponseTvEpisodeKey[]} [appendToResponse] - Additional data to append to the response.
|
|
40
|
-
* @param {LanguageOption} [options] - Optional parameters for specifying the language.
|
|
41
|
-
* @returns {Promise<AppendToResponse<Omit<Episode, 'show_id'>, AppendToResponseTvEpisodeKey[], 'tvEpisode'>>}
|
|
42
|
-
* A Promise that resolves with the details of the TV episode.
|
|
43
|
-
*/
|
|
44
|
-
async details<T extends AppendToResponseTvEpisodeKey[] | undefined>(
|
|
45
|
-
episodeSelection: EpisodeSelection,
|
|
46
|
-
appendToResponse?: T,
|
|
47
|
-
options?: LanguageOption,
|
|
48
|
-
) {
|
|
49
|
-
const combinedOptions = {
|
|
50
|
-
append_to_response: appendToResponse ? appendToResponse.join(',') : undefined,
|
|
51
|
-
...options,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
return await this.api.get<AppendToResponse<Omit<Episode, 'show_id'>, T, 'tvEpisode'>>(
|
|
55
|
-
`${BASE_EPISODE(episodeSelection)}`,
|
|
56
|
-
combinedOptions,
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Retrieves changes related to a specific TV episode asynchronously.
|
|
62
|
-
* @param {number} episodeID - The ID of the TV episode.
|
|
63
|
-
* @param {ChangeOption} [options] - Optional parameters for specifying changes.
|
|
64
|
-
* @returns {Promise<Changes<TvEpisodeChangeValue>>} A Promise that resolves with the changes related to the TV episode.
|
|
65
|
-
*/
|
|
66
|
-
async changes(episodeID: number, options?: ChangeOption) {
|
|
67
|
-
return await this.api.get<Changes<TvEpisodeChangeValue>>(`/tv/episode/${episodeID}/changes`, options);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Retrieves credits for a specific TV episode asynchronously.
|
|
72
|
-
* @param {EpisodeSelection} episodeSelection - The selection criteria for the TV episode.
|
|
73
|
-
* @param {LanguageOption} [options] - Optional parameters for specifying the language.
|
|
74
|
-
* @returns {Promise<TvEpisodeCredit>} A Promise that resolves with the credits for the TV episode.
|
|
75
|
-
*/
|
|
76
|
-
async credits(episodeSelection: EpisodeSelection, options?: LanguageOption) {
|
|
77
|
-
return await this.api.get<TvEpisodeCredit>(`${BASE_EPISODE(episodeSelection)}/credits`, options);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Retrieves external IDs for a specific TV episode asynchronously.
|
|
82
|
-
* @param {EpisodeSelection} episodeSelection - The selection criteria for the TV episode.
|
|
83
|
-
* @returns {Promise<ExternalIds>} A Promise that resolves with the external IDs for the TV episode.
|
|
84
|
-
*/
|
|
85
|
-
async externalIds(episodeSelection: EpisodeSelection) {
|
|
86
|
-
return await this.api.get<ExternalIds>(`${BASE_EPISODE(episodeSelection)}/external_ids`);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Retrieves images for a specific TV episode asynchronously.
|
|
91
|
-
* @param {EpisodeSelection} episodeSelection - The selection criteria for the TV episode.
|
|
92
|
-
* @param {TvEpisodeImageSearchOptions} [options] - Optional parameters for specifying image search options.
|
|
93
|
-
* @returns {Promise<Images>} A Promise that resolves with the images for the TV episode.
|
|
94
|
-
*/
|
|
95
|
-
async images(episodeSelection: EpisodeSelection, options?: TvEpisodeImageSearchOptions) {
|
|
96
|
-
const computedOptions = {
|
|
97
|
-
include_image_language: options?.include_image_language?.join(','),
|
|
98
|
-
language: options?.language,
|
|
99
|
-
};
|
|
100
|
-
return await this.api.get<Images>(`${BASE_EPISODE(episodeSelection)}/images`, computedOptions);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Retrieves translations for a specific TV episode asynchronously.
|
|
105
|
-
* @param {EpisodeSelection} episodeSelection - The selection criteria for the TV episode.
|
|
106
|
-
* @returns {Promise<TvEpisodeTranslations>} A Promise that resolves with the translations for the TV episode.
|
|
107
|
-
*/
|
|
108
|
-
async translations(episodeSelection: EpisodeSelection) {
|
|
109
|
-
return await this.api.get<TvEpisodeTranslations>(`${BASE_EPISODE(episodeSelection)}/translations`);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Retrieves videos for a specific TV episode asynchronously.
|
|
114
|
-
* @param {EpisodeSelection} episodeSelection - The selection criteria for the TV episode.
|
|
115
|
-
* @param {TvEpisodeVideoSearchOptions} [options] - Optional parameters for specifying video search options.
|
|
116
|
-
* @returns {Promise<Videos>} A Promise that resolves with the videos for the TV episode.
|
|
117
|
-
*/
|
|
118
|
-
async videos(episodeSelection: EpisodeSelection, options?: TvEpisodeVideoSearchOptions) {
|
|
119
|
-
const computedOptions = {
|
|
120
|
-
include_video_language: options?.include_video_language?.join(','),
|
|
121
|
-
language: options?.language,
|
|
122
|
-
};
|
|
123
|
-
return await this.api.get<Videos>(`${BASE_EPISODE(episodeSelection)}/videos`, computedOptions);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AggregateCredits,
|
|
3
|
-
AppendToResponse,
|
|
4
|
-
AppendToResponseTvSeasonKey,
|
|
5
|
-
BaseEndpoint,
|
|
6
|
-
ChangeOption,
|
|
7
|
-
Changes,
|
|
8
|
-
Credits,
|
|
9
|
-
ExternalIds,
|
|
10
|
-
Images,
|
|
11
|
-
LanguageOption,
|
|
12
|
-
SeasonDetails,
|
|
13
|
-
SeasonSelection,
|
|
14
|
-
Translations,
|
|
15
|
-
TvSeasonChangeValue,
|
|
16
|
-
TvSeasonImageSearchOptions,
|
|
17
|
-
TvSeasonVideoSearchOptions,
|
|
18
|
-
Videos,
|
|
19
|
-
} from '@/@types';
|
|
20
|
-
|
|
21
|
-
const BASE_SEASON = (seasonSelection: SeasonSelection): string => {
|
|
22
|
-
return `/tv/${seasonSelection.tvShowID}/season/${seasonSelection.seasonNumber}`;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Represents an endpoint for accessing TV season-related information.
|
|
27
|
-
*/
|
|
28
|
-
export class TvSeasonsEndpoint extends BaseEndpoint {
|
|
29
|
-
/**
|
|
30
|
-
* Constructs a new TvSeasonsEndpoint instance.
|
|
31
|
-
* @param {string} access_token - The access token used for authentication.
|
|
32
|
-
*/
|
|
33
|
-
constructor(access_token: string) {
|
|
34
|
-
super(access_token);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Retrieves details of a specific TV season asynchronously.
|
|
39
|
-
* @param {SeasonSelection} seasonSelection - The selection criteria for the TV season.
|
|
40
|
-
* @param {AppendToResponseTvSeasonKey[]} [appendToResponse] - Additional data to append to the response.
|
|
41
|
-
* @param {LanguageOption} [options] - Optional parameters for specifying the language.
|
|
42
|
-
* @returns {Promise<AppendToResponse<SeasonDetails, AppendToResponseTvSeasonKey[], 'tvSeason'>>}
|
|
43
|
-
* A Promise that resolves with the details of the TV season.
|
|
44
|
-
*/
|
|
45
|
-
async details<T extends AppendToResponseTvSeasonKey[] | undefined>(
|
|
46
|
-
seasonSelection: SeasonSelection,
|
|
47
|
-
appendToResponse?: T,
|
|
48
|
-
options?: LanguageOption,
|
|
49
|
-
) {
|
|
50
|
-
const combinedOptions = {
|
|
51
|
-
append_to_response: appendToResponse ? appendToResponse.join(',') : undefined,
|
|
52
|
-
...options,
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
return await this.api.get<AppendToResponse<SeasonDetails, T, 'tvSeason'>>(
|
|
56
|
-
`${BASE_SEASON(seasonSelection)}`,
|
|
57
|
-
combinedOptions,
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Retrieves aggregate credits for a specific TV season asynchronously.
|
|
63
|
-
* @param {SeasonSelection} seasonSelection - The selection criteria for the TV season.
|
|
64
|
-
* @param {LanguageOption} [options] - Optional parameters for specifying the language.
|
|
65
|
-
* @returns {Promise<AggregateCredits>} A Promise that resolves with the aggregate credits for the TV season.
|
|
66
|
-
*/
|
|
67
|
-
async aggregateCredits(seasonSelection: SeasonSelection, options?: LanguageOption) {
|
|
68
|
-
return await this.api.get<AggregateCredits>(`${BASE_SEASON(seasonSelection)}/aggregate_credits`, options);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Retrieves changes related to a specific TV season asynchronously.
|
|
73
|
-
* @param {number} seasonId - The ID of the TV season.
|
|
74
|
-
* @param {ChangeOption} [options] - Optional parameters for specifying changes.
|
|
75
|
-
* @returns {Promise<Changes<TvSeasonChangeValue>>} A Promise that resolves with the changes related to the TV season.
|
|
76
|
-
*/
|
|
77
|
-
async changes(seasonId: number, options?: ChangeOption) {
|
|
78
|
-
return await this.api.get<Changes<TvSeasonChangeValue>>(`/tv/season/${seasonId}/changes`, options);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Retrieves credits for a specific TV season asynchronously.
|
|
83
|
-
* @param {SeasonSelection} seasonSelection - The selection criteria for the TV season.
|
|
84
|
-
* @param {LanguageOption} [options] - Optional parameters for specifying the language.
|
|
85
|
-
* @returns {Promise<Credits>} A Promise that resolves with the credits for the TV season.
|
|
86
|
-
*/
|
|
87
|
-
async credits(seasonSelection: SeasonSelection, options?: LanguageOption) {
|
|
88
|
-
return await this.api.get<Credits>(`${BASE_SEASON(seasonSelection)}/credits`, options);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Retrieves external IDs for a specific TV season asynchronously.
|
|
93
|
-
* @param {SeasonSelection} seasonSelection - The selection criteria for the TV season.
|
|
94
|
-
* @param {LanguageOption} [options] - Optional parameters for specifying the language.
|
|
95
|
-
* @returns {Promise<ExternalIds>} A Promise that resolves with the external IDs for the TV season.
|
|
96
|
-
*/
|
|
97
|
-
async externalIds(seasonSelection: SeasonSelection, options?: LanguageOption) {
|
|
98
|
-
return await this.api.get<ExternalIds>(`${BASE_SEASON(seasonSelection)}/external_ids`, options);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Retrieves images for a specific TV season asynchronously.
|
|
103
|
-
* @param {SeasonSelection} seasonSelection - The selection criteria for the TV season.
|
|
104
|
-
* @param {TvSeasonImageSearchOptions} [options] - Optional parameters for specifying image search options.
|
|
105
|
-
* @returns {Promise<Images>} A Promise that resolves with the images for the TV season.
|
|
106
|
-
*/
|
|
107
|
-
async images(seasonSelection: SeasonSelection, options?: TvSeasonImageSearchOptions) {
|
|
108
|
-
const computedOptions = {
|
|
109
|
-
include_image_language: options?.include_image_language?.join(','),
|
|
110
|
-
language: options?.language,
|
|
111
|
-
};
|
|
112
|
-
return await this.api.get<Images>(`${BASE_SEASON(seasonSelection)}/images`, computedOptions);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Retrieves videos for a specific TV season asynchronously.
|
|
117
|
-
* @param {SeasonSelection} seasonSelection - The selection criteria for the TV season.
|
|
118
|
-
* @param {TvSeasonVideoSearchOptions} [options] - Optional parameters for specifying video search options.
|
|
119
|
-
* @returns {Promise<Videos>} A Promise that resolves with the videos for the TV season.
|
|
120
|
-
*/
|
|
121
|
-
async videos(seasonSelection: SeasonSelection, options?: TvSeasonVideoSearchOptions) {
|
|
122
|
-
const computedOptions = {
|
|
123
|
-
include_video_language: options?.include_video_language?.join(','),
|
|
124
|
-
language: options?.language,
|
|
125
|
-
};
|
|
126
|
-
return await this.api.get<Videos>(`${BASE_SEASON(seasonSelection)}/videos`, computedOptions);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Retrieves translations for a specific TV season asynchronously.
|
|
131
|
-
* @param {SeasonSelection} seasonSelection - The selection criteria for the TV season.
|
|
132
|
-
* @param {LanguageOption} [options] - Optional parameters for specifying the language.
|
|
133
|
-
* @returns {Promise<Translations>} A Promise that resolves with the translations for the TV season.
|
|
134
|
-
*/
|
|
135
|
-
async translations(seasonSelection: SeasonSelection, options?: LanguageOption) {
|
|
136
|
-
return await this.api.get<Translations>(`${BASE_SEASON(seasonSelection)}/translations`, options);
|
|
137
|
-
}
|
|
138
|
-
}
|
package/src/endpoints/tvShows.ts
DELETED
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AggregateCredits,
|
|
3
|
-
AlternativeTitles,
|
|
4
|
-
AppendToResponse,
|
|
5
|
-
AppendToResponseTvKey,
|
|
6
|
-
BaseEndpoint,
|
|
7
|
-
ChangeOption,
|
|
8
|
-
Changes,
|
|
9
|
-
ContentRatings,
|
|
10
|
-
Credits,
|
|
11
|
-
EpisodeGroups,
|
|
12
|
-
ExternalIds,
|
|
13
|
-
Images,
|
|
14
|
-
Keywords,
|
|
15
|
-
LanguageOption,
|
|
16
|
-
Latesttv,
|
|
17
|
-
OnTheAir,
|
|
18
|
-
PageOption,
|
|
19
|
-
Populartv,
|
|
20
|
-
Recommendations,
|
|
21
|
-
Reviews,
|
|
22
|
-
ScreenedTheatrically,
|
|
23
|
-
SeasonDetails,
|
|
24
|
-
Similartv,
|
|
25
|
-
TimezoneOption,
|
|
26
|
-
TopRatedtv,
|
|
27
|
-
Translations,
|
|
28
|
-
TvShowChangeValue,
|
|
29
|
-
TvShowDetails,
|
|
30
|
-
TvShowImageOptions,
|
|
31
|
-
TvShowVideoOptions,
|
|
32
|
-
Videos,
|
|
33
|
-
WatchProviders,
|
|
34
|
-
tvAiringToday,
|
|
35
|
-
} from '@/@types';
|
|
36
|
-
|
|
37
|
-
const BASE_TV = '/tv';
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Represents an endpoint for accessing TV show-related information.
|
|
41
|
-
*/
|
|
42
|
-
export class TvShowsEndpoint extends BaseEndpoint {
|
|
43
|
-
/**
|
|
44
|
-
* Constructs a new TvShowsEndpoint instance.
|
|
45
|
-
* @param {string} access_token - The access token used for authentication.
|
|
46
|
-
*/
|
|
47
|
-
constructor(protected readonly access_token: string) {
|
|
48
|
-
super(access_token);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Retrieves details of a specific TV show asynchronously.
|
|
53
|
-
* @param {number} id - The ID of the TV show.
|
|
54
|
-
* @param {AppendToResponseTvKey[]} [appendToResponse] - Additional data to append to the response.
|
|
55
|
-
* @param {string} [language] - The language for the response.
|
|
56
|
-
* @returns {Promise<AppendToResponse<TvShowDetails, AppendToResponseTvKey[], 'tvShow'>>}
|
|
57
|
-
* A Promise that resolves with the details of the TV show.
|
|
58
|
-
*/
|
|
59
|
-
async details<T extends AppendToResponseTvKey[] | undefined>(
|
|
60
|
-
id: number,
|
|
61
|
-
appendToResponse?: T,
|
|
62
|
-
language?: string,
|
|
63
|
-
): Promise<AppendToResponse<TvShowDetails, T, 'tvShow'>> {
|
|
64
|
-
const options = {
|
|
65
|
-
append_to_response: appendToResponse ? appendToResponse.join(',') : undefined,
|
|
66
|
-
language: language,
|
|
67
|
-
};
|
|
68
|
-
return await this.api.get<AppendToResponse<TvShowDetails, T, 'tvShow'>>(`${BASE_TV}/${id}`, options);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Retrieves alternative titles of a specific TV show asynchronously.
|
|
73
|
-
* @param {number} id - The ID of the TV show.
|
|
74
|
-
* @returns {Promise<AlternativeTitles>} A Promise that resolves with the alternative titles of the TV show.
|
|
75
|
-
*/
|
|
76
|
-
async alternativeTitles(id: number): Promise<AlternativeTitles> {
|
|
77
|
-
return await this.api.get<AlternativeTitles>(`${BASE_TV}/${id}/alternative_titles`);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Retrieves changes for a specific TV show asynchronously.
|
|
82
|
-
* @param {number} id - The ID of the TV show.
|
|
83
|
-
* @param {ChangeOption} [options] - Additional options for the request.
|
|
84
|
-
* @returns {Promise<Changes<TvShowChangeValue>>}
|
|
85
|
-
* A Promise that resolves with the changes for the TV show.
|
|
86
|
-
*/
|
|
87
|
-
async changes(id: number, options?: ChangeOption): Promise<Changes<TvShowChangeValue>> {
|
|
88
|
-
return await this.api.get<Changes<TvShowChangeValue>>(`${BASE_TV}/${id}/changes`, options);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Retrieves content ratings for a specific TV show asynchronously.
|
|
93
|
-
* @param {number} id - The ID of the TV show.
|
|
94
|
-
* @returns {Promise<ContentRatings>} A Promise that resolves with the content ratings of the TV show.
|
|
95
|
-
*/
|
|
96
|
-
async contentRatings(id: number): Promise<ContentRatings> {
|
|
97
|
-
return await this.api.get<ContentRatings>(`${BASE_TV}/${id}/content_ratings`);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Retrieves aggregate credits for a specific TV show asynchronously.
|
|
102
|
-
* @param {number} id - The ID of the TV show.
|
|
103
|
-
* @param {LanguageOption} [options] - Additional options for the request.
|
|
104
|
-
* @returns {Promise<AggregateCredits>} A Promise that resolves with the aggregate credits of the TV show.
|
|
105
|
-
*/
|
|
106
|
-
async aggregateCredits(id: number, options?: LanguageOption): Promise<AggregateCredits> {
|
|
107
|
-
return await this.api.get<AggregateCredits>(`${BASE_TV}/${id}/aggregate_credits`, options);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Retrieves credits for a specific TV show asynchronously.
|
|
112
|
-
* @param {number} id - The ID of the TV show.
|
|
113
|
-
* @param {LanguageOption} [options] - Additional options for the request.
|
|
114
|
-
* @returns {Promise<Credits>} A Promise that resolves with the credits of the TV show.
|
|
115
|
-
*/
|
|
116
|
-
async credits(id: number, options?: LanguageOption): Promise<Credits> {
|
|
117
|
-
return await this.api.get<Credits>(`${BASE_TV}/${id}/credits`, options);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Retrieves details of a specific season of a TV show asynchronously.
|
|
122
|
-
* @param {number} tvId - The ID of the TV show.
|
|
123
|
-
* @param {number} seasonNumber - The season number.
|
|
124
|
-
* @returns {Promise<SeasonDetails>} A Promise that resolves with the details of the season.
|
|
125
|
-
*/
|
|
126
|
-
async season(tvId: number, seasonNumber: number): Promise<SeasonDetails> {
|
|
127
|
-
return await this.api.get<SeasonDetails>(`${BASE_TV}/${tvId}/season/${seasonNumber}`);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Retrieves episode groups for a specific TV show asynchronously.
|
|
132
|
-
* @param {number} id - The ID of the TV show.
|
|
133
|
-
* @returns {Promise<EpisodeGroups>} A Promise that resolves with the episode groups of the TV show.
|
|
134
|
-
*/
|
|
135
|
-
async episodeGroups(id: number): Promise<EpisodeGroups> {
|
|
136
|
-
return await this.api.get<EpisodeGroups>(`${BASE_TV}/${id}/episode_groups`);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Retrieves external IDs for a specific TV show asynchronously.
|
|
141
|
-
* @param {number} id - The ID of the TV show.
|
|
142
|
-
* @returns {Promise<ExternalIds>} A Promise that resolves with the external IDs of the TV show.
|
|
143
|
-
*/
|
|
144
|
-
async externalIds(id: number): Promise<ExternalIds> {
|
|
145
|
-
return await this.api.get<ExternalIds>(`${BASE_TV}/${id}/external_ids`);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Retrieves images for a specific TV show asynchronously.
|
|
150
|
-
* @param {number} id - The ID of the TV show.
|
|
151
|
-
* @param {TvShowImageOptions} [options] - Additional options for the request.
|
|
152
|
-
* @returns {Promise<Images>} A Promise that resolves with the images of the TV show.
|
|
153
|
-
*/
|
|
154
|
-
async images(id: number, options?: TvShowImageOptions): Promise<Images> {
|
|
155
|
-
const computedOptions = {
|
|
156
|
-
include_image_language: options?.include_image_language?.join(','),
|
|
157
|
-
language: options?.language,
|
|
158
|
-
};
|
|
159
|
-
return await this.api.get<Images>(`${BASE_TV}/${id}/images`, computedOptions);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Retrieves keywords for a specific TV show asynchronously.
|
|
164
|
-
* @param {number} id - The ID of the TV show.
|
|
165
|
-
* @returns {Promise<Keywords>} A Promise that resolves with the keywords of the TV show.
|
|
166
|
-
*/
|
|
167
|
-
async keywords(id: number): Promise<Keywords> {
|
|
168
|
-
return await this.api.get<Keywords>(`${BASE_TV}/${id}/keywords`);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Retrieves recommendations for a specific TV show asynchronously.
|
|
173
|
-
* @param {number} id - The ID of the TV show.
|
|
174
|
-
* @param {LanguageOption & PageOption} [options] - Additional options for the request.
|
|
175
|
-
* @returns {Promise<Recommendations>} A Promise that resolves with the recommendations for the TV show.
|
|
176
|
-
*/
|
|
177
|
-
async recommendations(id: number, options?: LanguageOption & PageOption): Promise<Recommendations> {
|
|
178
|
-
return await this.api.get<Recommendations>(`${BASE_TV}/${id}/recommendations`, options);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Retrieves reviews for a specific TV show asynchronously.
|
|
183
|
-
* @param {number} id - The ID of the TV show.
|
|
184
|
-
* @param {LanguageOption & PageOption} [options] - Additional options for the request.
|
|
185
|
-
* @returns {Promise<Reviews>} A Promise that resolves with the reviews of the TV show.
|
|
186
|
-
*/
|
|
187
|
-
async reviews(id: number, options?: LanguageOption & PageOption): Promise<Reviews> {
|
|
188
|
-
return await this.api.get<Reviews>(`${BASE_TV}/${id}/reviews`, options);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Retrieves information about whether the TV show was screened theatrically asynchronously.
|
|
193
|
-
* @param {number} id - The ID of the TV show.
|
|
194
|
-
* @returns {Promise<ScreenedTheatrically>} A Promise that resolves with information about theatrical screenings.
|
|
195
|
-
*/
|
|
196
|
-
async screenedTheatrically(id: number): Promise<ScreenedTheatrically> {
|
|
197
|
-
return await this.api.get<ScreenedTheatrically>(`${BASE_TV}/${id}/screened_theatrically`);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Retrieves similar TV shows for a specific TV show asynchronously.
|
|
202
|
-
* @param {number} id - The ID of the TV show.
|
|
203
|
-
* @param {LanguageOption & PageOption} [options] - Additional options for the request.
|
|
204
|
-
* @returns {Promise<Similartv>} A Promise that resolves with the similar TV shows.
|
|
205
|
-
*/
|
|
206
|
-
async similar(id: number, options?: LanguageOption & PageOption): Promise<Similartv> {
|
|
207
|
-
return await this.api.get<Similartv>(`${BASE_TV}/${id}/similar`, options);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Retrieves translations for a specific TV show asynchronously.
|
|
212
|
-
* @param {number} id - The ID of the TV show.
|
|
213
|
-
* @returns {Promise<Translations>} A Promise that resolves with the translations of the TV show.
|
|
214
|
-
*/
|
|
215
|
-
async translations(id: number): Promise<Translations> {
|
|
216
|
-
return await this.api.get<Translations>(`${BASE_TV}/${id}/translations`);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Retrieves videos for a specific TV show asynchronously.
|
|
221
|
-
* @param {number} id - The ID of the TV show.
|
|
222
|
-
* @param {TvShowVideoOptions} [options] - Additional options for the request.
|
|
223
|
-
* @returns {Promise<Videos>} A Promise that resolves with the videos of the TV show.
|
|
224
|
-
*/
|
|
225
|
-
async videos(id: number, options?: TvShowVideoOptions): Promise<Videos> {
|
|
226
|
-
const computedOptions = {
|
|
227
|
-
include_video_language: options?.include_video_language?.join(','),
|
|
228
|
-
language: options?.language,
|
|
229
|
-
};
|
|
230
|
-
return await this.api.get<Videos>(`${BASE_TV}/${id}/videos`, computedOptions);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Retrieves watch providers for a specific TV show asynchronously.
|
|
235
|
-
* Powered by JustWatch.
|
|
236
|
-
* @param {number} id - The ID of the TV show.
|
|
237
|
-
* @returns {Promise<WatchProviders>} A Promise that resolves with the watch providers of the TV show.
|
|
238
|
-
*/
|
|
239
|
-
async watchProviders(id: number): Promise<WatchProviders> {
|
|
240
|
-
return await this.api.get<WatchProviders>(`${BASE_TV}/${id}/watch/providers`);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Retrieves the latest TV show asynchronously.
|
|
245
|
-
* @returns {Promise<Latesttv>} A Promise that resolves with the latest TV show.
|
|
246
|
-
*/
|
|
247
|
-
async latest(): Promise<Latesttv> {
|
|
248
|
-
return await this.api.get<Latesttv>(`${BASE_TV}/latest`);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Retrieves TV shows that are currently on the air asynchronously.
|
|
253
|
-
* @param {PageOption & LanguageOption & TimezoneOption} [options] - Additional options for the request.
|
|
254
|
-
* @returns {Promise<OnTheAir>} A Promise that resolves with TV shows currently on the air.
|
|
255
|
-
*/
|
|
256
|
-
async onTheAir(options?: PageOption & LanguageOption & TimezoneOption): Promise<OnTheAir> {
|
|
257
|
-
return await this.api.get<OnTheAir>(`${BASE_TV}/on_the_air`, options);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Retrieves TV shows that are airing today asynchronously.
|
|
262
|
-
* @param {PageOption & LanguageOption & TimezoneOption} [options] - Additional options for the request.
|
|
263
|
-
* @returns {Promise<tvAiringToday>} A Promise that resolves with TV shows airing today.
|
|
264
|
-
*/
|
|
265
|
-
async airingToday(options?: PageOption & LanguageOption & TimezoneOption): Promise<tvAiringToday> {
|
|
266
|
-
return await this.api.get<tvAiringToday>(`${BASE_TV}/airing_today`, options);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* Retrieves popular TV shows asynchronously.
|
|
271
|
-
* @param {PageOption & LanguageOption} [options] - Additional options for the request.
|
|
272
|
-
* @returns {Promise<Populartv>} A Promise that resolves with popular TV shows.
|
|
273
|
-
*/
|
|
274
|
-
async popular(options?: PageOption & LanguageOption): Promise<Populartv> {
|
|
275
|
-
return await this.api.get<Populartv>(`${BASE_TV}/popular`, options);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Retrieves top-rated TV shows asynchronously.
|
|
280
|
-
* @param {PageOption & LanguageOption} [options] - Additional options for the request.
|
|
281
|
-
* @returns {Promise<TopRatedtv>} A Promise that resolves with top-rated TV shows.
|
|
282
|
-
*/
|
|
283
|
-
async topRated(options?: PageOption & LanguageOption): Promise<TopRatedtv> {
|
|
284
|
-
return await this.api.get<TopRatedtv>(`${BASE_TV}/top_rated`, options);
|
|
285
|
-
}
|
|
286
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AccountEndpoint,
|
|
3
|
-
CertificationEndpoint,
|
|
4
|
-
ChangeEndpoint,
|
|
5
|
-
CollectionsEndpoint,
|
|
6
|
-
ConfigurationEndpoint,
|
|
7
|
-
CreditsEndpoint,
|
|
8
|
-
DiscoverEndpoint,
|
|
9
|
-
FindEndpoint,
|
|
10
|
-
GenreEndpoint,
|
|
11
|
-
KeywordsEndpoint,
|
|
12
|
-
MoviesEndpoint,
|
|
13
|
-
PeopleEndpoint,
|
|
14
|
-
ReviewEndpoint,
|
|
15
|
-
SearchEndpoint,
|
|
16
|
-
TrendingEndpoint,
|
|
17
|
-
TvEpisodesEndpoint,
|
|
18
|
-
TvSeasonsEndpoint,
|
|
19
|
-
TvShowsEndpoint,
|
|
20
|
-
} from '@/endpoints';
|
|
21
|
-
|
|
22
|
-
class TMDB {
|
|
23
|
-
constructor(access_token: string) {
|
|
24
|
-
this.account = new AccountEndpoint(access_token);
|
|
25
|
-
this.certification = new CertificationEndpoint(access_token);
|
|
26
|
-
this.changes = new ChangeEndpoint(access_token);
|
|
27
|
-
this.collections = new CollectionsEndpoint(access_token);
|
|
28
|
-
this.configuration = new ConfigurationEndpoint(access_token);
|
|
29
|
-
this.credits = new CreditsEndpoint(access_token);
|
|
30
|
-
this.discover = new DiscoverEndpoint(access_token);
|
|
31
|
-
this.find = new FindEndpoint(access_token);
|
|
32
|
-
this.genre = new GenreEndpoint(access_token);
|
|
33
|
-
this.keywords = new KeywordsEndpoint(access_token);
|
|
34
|
-
this.movies = new MoviesEndpoint(access_token);
|
|
35
|
-
this.people = new PeopleEndpoint(access_token);
|
|
36
|
-
this.review = new ReviewEndpoint(access_token);
|
|
37
|
-
this.search = new SearchEndpoint(access_token);
|
|
38
|
-
this.trending = new TrendingEndpoint(access_token);
|
|
39
|
-
this.tvEpisodes = new TvEpisodesEndpoint(access_token);
|
|
40
|
-
this.tvSeasons = new TvSeasonsEndpoint(access_token);
|
|
41
|
-
this.tvShows = new TvShowsEndpoint(access_token);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
account: AccountEndpoint;
|
|
45
|
-
certification: CertificationEndpoint;
|
|
46
|
-
changes: ChangeEndpoint;
|
|
47
|
-
collections: CollectionsEndpoint;
|
|
48
|
-
configuration: ConfigurationEndpoint;
|
|
49
|
-
credits: CreditsEndpoint;
|
|
50
|
-
discover: DiscoverEndpoint;
|
|
51
|
-
find: FindEndpoint;
|
|
52
|
-
genre: GenreEndpoint;
|
|
53
|
-
keywords: KeywordsEndpoint;
|
|
54
|
-
movies: MoviesEndpoint;
|
|
55
|
-
people: PeopleEndpoint;
|
|
56
|
-
review: ReviewEndpoint;
|
|
57
|
-
search: SearchEndpoint;
|
|
58
|
-
trending: TrendingEndpoint;
|
|
59
|
-
tvEpisodes: TvEpisodesEndpoint;
|
|
60
|
-
tvSeasons: TvSeasonsEndpoint;
|
|
61
|
-
tvShows: TvShowsEndpoint;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export * from './@types';
|
|
65
|
-
export * from './utils';
|
|
66
|
-
export { TMDB };
|
package/src/utils/api.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ErrorResponse } from '@/@types';
|
|
2
|
-
|
|
3
|
-
const BASE_URL_V3 = 'https://api.themoviedb.org/3';
|
|
4
|
-
|
|
5
|
-
export class API {
|
|
6
|
-
private access_token: string;
|
|
7
|
-
constructor(access_token: string) {
|
|
8
|
-
this.access_token = access_token;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
async get<T>(path: string, options?: Record<string, any>): Promise<T> {
|
|
12
|
-
const params = parseOptions(options);
|
|
13
|
-
const response = await fetch(`${BASE_URL_V3}${path}?${params}`, {
|
|
14
|
-
method: 'GET',
|
|
15
|
-
headers: {
|
|
16
|
-
Authorization: `Bearer ${this.access_token}`,
|
|
17
|
-
'Content-Type': 'application/json;charset=utf-8',
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
if (!response.ok) {
|
|
22
|
-
return Promise.reject((await response.json()) as ErrorResponse);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return (await response.json()) as T;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const parseOptions = (options?: Record<string, any>): string => {
|
|
30
|
-
return options ? new URLSearchParams(Object.entries(options)).toString() : '';
|
|
31
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility method to construct full url for image
|
|
3
|
-
* based on configuration
|
|
4
|
-
*
|
|
5
|
-
* https://developers.themoviedb.org/3/getting-started/images
|
|
6
|
-
* @param {string} baseUrl base image url
|
|
7
|
-
* @param {string} fileSize file size
|
|
8
|
-
* @param {string} imagePath raw image path
|
|
9
|
-
* @param {boolean} svg get svg version if true
|
|
10
|
-
*/
|
|
11
|
-
export const getFullImagePath = (baseUrl: string, fileSize: string, imagePath: string, svg = false): string => {
|
|
12
|
-
const imagePathArr = imagePath.split('.');
|
|
13
|
-
const imageFormat = svg ? 'svg' : imagePathArr[1];
|
|
14
|
-
|
|
15
|
-
return `${baseUrl}${fileSize}${imagePathArr[0]}.${imageFormat}`;
|
|
16
|
-
};
|
package/src/utils/index.ts
DELETED