@justwicked/tmdb-client 1.0.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 +40 -0
- package/dist/client/__generated__/api/tmdbApi.d.ts +9117 -0
- package/dist/client/__generated__/api/tmdbApi.js +3248 -0
- package/dist/client/services/account/account-service.d.ts +17 -0
- package/dist/client/services/account/account-service.js +40 -0
- package/dist/client/services/authentication/authentication-service.d.ts +13 -0
- package/dist/client/services/authentication/authentication-service.js +28 -0
- package/dist/client/services/certification/certification-service.d.ts +7 -0
- package/dist/client/services/certification/certification-service.js +13 -0
- package/dist/client/services/collection/collection-service.d.ts +9 -0
- package/dist/client/services/collection/collection-service.js +16 -0
- package/dist/client/services/company/company-service.d.ts +8 -0
- package/dist/client/services/company/company-service.js +16 -0
- package/dist/client/services/configuration/configuration-service.d.ts +12 -0
- package/dist/client/services/configuration/configuration-service.js +25 -0
- package/dist/client/services/credit/credit-service.d.ts +6 -0
- package/dist/client/services/credit/credit-service.js +10 -0
- package/dist/client/services/dicover/discover-service.d.ts +8 -0
- package/dist/client/services/dicover/discover-service.js +13 -0
- package/dist/client/services/find/find-service.d.ts +7 -0
- package/dist/client/services/find/find-service.js +10 -0
- package/dist/client/services/genre/genre-service.d.ts +8 -0
- package/dist/client/services/genre/genre-service.js +13 -0
- package/dist/client/services/guest-session/guest-session-service.d.ts +9 -0
- package/dist/client/services/guest-session/guest-session-service.js +16 -0
- package/dist/client/services/keyword/keyword-service.d.ts +8 -0
- package/dist/client/services/keyword/keyword-service.js +13 -0
- package/dist/client/services/list/list-service.d.ts +13 -0
- package/dist/client/services/list/list-service.js +28 -0
- package/dist/client/services/movie/movie-service.d.ts +30 -0
- package/dist/client/services/movie/movie-service.js +79 -0
- package/dist/client/services/network/network-service.d.ts +8 -0
- package/dist/client/services/network/network-service.js +16 -0
- package/dist/client/services/person/person-service.d.ts +18 -0
- package/dist/client/services/person/person-service.js +43 -0
- package/dist/client/services/review/review-service.d.ts +6 -0
- package/dist/client/services/review/review-service.js +10 -0
- package/dist/client/services/search/search-service.d.ts +13 -0
- package/dist/client/services/search/search-service.js +28 -0
- package/dist/client/services/trending/trending-service.d.ts +10 -0
- package/dist/client/services/trending/trending-service.js +19 -0
- package/dist/client/services/tv/episode-service.d.ts +18 -0
- package/dist/client/services/tv/episode-service.js +43 -0
- package/dist/client/services/tv/season-service.d.ts +16 -0
- package/dist/client/services/tv/season-service.js +37 -0
- package/dist/client/services/tv/tv-service.d.ts +36 -0
- package/dist/client/services/tv/tv-service.js +91 -0
- package/dist/client/services/watch/watch-service.d.ts +9 -0
- package/dist/client/services/watch/watch-service.js +16 -0
- package/dist/client/tmdb-client.d.ts +47 -0
- package/dist/client/tmdb-client.js +69 -0
- package/dist/client/types.d.ts +16 -0
- package/dist/client/types.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1,3248 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
2
|
+
export const AccountGetFavoritesSortBy = {
|
|
3
|
+
created_atasc: 'created_at.asc',
|
|
4
|
+
created_atdesc: 'created_at.desc',
|
|
5
|
+
};
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
7
|
+
export const AccountFavoriteTvSortBy = {
|
|
8
|
+
created_atasc: 'created_at.asc',
|
|
9
|
+
created_atdesc: 'created_at.desc',
|
|
10
|
+
};
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
12
|
+
export const AccountRatedMoviesSortBy = {
|
|
13
|
+
created_atasc: 'created_at.asc',
|
|
14
|
+
created_atdesc: 'created_at.desc',
|
|
15
|
+
};
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
17
|
+
export const AccountRatedTvSortBy = {
|
|
18
|
+
created_atasc: 'created_at.asc',
|
|
19
|
+
created_atdesc: 'created_at.desc',
|
|
20
|
+
};
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
22
|
+
export const AccountRatedTvEpisodesSortBy = {
|
|
23
|
+
created_atasc: 'created_at.asc',
|
|
24
|
+
created_atdesc: 'created_at.desc',
|
|
25
|
+
};
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
27
|
+
export const AccountWatchlistMoviesSortBy = {
|
|
28
|
+
created_atasc: 'created_at.asc',
|
|
29
|
+
created_atdesc: 'created_at.desc',
|
|
30
|
+
};
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
32
|
+
export const AccountWatchlistTvSortBy = {
|
|
33
|
+
created_atasc: 'created_at.asc',
|
|
34
|
+
created_atdesc: 'created_at.desc',
|
|
35
|
+
};
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
37
|
+
export const DiscoverMovieSortBy = {
|
|
38
|
+
original_titleasc: 'original_title.asc',
|
|
39
|
+
original_titledesc: 'original_title.desc',
|
|
40
|
+
popularityasc: 'popularity.asc',
|
|
41
|
+
popularitydesc: 'popularity.desc',
|
|
42
|
+
revenueasc: 'revenue.asc',
|
|
43
|
+
revenuedesc: 'revenue.desc',
|
|
44
|
+
primary_release_dateasc: 'primary_release_date.asc',
|
|
45
|
+
titleasc: 'title.asc',
|
|
46
|
+
titledesc: 'title.desc',
|
|
47
|
+
primary_release_datedesc: 'primary_release_date.desc',
|
|
48
|
+
vote_averageasc: 'vote_average.asc',
|
|
49
|
+
vote_averagedesc: 'vote_average.desc',
|
|
50
|
+
vote_countasc: 'vote_count.asc',
|
|
51
|
+
vote_countdesc: 'vote_count.desc',
|
|
52
|
+
};
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
54
|
+
export const DiscoverTvSortBy = {
|
|
55
|
+
first_air_dateasc: 'first_air_date.asc',
|
|
56
|
+
first_air_datedesc: 'first_air_date.desc',
|
|
57
|
+
nameasc: 'name.asc',
|
|
58
|
+
namedesc: 'name.desc',
|
|
59
|
+
original_nameasc: 'original_name.asc',
|
|
60
|
+
original_namedesc: 'original_name.desc',
|
|
61
|
+
popularityasc: 'popularity.asc',
|
|
62
|
+
popularitydesc: 'popularity.desc',
|
|
63
|
+
vote_averageasc: 'vote_average.asc',
|
|
64
|
+
vote_averagedesc: 'vote_average.desc',
|
|
65
|
+
vote_countasc: 'vote_count.asc',
|
|
66
|
+
vote_countdesc: 'vote_count.desc',
|
|
67
|
+
};
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
69
|
+
export const FindByIdExternalSource = {
|
|
70
|
+
'': '',
|
|
71
|
+
imdb_id: 'imdb_id',
|
|
72
|
+
facebook_id: 'facebook_id',
|
|
73
|
+
instagram_id: 'instagram_id',
|
|
74
|
+
tvdb_id: 'tvdb_id',
|
|
75
|
+
tiktok_id: 'tiktok_id',
|
|
76
|
+
twitter_id: 'twitter_id',
|
|
77
|
+
wikidata_id: 'wikidata_id',
|
|
78
|
+
youtube_id: 'youtube_id',
|
|
79
|
+
};
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
81
|
+
export const GuestSessionRatedMoviesSortBy = {
|
|
82
|
+
created_atasc: 'created_at.asc',
|
|
83
|
+
created_atdesc: 'created_at.desc',
|
|
84
|
+
};
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
86
|
+
export const GuestSessionRatedTvSortBy = {
|
|
87
|
+
created_atasc: 'created_at.asc',
|
|
88
|
+
created_atdesc: 'created_at.desc',
|
|
89
|
+
};
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
91
|
+
export const GuestSessionRatedTvEpisodesSortBy = {
|
|
92
|
+
created_atasc: 'created_at.asc',
|
|
93
|
+
created_atdesc: 'created_at.desc',
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Test your API Key to see if it's valid.
|
|
97
|
+
* @summary Validate Key
|
|
98
|
+
*/
|
|
99
|
+
export const getAuthenticationValidateKeyUrl = () => {
|
|
100
|
+
return `https://api.themoviedb.org/3/authentication`;
|
|
101
|
+
};
|
|
102
|
+
export const authenticationValidateKey = async (options) => {
|
|
103
|
+
const res = await fetch(getAuthenticationValidateKeyUrl(), {
|
|
104
|
+
...options,
|
|
105
|
+
method: 'GET'
|
|
106
|
+
});
|
|
107
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
108
|
+
const data = body ? JSON.parse(body) : {};
|
|
109
|
+
return data;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Get the public details of an account on TMDB.
|
|
113
|
+
* @summary Details
|
|
114
|
+
*/
|
|
115
|
+
export const getAccountDetailsUrl = (accountId, params) => {
|
|
116
|
+
const normalizedParams = new URLSearchParams();
|
|
117
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
118
|
+
if (value !== undefined) {
|
|
119
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
const stringifiedParams = normalizedParams.toString();
|
|
123
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/account/${accountId}?${stringifiedParams}` : `https://api.themoviedb.org/3/account/${accountId}`;
|
|
124
|
+
};
|
|
125
|
+
export const accountDetails = async (accountId, params, options) => {
|
|
126
|
+
const res = await fetch(getAccountDetailsUrl(accountId, params), {
|
|
127
|
+
...options,
|
|
128
|
+
method: 'GET'
|
|
129
|
+
});
|
|
130
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
131
|
+
const data = body ? JSON.parse(body) : {};
|
|
132
|
+
return data;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Mark a movie or TV show as a favourite.
|
|
136
|
+
* @summary Add Favorite
|
|
137
|
+
*/
|
|
138
|
+
export const getAccountAddFavoriteUrl = (accountId, params) => {
|
|
139
|
+
const normalizedParams = new URLSearchParams();
|
|
140
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
141
|
+
if (value !== undefined) {
|
|
142
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
const stringifiedParams = normalizedParams.toString();
|
|
146
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/account/${accountId}/favorite?${stringifiedParams}` : `https://api.themoviedb.org/3/account/${accountId}/favorite`;
|
|
147
|
+
};
|
|
148
|
+
export const accountAddFavorite = async (accountId, accountAddFavoriteBody, params, options) => {
|
|
149
|
+
const res = await fetch(getAccountAddFavoriteUrl(accountId, params), {
|
|
150
|
+
...options,
|
|
151
|
+
method: 'POST',
|
|
152
|
+
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
153
|
+
body: JSON.stringify(accountAddFavoriteBody)
|
|
154
|
+
});
|
|
155
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
156
|
+
const data = body ? JSON.parse(body) : {};
|
|
157
|
+
return data;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Add a movie or TV show to your watchlist.
|
|
161
|
+
* @summary Add To Watchlist
|
|
162
|
+
*/
|
|
163
|
+
export const getAccountAddToWatchlistUrl = (accountId, params) => {
|
|
164
|
+
const normalizedParams = new URLSearchParams();
|
|
165
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
166
|
+
if (value !== undefined) {
|
|
167
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
const stringifiedParams = normalizedParams.toString();
|
|
171
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/account/${accountId}/watchlist?${stringifiedParams}` : `https://api.themoviedb.org/3/account/${accountId}/watchlist`;
|
|
172
|
+
};
|
|
173
|
+
export const accountAddToWatchlist = async (accountId, accountAddToWatchlistBody, params, options) => {
|
|
174
|
+
const res = await fetch(getAccountAddToWatchlistUrl(accountId, params), {
|
|
175
|
+
...options,
|
|
176
|
+
method: 'POST',
|
|
177
|
+
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
178
|
+
body: JSON.stringify(accountAddToWatchlistBody)
|
|
179
|
+
});
|
|
180
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
181
|
+
const data = body ? JSON.parse(body) : {};
|
|
182
|
+
return data;
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Get a users list of favourite movies.
|
|
186
|
+
* @summary Favorite Movies
|
|
187
|
+
*/
|
|
188
|
+
export const getAccountGetFavoritesUrl = (accountId, params) => {
|
|
189
|
+
const normalizedParams = new URLSearchParams();
|
|
190
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
191
|
+
if (value !== undefined) {
|
|
192
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
const stringifiedParams = normalizedParams.toString();
|
|
196
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/account/${accountId}/favorite/movies?${stringifiedParams}` : `https://api.themoviedb.org/3/account/${accountId}/favorite/movies`;
|
|
197
|
+
};
|
|
198
|
+
export const accountGetFavorites = async (accountId, params, options) => {
|
|
199
|
+
const res = await fetch(getAccountGetFavoritesUrl(accountId, params), {
|
|
200
|
+
...options,
|
|
201
|
+
method: 'GET'
|
|
202
|
+
});
|
|
203
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
204
|
+
const data = body ? JSON.parse(body) : {};
|
|
205
|
+
return data;
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Get a users list of favourite TV shows.
|
|
209
|
+
* @summary Favorite TV
|
|
210
|
+
*/
|
|
211
|
+
export const getAccountFavoriteTvUrl = (accountId, params) => {
|
|
212
|
+
const normalizedParams = new URLSearchParams();
|
|
213
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
214
|
+
if (value !== undefined) {
|
|
215
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
const stringifiedParams = normalizedParams.toString();
|
|
219
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/account/${accountId}/favorite/tv?${stringifiedParams}` : `https://api.themoviedb.org/3/account/${accountId}/favorite/tv`;
|
|
220
|
+
};
|
|
221
|
+
export const accountFavoriteTv = async (accountId, params, options) => {
|
|
222
|
+
const res = await fetch(getAccountFavoriteTvUrl(accountId, params), {
|
|
223
|
+
...options,
|
|
224
|
+
method: 'GET'
|
|
225
|
+
});
|
|
226
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
227
|
+
const data = body ? JSON.parse(body) : {};
|
|
228
|
+
return data;
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Get a users list of custom lists.
|
|
232
|
+
* @summary Lists
|
|
233
|
+
*/
|
|
234
|
+
export const getAccountListsUrl = (accountId, params) => {
|
|
235
|
+
const normalizedParams = new URLSearchParams();
|
|
236
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
237
|
+
if (value !== undefined) {
|
|
238
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
const stringifiedParams = normalizedParams.toString();
|
|
242
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/account/${accountId}/lists?${stringifiedParams}` : `https://api.themoviedb.org/3/account/${accountId}/lists`;
|
|
243
|
+
};
|
|
244
|
+
export const accountLists = async (accountId, params, options) => {
|
|
245
|
+
const res = await fetch(getAccountListsUrl(accountId, params), {
|
|
246
|
+
...options,
|
|
247
|
+
method: 'GET'
|
|
248
|
+
});
|
|
249
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
250
|
+
const data = body ? JSON.parse(body) : {};
|
|
251
|
+
return data;
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Get a users list of rated movies.
|
|
255
|
+
* @summary Rated Movies
|
|
256
|
+
*/
|
|
257
|
+
export const getAccountRatedMoviesUrl = (accountId, params) => {
|
|
258
|
+
const normalizedParams = new URLSearchParams();
|
|
259
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
260
|
+
if (value !== undefined) {
|
|
261
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
const stringifiedParams = normalizedParams.toString();
|
|
265
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/account/${accountId}/rated/movies?${stringifiedParams}` : `https://api.themoviedb.org/3/account/${accountId}/rated/movies`;
|
|
266
|
+
};
|
|
267
|
+
export const accountRatedMovies = async (accountId, params, options) => {
|
|
268
|
+
const res = await fetch(getAccountRatedMoviesUrl(accountId, params), {
|
|
269
|
+
...options,
|
|
270
|
+
method: 'GET'
|
|
271
|
+
});
|
|
272
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
273
|
+
const data = body ? JSON.parse(body) : {};
|
|
274
|
+
return data;
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* Get a users list of rated TV shows.
|
|
278
|
+
* @summary Rated TV
|
|
279
|
+
*/
|
|
280
|
+
export const getAccountRatedTvUrl = (accountId, params) => {
|
|
281
|
+
const normalizedParams = new URLSearchParams();
|
|
282
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
283
|
+
if (value !== undefined) {
|
|
284
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
const stringifiedParams = normalizedParams.toString();
|
|
288
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/account/${accountId}/rated/tv?${stringifiedParams}` : `https://api.themoviedb.org/3/account/${accountId}/rated/tv`;
|
|
289
|
+
};
|
|
290
|
+
export const accountRatedTv = async (accountId, params, options) => {
|
|
291
|
+
const res = await fetch(getAccountRatedTvUrl(accountId, params), {
|
|
292
|
+
...options,
|
|
293
|
+
method: 'GET'
|
|
294
|
+
});
|
|
295
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
296
|
+
const data = body ? JSON.parse(body) : {};
|
|
297
|
+
return data;
|
|
298
|
+
};
|
|
299
|
+
/**
|
|
300
|
+
* Get a users list of rated TV episodes.
|
|
301
|
+
* @summary Rated TV Episodes
|
|
302
|
+
*/
|
|
303
|
+
export const getAccountRatedTvEpisodesUrl = (accountId, params) => {
|
|
304
|
+
const normalizedParams = new URLSearchParams();
|
|
305
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
306
|
+
if (value !== undefined) {
|
|
307
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
const stringifiedParams = normalizedParams.toString();
|
|
311
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/account/${accountId}/rated/tv/episodes?${stringifiedParams}` : `https://api.themoviedb.org/3/account/${accountId}/rated/tv/episodes`;
|
|
312
|
+
};
|
|
313
|
+
export const accountRatedTvEpisodes = async (accountId, params, options) => {
|
|
314
|
+
const res = await fetch(getAccountRatedTvEpisodesUrl(accountId, params), {
|
|
315
|
+
...options,
|
|
316
|
+
method: 'GET'
|
|
317
|
+
});
|
|
318
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
319
|
+
const data = body ? JSON.parse(body) : {};
|
|
320
|
+
return data;
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* Get a list of movies added to a users watchlist.
|
|
324
|
+
* @summary Watchlist Movies
|
|
325
|
+
*/
|
|
326
|
+
export const getAccountWatchlistMoviesUrl = (accountId, params) => {
|
|
327
|
+
const normalizedParams = new URLSearchParams();
|
|
328
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
329
|
+
if (value !== undefined) {
|
|
330
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
const stringifiedParams = normalizedParams.toString();
|
|
334
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/account/${accountId}/watchlist/movies?${stringifiedParams}` : `https://api.themoviedb.org/3/account/${accountId}/watchlist/movies`;
|
|
335
|
+
};
|
|
336
|
+
export const accountWatchlistMovies = async (accountId, params, options) => {
|
|
337
|
+
const res = await fetch(getAccountWatchlistMoviesUrl(accountId, params), {
|
|
338
|
+
...options,
|
|
339
|
+
method: 'GET'
|
|
340
|
+
});
|
|
341
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
342
|
+
const data = body ? JSON.parse(body) : {};
|
|
343
|
+
return data;
|
|
344
|
+
};
|
|
345
|
+
/**
|
|
346
|
+
* Get a list of TV shows added to a users watchlist.
|
|
347
|
+
* @summary Watchlist TV
|
|
348
|
+
*/
|
|
349
|
+
export const getAccountWatchlistTvUrl = (accountId, params) => {
|
|
350
|
+
const normalizedParams = new URLSearchParams();
|
|
351
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
352
|
+
if (value !== undefined) {
|
|
353
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
const stringifiedParams = normalizedParams.toString();
|
|
357
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/account/${accountId}/watchlist/tv?${stringifiedParams}` : `https://api.themoviedb.org/3/account/${accountId}/watchlist/tv`;
|
|
358
|
+
};
|
|
359
|
+
export const accountWatchlistTv = async (accountId, params, options) => {
|
|
360
|
+
const res = await fetch(getAccountWatchlistTvUrl(accountId, params), {
|
|
361
|
+
...options,
|
|
362
|
+
method: 'GET'
|
|
363
|
+
});
|
|
364
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
365
|
+
const data = body ? JSON.parse(body) : {};
|
|
366
|
+
return data;
|
|
367
|
+
};
|
|
368
|
+
/**
|
|
369
|
+
* @summary Create Guest Session
|
|
370
|
+
*/
|
|
371
|
+
export const getAuthenticationCreateGuestSessionUrl = () => {
|
|
372
|
+
return `https://api.themoviedb.org/3/authentication/guest_session/new`;
|
|
373
|
+
};
|
|
374
|
+
export const authenticationCreateGuestSession = async (options) => {
|
|
375
|
+
const res = await fetch(getAuthenticationCreateGuestSessionUrl(), {
|
|
376
|
+
...options,
|
|
377
|
+
method: 'GET'
|
|
378
|
+
});
|
|
379
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
380
|
+
const data = body ? JSON.parse(body) : {};
|
|
381
|
+
return data;
|
|
382
|
+
};
|
|
383
|
+
/**
|
|
384
|
+
* @summary Create Request Token
|
|
385
|
+
*/
|
|
386
|
+
export const getAuthenticationCreateRequestTokenUrl = () => {
|
|
387
|
+
return `https://api.themoviedb.org/3/authentication/token/new`;
|
|
388
|
+
};
|
|
389
|
+
export const authenticationCreateRequestToken = async (options) => {
|
|
390
|
+
const res = await fetch(getAuthenticationCreateRequestTokenUrl(), {
|
|
391
|
+
...options,
|
|
392
|
+
method: 'GET'
|
|
393
|
+
});
|
|
394
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
395
|
+
const data = body ? JSON.parse(body) : {};
|
|
396
|
+
return data;
|
|
397
|
+
};
|
|
398
|
+
/**
|
|
399
|
+
* @summary Create Session
|
|
400
|
+
*/
|
|
401
|
+
export const getAuthenticationCreateSessionUrl = () => {
|
|
402
|
+
return `https://api.themoviedb.org/3/authentication/session/new`;
|
|
403
|
+
};
|
|
404
|
+
export const authenticationCreateSession = async (authenticationCreateSessionBody, options) => {
|
|
405
|
+
const res = await fetch(getAuthenticationCreateSessionUrl(), {
|
|
406
|
+
...options,
|
|
407
|
+
method: 'POST',
|
|
408
|
+
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
409
|
+
body: JSON.stringify(authenticationCreateSessionBody)
|
|
410
|
+
});
|
|
411
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
412
|
+
const data = body ? JSON.parse(body) : {};
|
|
413
|
+
return data;
|
|
414
|
+
};
|
|
415
|
+
/**
|
|
416
|
+
* @summary Create Session (from v4 token)
|
|
417
|
+
*/
|
|
418
|
+
export const getAuthenticationCreateSessionFromV4TokenUrl = () => {
|
|
419
|
+
return `https://api.themoviedb.org/3/authentication/session/convert/4`;
|
|
420
|
+
};
|
|
421
|
+
export const authenticationCreateSessionFromV4Token = async (authenticationCreateSessionFromV4TokenBody, options) => {
|
|
422
|
+
const res = await fetch(getAuthenticationCreateSessionFromV4TokenUrl(), {
|
|
423
|
+
...options,
|
|
424
|
+
method: 'POST',
|
|
425
|
+
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
426
|
+
body: JSON.stringify(authenticationCreateSessionFromV4TokenBody)
|
|
427
|
+
});
|
|
428
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
429
|
+
const data = body ? JSON.parse(body) : {};
|
|
430
|
+
return data;
|
|
431
|
+
};
|
|
432
|
+
/**
|
|
433
|
+
* This method allows an application to validate a request token by entering a username and password.
|
|
434
|
+
* @summary Create Session (with login)
|
|
435
|
+
*/
|
|
436
|
+
export const getAuthenticationCreateSessionFromLoginUrl = () => {
|
|
437
|
+
return `https://api.themoviedb.org/3/authentication/token/validate_with_login`;
|
|
438
|
+
};
|
|
439
|
+
export const authenticationCreateSessionFromLogin = async (authenticationCreateSessionFromLoginBody, options) => {
|
|
440
|
+
const res = await fetch(getAuthenticationCreateSessionFromLoginUrl(), {
|
|
441
|
+
...options,
|
|
442
|
+
method: 'POST',
|
|
443
|
+
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
444
|
+
body: JSON.stringify(authenticationCreateSessionFromLoginBody)
|
|
445
|
+
});
|
|
446
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
447
|
+
const data = body ? JSON.parse(body) : {};
|
|
448
|
+
return data;
|
|
449
|
+
};
|
|
450
|
+
/**
|
|
451
|
+
* @summary Delete Session
|
|
452
|
+
*/
|
|
453
|
+
export const getAuthenticationDeleteSessionUrl = () => {
|
|
454
|
+
return `https://api.themoviedb.org/3/authentication/session`;
|
|
455
|
+
};
|
|
456
|
+
export const authenticationDeleteSession = async (authenticationDeleteSessionBody, options) => {
|
|
457
|
+
const res = await fetch(getAuthenticationDeleteSessionUrl(), {
|
|
458
|
+
...options,
|
|
459
|
+
method: 'DELETE',
|
|
460
|
+
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
461
|
+
body: JSON.stringify(authenticationDeleteSessionBody)
|
|
462
|
+
});
|
|
463
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
464
|
+
const data = body ? JSON.parse(body) : {};
|
|
465
|
+
return data;
|
|
466
|
+
};
|
|
467
|
+
/**
|
|
468
|
+
* Get an up to date list of the officially supported movie certifications on TMDB.
|
|
469
|
+
* @summary Movie Certifications
|
|
470
|
+
*/
|
|
471
|
+
export const getCertificationMovieListUrl = () => {
|
|
472
|
+
return `https://api.themoviedb.org/3/certification/movie/list`;
|
|
473
|
+
};
|
|
474
|
+
export const certificationMovieList = async (options) => {
|
|
475
|
+
const res = await fetch(getCertificationMovieListUrl(), {
|
|
476
|
+
...options,
|
|
477
|
+
method: 'GET'
|
|
478
|
+
});
|
|
479
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
480
|
+
const data = body ? JSON.parse(body) : {};
|
|
481
|
+
return data;
|
|
482
|
+
};
|
|
483
|
+
/**
|
|
484
|
+
* @summary TV Certifications
|
|
485
|
+
*/
|
|
486
|
+
export const getCertificationsTvListUrl = () => {
|
|
487
|
+
return `https://api.themoviedb.org/3/certification/tv/list`;
|
|
488
|
+
};
|
|
489
|
+
export const certificationsTvList = async (options) => {
|
|
490
|
+
const res = await fetch(getCertificationsTvListUrl(), {
|
|
491
|
+
...options,
|
|
492
|
+
method: 'GET'
|
|
493
|
+
});
|
|
494
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
495
|
+
const data = body ? JSON.parse(body) : {};
|
|
496
|
+
return data;
|
|
497
|
+
};
|
|
498
|
+
/**
|
|
499
|
+
* Get a list of all of the movie ids that have been changed in the past 24 hours.
|
|
500
|
+
* @summary Movie List
|
|
501
|
+
*/
|
|
502
|
+
export const getChangesMovieListUrl = (params) => {
|
|
503
|
+
const normalizedParams = new URLSearchParams();
|
|
504
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
505
|
+
if (value !== undefined) {
|
|
506
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
const stringifiedParams = normalizedParams.toString();
|
|
510
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/movie/changes?${stringifiedParams}` : `https://api.themoviedb.org/3/movie/changes`;
|
|
511
|
+
};
|
|
512
|
+
export const changesMovieList = async (params, options) => {
|
|
513
|
+
const res = await fetch(getChangesMovieListUrl(params), {
|
|
514
|
+
...options,
|
|
515
|
+
method: 'GET'
|
|
516
|
+
});
|
|
517
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
518
|
+
const data = body ? JSON.parse(body) : {};
|
|
519
|
+
return data;
|
|
520
|
+
};
|
|
521
|
+
/**
|
|
522
|
+
* @summary People List
|
|
523
|
+
*/
|
|
524
|
+
export const getChangesPeopleListUrl = (params) => {
|
|
525
|
+
const normalizedParams = new URLSearchParams();
|
|
526
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
527
|
+
if (value !== undefined) {
|
|
528
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
const stringifiedParams = normalizedParams.toString();
|
|
532
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/person/changes?${stringifiedParams}` : `https://api.themoviedb.org/3/person/changes`;
|
|
533
|
+
};
|
|
534
|
+
export const changesPeopleList = async (params, options) => {
|
|
535
|
+
const res = await fetch(getChangesPeopleListUrl(params), {
|
|
536
|
+
...options,
|
|
537
|
+
method: 'GET'
|
|
538
|
+
});
|
|
539
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
540
|
+
const data = body ? JSON.parse(body) : {};
|
|
541
|
+
return data;
|
|
542
|
+
};
|
|
543
|
+
/**
|
|
544
|
+
* @summary TV List
|
|
545
|
+
*/
|
|
546
|
+
export const getChangesTvListUrl = (params) => {
|
|
547
|
+
const normalizedParams = new URLSearchParams();
|
|
548
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
549
|
+
if (value !== undefined) {
|
|
550
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
const stringifiedParams = normalizedParams.toString();
|
|
554
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/changes?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/changes`;
|
|
555
|
+
};
|
|
556
|
+
export const changesTvList = async (params, options) => {
|
|
557
|
+
const res = await fetch(getChangesTvListUrl(params), {
|
|
558
|
+
...options,
|
|
559
|
+
method: 'GET'
|
|
560
|
+
});
|
|
561
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
562
|
+
const data = body ? JSON.parse(body) : {};
|
|
563
|
+
return data;
|
|
564
|
+
};
|
|
565
|
+
/**
|
|
566
|
+
* Get collection details by ID.
|
|
567
|
+
* @summary Details
|
|
568
|
+
*/
|
|
569
|
+
export const getCollectionDetailsUrl = (collectionId, params) => {
|
|
570
|
+
const normalizedParams = new URLSearchParams();
|
|
571
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
572
|
+
if (value !== undefined) {
|
|
573
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
const stringifiedParams = normalizedParams.toString();
|
|
577
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/collection/${collectionId}?${stringifiedParams}` : `https://api.themoviedb.org/3/collection/${collectionId}`;
|
|
578
|
+
};
|
|
579
|
+
export const collectionDetails = async (collectionId, params, options) => {
|
|
580
|
+
const res = await fetch(getCollectionDetailsUrl(collectionId, params), {
|
|
581
|
+
...options,
|
|
582
|
+
method: 'GET'
|
|
583
|
+
});
|
|
584
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
585
|
+
const data = body ? JSON.parse(body) : {};
|
|
586
|
+
return data;
|
|
587
|
+
};
|
|
588
|
+
/**
|
|
589
|
+
* Get the images that belong to a collection.
|
|
590
|
+
* @summary Images
|
|
591
|
+
*/
|
|
592
|
+
export const getCollectionImagesUrl = (collectionId, params) => {
|
|
593
|
+
const normalizedParams = new URLSearchParams();
|
|
594
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
595
|
+
if (value !== undefined) {
|
|
596
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
const stringifiedParams = normalizedParams.toString();
|
|
600
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/collection/${collectionId}/images?${stringifiedParams}` : `https://api.themoviedb.org/3/collection/${collectionId}/images`;
|
|
601
|
+
};
|
|
602
|
+
export const collectionImages = async (collectionId, params, options) => {
|
|
603
|
+
const res = await fetch(getCollectionImagesUrl(collectionId, params), {
|
|
604
|
+
...options,
|
|
605
|
+
method: 'GET'
|
|
606
|
+
});
|
|
607
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
608
|
+
const data = body ? JSON.parse(body) : {};
|
|
609
|
+
return data;
|
|
610
|
+
};
|
|
611
|
+
/**
|
|
612
|
+
* @summary Translations
|
|
613
|
+
*/
|
|
614
|
+
export const getCollectionTranslationsUrl = (collectionId) => {
|
|
615
|
+
return `https://api.themoviedb.org/3/collection/${collectionId}/translations`;
|
|
616
|
+
};
|
|
617
|
+
export const collectionTranslations = async (collectionId, options) => {
|
|
618
|
+
const res = await fetch(getCollectionTranslationsUrl(collectionId), {
|
|
619
|
+
...options,
|
|
620
|
+
method: 'GET'
|
|
621
|
+
});
|
|
622
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
623
|
+
const data = body ? JSON.parse(body) : {};
|
|
624
|
+
return data;
|
|
625
|
+
};
|
|
626
|
+
/**
|
|
627
|
+
* Get the company details by ID.
|
|
628
|
+
* @summary Details
|
|
629
|
+
*/
|
|
630
|
+
export const getCompanyDetailsUrl = (companyId) => {
|
|
631
|
+
return `https://api.themoviedb.org/3/company/${companyId}`;
|
|
632
|
+
};
|
|
633
|
+
export const companyDetails = async (companyId, options) => {
|
|
634
|
+
const res = await fetch(getCompanyDetailsUrl(companyId), {
|
|
635
|
+
...options,
|
|
636
|
+
method: 'GET'
|
|
637
|
+
});
|
|
638
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
639
|
+
const data = body ? JSON.parse(body) : {};
|
|
640
|
+
return data;
|
|
641
|
+
};
|
|
642
|
+
/**
|
|
643
|
+
* Get the company details by ID.
|
|
644
|
+
* @summary Alternative Names
|
|
645
|
+
*/
|
|
646
|
+
export const getCompanyAlternativeNamesUrl = (companyId) => {
|
|
647
|
+
return `https://api.themoviedb.org/3/company/${companyId}/alternative_names`;
|
|
648
|
+
};
|
|
649
|
+
export const companyAlternativeNames = async (companyId, options) => {
|
|
650
|
+
const res = await fetch(getCompanyAlternativeNamesUrl(companyId), {
|
|
651
|
+
...options,
|
|
652
|
+
method: 'GET'
|
|
653
|
+
});
|
|
654
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
655
|
+
const data = body ? JSON.parse(body) : {};
|
|
656
|
+
return data;
|
|
657
|
+
};
|
|
658
|
+
/**
|
|
659
|
+
* Get the company logos by id.
|
|
660
|
+
* @summary Images
|
|
661
|
+
*/
|
|
662
|
+
export const getCompanyImagesUrl = (companyId) => {
|
|
663
|
+
return `https://api.themoviedb.org/3/company/${companyId}/images`;
|
|
664
|
+
};
|
|
665
|
+
export const companyImages = async (companyId, options) => {
|
|
666
|
+
const res = await fetch(getCompanyImagesUrl(companyId), {
|
|
667
|
+
...options,
|
|
668
|
+
method: 'GET'
|
|
669
|
+
});
|
|
670
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
671
|
+
const data = body ? JSON.parse(body) : {};
|
|
672
|
+
return data;
|
|
673
|
+
};
|
|
674
|
+
/**
|
|
675
|
+
* Query the API configuration details.
|
|
676
|
+
* @summary Details
|
|
677
|
+
*/
|
|
678
|
+
export const getConfigurationDetailsUrl = () => {
|
|
679
|
+
return `https://api.themoviedb.org/3/configuration`;
|
|
680
|
+
};
|
|
681
|
+
export const configurationDetails = async (options) => {
|
|
682
|
+
const res = await fetch(getConfigurationDetailsUrl(), {
|
|
683
|
+
...options,
|
|
684
|
+
method: 'GET'
|
|
685
|
+
});
|
|
686
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
687
|
+
const data = body ? JSON.parse(body) : {};
|
|
688
|
+
return data;
|
|
689
|
+
};
|
|
690
|
+
/**
|
|
691
|
+
* Get the list of countries (ISO 3166-1 tags) used throughout TMDB.
|
|
692
|
+
* @summary Countries
|
|
693
|
+
*/
|
|
694
|
+
export const getConfigurationCountriesUrl = (params) => {
|
|
695
|
+
const normalizedParams = new URLSearchParams();
|
|
696
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
697
|
+
if (value !== undefined) {
|
|
698
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
const stringifiedParams = normalizedParams.toString();
|
|
702
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/configuration/countries?${stringifiedParams}` : `https://api.themoviedb.org/3/configuration/countries`;
|
|
703
|
+
};
|
|
704
|
+
export const configurationCountries = async (params, options) => {
|
|
705
|
+
const res = await fetch(getConfigurationCountriesUrl(params), {
|
|
706
|
+
...options,
|
|
707
|
+
method: 'GET'
|
|
708
|
+
});
|
|
709
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
710
|
+
const data = body ? JSON.parse(body) : {};
|
|
711
|
+
return data;
|
|
712
|
+
};
|
|
713
|
+
/**
|
|
714
|
+
* Get the list of the jobs and departments we use on TMDB.
|
|
715
|
+
* @summary Jobs
|
|
716
|
+
*/
|
|
717
|
+
export const getConfigurationJobsUrl = () => {
|
|
718
|
+
return `https://api.themoviedb.org/3/configuration/jobs`;
|
|
719
|
+
};
|
|
720
|
+
export const configurationJobs = async (options) => {
|
|
721
|
+
const res = await fetch(getConfigurationJobsUrl(), {
|
|
722
|
+
...options,
|
|
723
|
+
method: 'GET'
|
|
724
|
+
});
|
|
725
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
726
|
+
const data = body ? JSON.parse(body) : {};
|
|
727
|
+
return data;
|
|
728
|
+
};
|
|
729
|
+
/**
|
|
730
|
+
* Get the list of languages (ISO 639-1 tags) used throughout TMDB.
|
|
731
|
+
* @summary Languages
|
|
732
|
+
*/
|
|
733
|
+
export const getConfigurationLanguagesUrl = () => {
|
|
734
|
+
return `https://api.themoviedb.org/3/configuration/languages`;
|
|
735
|
+
};
|
|
736
|
+
export const configurationLanguages = async (options) => {
|
|
737
|
+
const res = await fetch(getConfigurationLanguagesUrl(), {
|
|
738
|
+
...options,
|
|
739
|
+
method: 'GET'
|
|
740
|
+
});
|
|
741
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
742
|
+
const data = body ? JSON.parse(body) : {};
|
|
743
|
+
return data;
|
|
744
|
+
};
|
|
745
|
+
/**
|
|
746
|
+
* Get a list of the officially supported translations on TMDB.
|
|
747
|
+
* @summary Primary Translations
|
|
748
|
+
*/
|
|
749
|
+
export const getConfigurationPrimaryTranslationsUrl = () => {
|
|
750
|
+
return `https://api.themoviedb.org/3/configuration/primary_translations`;
|
|
751
|
+
};
|
|
752
|
+
export const configurationPrimaryTranslations = async (options) => {
|
|
753
|
+
const res = await fetch(getConfigurationPrimaryTranslationsUrl(), {
|
|
754
|
+
...options,
|
|
755
|
+
method: 'GET'
|
|
756
|
+
});
|
|
757
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
758
|
+
const data = body ? JSON.parse(body) : {};
|
|
759
|
+
return data;
|
|
760
|
+
};
|
|
761
|
+
/**
|
|
762
|
+
* Get the list of timezones used throughout TMDB.
|
|
763
|
+
* @summary Timezones
|
|
764
|
+
*/
|
|
765
|
+
export const getConfigurationTimezonesUrl = () => {
|
|
766
|
+
return `https://api.themoviedb.org/3/configuration/timezones`;
|
|
767
|
+
};
|
|
768
|
+
export const configurationTimezones = async (options) => {
|
|
769
|
+
const res = await fetch(getConfigurationTimezonesUrl(), {
|
|
770
|
+
...options,
|
|
771
|
+
method: 'GET'
|
|
772
|
+
});
|
|
773
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
774
|
+
const data = body ? JSON.parse(body) : {};
|
|
775
|
+
return data;
|
|
776
|
+
};
|
|
777
|
+
/**
|
|
778
|
+
* Get a movie or TV credit details by ID.
|
|
779
|
+
* @summary Details
|
|
780
|
+
*/
|
|
781
|
+
export const getCreditDetailsUrl = (creditId) => {
|
|
782
|
+
return `https://api.themoviedb.org/3/credit/${creditId}`;
|
|
783
|
+
};
|
|
784
|
+
export const creditDetails = async (creditId, options) => {
|
|
785
|
+
const res = await fetch(getCreditDetailsUrl(creditId), {
|
|
786
|
+
...options,
|
|
787
|
+
method: 'GET'
|
|
788
|
+
});
|
|
789
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
790
|
+
const data = body ? JSON.parse(body) : {};
|
|
791
|
+
return data;
|
|
792
|
+
};
|
|
793
|
+
/**
|
|
794
|
+
* Find movies using over 30 filters and sort options.
|
|
795
|
+
* @summary Movie
|
|
796
|
+
*/
|
|
797
|
+
export const getDiscoverMovieUrl = (params) => {
|
|
798
|
+
const normalizedParams = new URLSearchParams();
|
|
799
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
800
|
+
if (value !== undefined) {
|
|
801
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
const stringifiedParams = normalizedParams.toString();
|
|
805
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/discover/movie?${stringifiedParams}` : `https://api.themoviedb.org/3/discover/movie`;
|
|
806
|
+
};
|
|
807
|
+
export const discoverMovie = async (params, options) => {
|
|
808
|
+
const res = await fetch(getDiscoverMovieUrl(params), {
|
|
809
|
+
...options,
|
|
810
|
+
method: 'GET'
|
|
811
|
+
});
|
|
812
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
813
|
+
const data = body ? JSON.parse(body) : {};
|
|
814
|
+
return data;
|
|
815
|
+
};
|
|
816
|
+
/**
|
|
817
|
+
* Find TV shows using over 30 filters and sort options.
|
|
818
|
+
* @summary TV
|
|
819
|
+
*/
|
|
820
|
+
export const getDiscoverTvUrl = (params) => {
|
|
821
|
+
const normalizedParams = new URLSearchParams();
|
|
822
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
823
|
+
if (value !== undefined) {
|
|
824
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
const stringifiedParams = normalizedParams.toString();
|
|
828
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/discover/tv?${stringifiedParams}` : `https://api.themoviedb.org/3/discover/tv`;
|
|
829
|
+
};
|
|
830
|
+
export const discoverTv = async (params, options) => {
|
|
831
|
+
const res = await fetch(getDiscoverTvUrl(params), {
|
|
832
|
+
...options,
|
|
833
|
+
method: 'GET'
|
|
834
|
+
});
|
|
835
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
836
|
+
const data = body ? JSON.parse(body) : {};
|
|
837
|
+
return data;
|
|
838
|
+
};
|
|
839
|
+
/**
|
|
840
|
+
* Find data by external ID's.
|
|
841
|
+
* @summary Find By ID
|
|
842
|
+
*/
|
|
843
|
+
export const getFindByIdUrl = (externalId, params) => {
|
|
844
|
+
const normalizedParams = new URLSearchParams();
|
|
845
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
846
|
+
if (value !== undefined) {
|
|
847
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
848
|
+
}
|
|
849
|
+
});
|
|
850
|
+
const stringifiedParams = normalizedParams.toString();
|
|
851
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/find/${externalId}?${stringifiedParams}` : `https://api.themoviedb.org/3/find/${externalId}`;
|
|
852
|
+
};
|
|
853
|
+
export const findById = async (externalId, params, options) => {
|
|
854
|
+
const res = await fetch(getFindByIdUrl(externalId, params), {
|
|
855
|
+
...options,
|
|
856
|
+
method: 'GET'
|
|
857
|
+
});
|
|
858
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
859
|
+
const data = body ? JSON.parse(body) : {};
|
|
860
|
+
return data;
|
|
861
|
+
};
|
|
862
|
+
/**
|
|
863
|
+
* Get the list of official genres for movies.
|
|
864
|
+
* @summary Movie List
|
|
865
|
+
*/
|
|
866
|
+
export const getGenreMovieListUrl = (params) => {
|
|
867
|
+
const normalizedParams = new URLSearchParams();
|
|
868
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
869
|
+
if (value !== undefined) {
|
|
870
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
871
|
+
}
|
|
872
|
+
});
|
|
873
|
+
const stringifiedParams = normalizedParams.toString();
|
|
874
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/genre/movie/list?${stringifiedParams}` : `https://api.themoviedb.org/3/genre/movie/list`;
|
|
875
|
+
};
|
|
876
|
+
export const genreMovieList = async (params, options) => {
|
|
877
|
+
const res = await fetch(getGenreMovieListUrl(params), {
|
|
878
|
+
...options,
|
|
879
|
+
method: 'GET'
|
|
880
|
+
});
|
|
881
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
882
|
+
const data = body ? JSON.parse(body) : {};
|
|
883
|
+
return data;
|
|
884
|
+
};
|
|
885
|
+
/**
|
|
886
|
+
* Get the list of official genres for TV shows.
|
|
887
|
+
* @summary TV List
|
|
888
|
+
*/
|
|
889
|
+
export const getGenreTvListUrl = (params) => {
|
|
890
|
+
const normalizedParams = new URLSearchParams();
|
|
891
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
892
|
+
if (value !== undefined) {
|
|
893
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
894
|
+
}
|
|
895
|
+
});
|
|
896
|
+
const stringifiedParams = normalizedParams.toString();
|
|
897
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/genre/tv/list?${stringifiedParams}` : `https://api.themoviedb.org/3/genre/tv/list`;
|
|
898
|
+
};
|
|
899
|
+
export const genreTvList = async (params, options) => {
|
|
900
|
+
const res = await fetch(getGenreTvListUrl(params), {
|
|
901
|
+
...options,
|
|
902
|
+
method: 'GET'
|
|
903
|
+
});
|
|
904
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
905
|
+
const data = body ? JSON.parse(body) : {};
|
|
906
|
+
return data;
|
|
907
|
+
};
|
|
908
|
+
/**
|
|
909
|
+
* Get the rated movies for a guest session.
|
|
910
|
+
* @summary Rated Movies
|
|
911
|
+
*/
|
|
912
|
+
export const getGuestSessionRatedMoviesUrl = (guestSessionId, params) => {
|
|
913
|
+
const normalizedParams = new URLSearchParams();
|
|
914
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
915
|
+
if (value !== undefined) {
|
|
916
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
917
|
+
}
|
|
918
|
+
});
|
|
919
|
+
const stringifiedParams = normalizedParams.toString();
|
|
920
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/guest_session/${guestSessionId}/rated/movies?${stringifiedParams}` : `https://api.themoviedb.org/3/guest_session/${guestSessionId}/rated/movies`;
|
|
921
|
+
};
|
|
922
|
+
export const guestSessionRatedMovies = async (guestSessionId, params, options) => {
|
|
923
|
+
const res = await fetch(getGuestSessionRatedMoviesUrl(guestSessionId, params), {
|
|
924
|
+
...options,
|
|
925
|
+
method: 'GET'
|
|
926
|
+
});
|
|
927
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
928
|
+
const data = body ? JSON.parse(body) : {};
|
|
929
|
+
return data;
|
|
930
|
+
};
|
|
931
|
+
/**
|
|
932
|
+
* Get the rated TV shows for a guest session.
|
|
933
|
+
* @summary Rated TV
|
|
934
|
+
*/
|
|
935
|
+
export const getGuestSessionRatedTvUrl = (guestSessionId, params) => {
|
|
936
|
+
const normalizedParams = new URLSearchParams();
|
|
937
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
938
|
+
if (value !== undefined) {
|
|
939
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
940
|
+
}
|
|
941
|
+
});
|
|
942
|
+
const stringifiedParams = normalizedParams.toString();
|
|
943
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/guest_session/${guestSessionId}/rated/tv?${stringifiedParams}` : `https://api.themoviedb.org/3/guest_session/${guestSessionId}/rated/tv`;
|
|
944
|
+
};
|
|
945
|
+
export const guestSessionRatedTv = async (guestSessionId, params, options) => {
|
|
946
|
+
const res = await fetch(getGuestSessionRatedTvUrl(guestSessionId, params), {
|
|
947
|
+
...options,
|
|
948
|
+
method: 'GET'
|
|
949
|
+
});
|
|
950
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
951
|
+
const data = body ? JSON.parse(body) : {};
|
|
952
|
+
return data;
|
|
953
|
+
};
|
|
954
|
+
/**
|
|
955
|
+
* Get the rated TV episodes for a guest session.
|
|
956
|
+
* @summary Rated TV Episodes
|
|
957
|
+
*/
|
|
958
|
+
export const getGuestSessionRatedTvEpisodesUrl = (guestSessionId, params) => {
|
|
959
|
+
const normalizedParams = new URLSearchParams();
|
|
960
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
961
|
+
if (value !== undefined) {
|
|
962
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
963
|
+
}
|
|
964
|
+
});
|
|
965
|
+
const stringifiedParams = normalizedParams.toString();
|
|
966
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/guest_session/${guestSessionId}/rated/tv/episodes?${stringifiedParams}` : `https://api.themoviedb.org/3/guest_session/${guestSessionId}/rated/tv/episodes`;
|
|
967
|
+
};
|
|
968
|
+
export const guestSessionRatedTvEpisodes = async (guestSessionId, params, options) => {
|
|
969
|
+
const res = await fetch(getGuestSessionRatedTvEpisodesUrl(guestSessionId, params), {
|
|
970
|
+
...options,
|
|
971
|
+
method: 'GET'
|
|
972
|
+
});
|
|
973
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
974
|
+
const data = body ? JSON.parse(body) : {};
|
|
975
|
+
return data;
|
|
976
|
+
};
|
|
977
|
+
/**
|
|
978
|
+
* @summary Details
|
|
979
|
+
*/
|
|
980
|
+
export const getKeywordDetailsUrl = (keywordId) => {
|
|
981
|
+
return `https://api.themoviedb.org/3/keyword/${keywordId}`;
|
|
982
|
+
};
|
|
983
|
+
export const keywordDetails = async (keywordId, options) => {
|
|
984
|
+
const res = await fetch(getKeywordDetailsUrl(keywordId), {
|
|
985
|
+
...options,
|
|
986
|
+
method: 'GET'
|
|
987
|
+
});
|
|
988
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
989
|
+
const data = body ? JSON.parse(body) : {};
|
|
990
|
+
return data;
|
|
991
|
+
};
|
|
992
|
+
/**
|
|
993
|
+
* @summary Movies
|
|
994
|
+
*/
|
|
995
|
+
export const getKeywordMoviesUrl = (keywordId, params) => {
|
|
996
|
+
const normalizedParams = new URLSearchParams();
|
|
997
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
998
|
+
if (value !== undefined) {
|
|
999
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1000
|
+
}
|
|
1001
|
+
});
|
|
1002
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1003
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/keyword/${keywordId}/movies?${stringifiedParams}` : `https://api.themoviedb.org/3/keyword/${keywordId}/movies`;
|
|
1004
|
+
};
|
|
1005
|
+
export const keywordMovies = async (keywordId, params, options) => {
|
|
1006
|
+
const res = await fetch(getKeywordMoviesUrl(keywordId, params), {
|
|
1007
|
+
...options,
|
|
1008
|
+
method: 'GET'
|
|
1009
|
+
});
|
|
1010
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1011
|
+
const data = body ? JSON.parse(body) : {};
|
|
1012
|
+
return data;
|
|
1013
|
+
};
|
|
1014
|
+
/**
|
|
1015
|
+
* Add a movie to a list.
|
|
1016
|
+
* @summary Add Movie
|
|
1017
|
+
*/
|
|
1018
|
+
export const getListAddMovieUrl = (listId, params) => {
|
|
1019
|
+
const normalizedParams = new URLSearchParams();
|
|
1020
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1021
|
+
if (value !== undefined) {
|
|
1022
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1023
|
+
}
|
|
1024
|
+
});
|
|
1025
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1026
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/list/${listId}/add_item?${stringifiedParams}` : `https://api.themoviedb.org/3/list/${listId}/add_item`;
|
|
1027
|
+
};
|
|
1028
|
+
export const listAddMovie = async (listId, listAddMovieBody, params, options) => {
|
|
1029
|
+
const res = await fetch(getListAddMovieUrl(listId, params), {
|
|
1030
|
+
...options,
|
|
1031
|
+
method: 'POST',
|
|
1032
|
+
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
1033
|
+
body: JSON.stringify(listAddMovieBody)
|
|
1034
|
+
});
|
|
1035
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1036
|
+
const data = body ? JSON.parse(body) : {};
|
|
1037
|
+
return data;
|
|
1038
|
+
};
|
|
1039
|
+
/**
|
|
1040
|
+
* Use this method to check if an item has already been added to the list.
|
|
1041
|
+
* @summary Check Item Status
|
|
1042
|
+
*/
|
|
1043
|
+
export const getListCheckItemStatusUrl = (listId, params) => {
|
|
1044
|
+
const normalizedParams = new URLSearchParams();
|
|
1045
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1046
|
+
if (value !== undefined) {
|
|
1047
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1048
|
+
}
|
|
1049
|
+
});
|
|
1050
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1051
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/list/${listId}/item_status?${stringifiedParams}` : `https://api.themoviedb.org/3/list/${listId}/item_status`;
|
|
1052
|
+
};
|
|
1053
|
+
export const listCheckItemStatus = async (listId, params, options) => {
|
|
1054
|
+
const res = await fetch(getListCheckItemStatusUrl(listId, params), {
|
|
1055
|
+
...options,
|
|
1056
|
+
method: 'GET'
|
|
1057
|
+
});
|
|
1058
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1059
|
+
const data = body ? JSON.parse(body) : {};
|
|
1060
|
+
return data;
|
|
1061
|
+
};
|
|
1062
|
+
/**
|
|
1063
|
+
* Clear all items from a list.
|
|
1064
|
+
* @summary Clear
|
|
1065
|
+
*/
|
|
1066
|
+
export const getListClearUrl = (listId, params) => {
|
|
1067
|
+
const normalizedParams = new URLSearchParams();
|
|
1068
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1069
|
+
if (value !== undefined) {
|
|
1070
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1073
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1074
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/list/${listId}/clear?${stringifiedParams}` : `https://api.themoviedb.org/3/list/${listId}/clear`;
|
|
1075
|
+
};
|
|
1076
|
+
export const listClear = async (listId, params, options) => {
|
|
1077
|
+
const res = await fetch(getListClearUrl(listId, params), {
|
|
1078
|
+
...options,
|
|
1079
|
+
method: 'POST'
|
|
1080
|
+
});
|
|
1081
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1082
|
+
const data = body ? JSON.parse(body) : {};
|
|
1083
|
+
return data;
|
|
1084
|
+
};
|
|
1085
|
+
/**
|
|
1086
|
+
* @summary Create
|
|
1087
|
+
*/
|
|
1088
|
+
export const getListCreateUrl = (params) => {
|
|
1089
|
+
const normalizedParams = new URLSearchParams();
|
|
1090
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1091
|
+
if (value !== undefined) {
|
|
1092
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1093
|
+
}
|
|
1094
|
+
});
|
|
1095
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1096
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/list?${stringifiedParams}` : `https://api.themoviedb.org/3/list`;
|
|
1097
|
+
};
|
|
1098
|
+
export const listCreate = async (listCreateBody, params, options) => {
|
|
1099
|
+
const res = await fetch(getListCreateUrl(params), {
|
|
1100
|
+
...options,
|
|
1101
|
+
method: 'POST',
|
|
1102
|
+
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
1103
|
+
body: JSON.stringify(listCreateBody)
|
|
1104
|
+
});
|
|
1105
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1106
|
+
const data = body ? JSON.parse(body) : {};
|
|
1107
|
+
return data;
|
|
1108
|
+
};
|
|
1109
|
+
/**
|
|
1110
|
+
* Delete a list.
|
|
1111
|
+
* @summary Delete
|
|
1112
|
+
*/
|
|
1113
|
+
export const getListDeleteUrl = (listId, params) => {
|
|
1114
|
+
const normalizedParams = new URLSearchParams();
|
|
1115
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1116
|
+
if (value !== undefined) {
|
|
1117
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1118
|
+
}
|
|
1119
|
+
});
|
|
1120
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1121
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/list/${listId}?${stringifiedParams}` : `https://api.themoviedb.org/3/list/${listId}`;
|
|
1122
|
+
};
|
|
1123
|
+
export const listDelete = async (listId, params, options) => {
|
|
1124
|
+
const res = await fetch(getListDeleteUrl(listId, params), {
|
|
1125
|
+
...options,
|
|
1126
|
+
method: 'DELETE'
|
|
1127
|
+
});
|
|
1128
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1129
|
+
const data = body ? JSON.parse(body) : {};
|
|
1130
|
+
return data;
|
|
1131
|
+
};
|
|
1132
|
+
/**
|
|
1133
|
+
* @summary Details
|
|
1134
|
+
*/
|
|
1135
|
+
export const getListDetailsUrl = (listId, params) => {
|
|
1136
|
+
const normalizedParams = new URLSearchParams();
|
|
1137
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1138
|
+
if (value !== undefined) {
|
|
1139
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1143
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/list/${listId}?${stringifiedParams}` : `https://api.themoviedb.org/3/list/${listId}`;
|
|
1144
|
+
};
|
|
1145
|
+
export const listDetails = async (listId, params, options) => {
|
|
1146
|
+
const res = await fetch(getListDetailsUrl(listId, params), {
|
|
1147
|
+
...options,
|
|
1148
|
+
method: 'GET'
|
|
1149
|
+
});
|
|
1150
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1151
|
+
const data = body ? JSON.parse(body) : {};
|
|
1152
|
+
return data;
|
|
1153
|
+
};
|
|
1154
|
+
/**
|
|
1155
|
+
* Remove a movie from a list.
|
|
1156
|
+
* @summary Remove Movie
|
|
1157
|
+
*/
|
|
1158
|
+
export const getListRemoveMovieUrl = (listId, params) => {
|
|
1159
|
+
const normalizedParams = new URLSearchParams();
|
|
1160
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1161
|
+
if (value !== undefined) {
|
|
1162
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1163
|
+
}
|
|
1164
|
+
});
|
|
1165
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1166
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/list/${listId}/remove_item?${stringifiedParams}` : `https://api.themoviedb.org/3/list/${listId}/remove_item`;
|
|
1167
|
+
};
|
|
1168
|
+
export const listRemoveMovie = async (listId, listRemoveMovieBody, params, options) => {
|
|
1169
|
+
const res = await fetch(getListRemoveMovieUrl(listId, params), {
|
|
1170
|
+
...options,
|
|
1171
|
+
method: 'POST',
|
|
1172
|
+
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
1173
|
+
body: JSON.stringify(listRemoveMovieBody)
|
|
1174
|
+
});
|
|
1175
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1176
|
+
const data = body ? JSON.parse(body) : {};
|
|
1177
|
+
return data;
|
|
1178
|
+
};
|
|
1179
|
+
/**
|
|
1180
|
+
* Get a list of movies that are currently in theatres.
|
|
1181
|
+
* @summary Now Playing
|
|
1182
|
+
*/
|
|
1183
|
+
export const getMovieNowPlayingListUrl = (params) => {
|
|
1184
|
+
const normalizedParams = new URLSearchParams();
|
|
1185
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1186
|
+
if (value !== undefined) {
|
|
1187
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1188
|
+
}
|
|
1189
|
+
});
|
|
1190
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1191
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/movie/now_playing?${stringifiedParams}` : `https://api.themoviedb.org/3/movie/now_playing`;
|
|
1192
|
+
};
|
|
1193
|
+
export const movieNowPlayingList = async (params, options) => {
|
|
1194
|
+
const res = await fetch(getMovieNowPlayingListUrl(params), {
|
|
1195
|
+
...options,
|
|
1196
|
+
method: 'GET'
|
|
1197
|
+
});
|
|
1198
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1199
|
+
const data = body ? JSON.parse(body) : {};
|
|
1200
|
+
return data;
|
|
1201
|
+
};
|
|
1202
|
+
/**
|
|
1203
|
+
* Get a list of movies ordered by popularity.
|
|
1204
|
+
* @summary Popular
|
|
1205
|
+
*/
|
|
1206
|
+
export const getMoviePopularListUrl = (params) => {
|
|
1207
|
+
const normalizedParams = new URLSearchParams();
|
|
1208
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1209
|
+
if (value !== undefined) {
|
|
1210
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1211
|
+
}
|
|
1212
|
+
});
|
|
1213
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1214
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/movie/popular?${stringifiedParams}` : `https://api.themoviedb.org/3/movie/popular`;
|
|
1215
|
+
};
|
|
1216
|
+
export const moviePopularList = async (params, options) => {
|
|
1217
|
+
const res = await fetch(getMoviePopularListUrl(params), {
|
|
1218
|
+
...options,
|
|
1219
|
+
method: 'GET'
|
|
1220
|
+
});
|
|
1221
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1222
|
+
const data = body ? JSON.parse(body) : {};
|
|
1223
|
+
return data;
|
|
1224
|
+
};
|
|
1225
|
+
/**
|
|
1226
|
+
* Get a list of movies ordered by rating.
|
|
1227
|
+
* @summary Top Rated
|
|
1228
|
+
*/
|
|
1229
|
+
export const getMovieTopRatedListUrl = (params) => {
|
|
1230
|
+
const normalizedParams = new URLSearchParams();
|
|
1231
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1232
|
+
if (value !== undefined) {
|
|
1233
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1234
|
+
}
|
|
1235
|
+
});
|
|
1236
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1237
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/movie/top_rated?${stringifiedParams}` : `https://api.themoviedb.org/3/movie/top_rated`;
|
|
1238
|
+
};
|
|
1239
|
+
export const movieTopRatedList = async (params, options) => {
|
|
1240
|
+
const res = await fetch(getMovieTopRatedListUrl(params), {
|
|
1241
|
+
...options,
|
|
1242
|
+
method: 'GET'
|
|
1243
|
+
});
|
|
1244
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1245
|
+
const data = body ? JSON.parse(body) : {};
|
|
1246
|
+
return data;
|
|
1247
|
+
};
|
|
1248
|
+
/**
|
|
1249
|
+
* Get a list of movies that are being released soon.
|
|
1250
|
+
* @summary Upcoming
|
|
1251
|
+
*/
|
|
1252
|
+
export const getMovieUpcomingListUrl = (params) => {
|
|
1253
|
+
const normalizedParams = new URLSearchParams();
|
|
1254
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1255
|
+
if (value !== undefined) {
|
|
1256
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1257
|
+
}
|
|
1258
|
+
});
|
|
1259
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1260
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/movie/upcoming?${stringifiedParams}` : `https://api.themoviedb.org/3/movie/upcoming`;
|
|
1261
|
+
};
|
|
1262
|
+
export const movieUpcomingList = async (params, options) => {
|
|
1263
|
+
const res = await fetch(getMovieUpcomingListUrl(params), {
|
|
1264
|
+
...options,
|
|
1265
|
+
method: 'GET'
|
|
1266
|
+
});
|
|
1267
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1268
|
+
const data = body ? JSON.parse(body) : {};
|
|
1269
|
+
return data;
|
|
1270
|
+
};
|
|
1271
|
+
/**
|
|
1272
|
+
* Get the top level details of a movie by ID.
|
|
1273
|
+
* @summary Details
|
|
1274
|
+
*/
|
|
1275
|
+
export const getMovieDetailsUrl = (movieId, params) => {
|
|
1276
|
+
const normalizedParams = new URLSearchParams();
|
|
1277
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1278
|
+
if (value !== undefined) {
|
|
1279
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1280
|
+
}
|
|
1281
|
+
});
|
|
1282
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1283
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/movie/${movieId}?${stringifiedParams}` : `https://api.themoviedb.org/3/movie/${movieId}`;
|
|
1284
|
+
};
|
|
1285
|
+
export const movieDetails = async (movieId, params, options) => {
|
|
1286
|
+
const res = await fetch(getMovieDetailsUrl(movieId, params), {
|
|
1287
|
+
...options,
|
|
1288
|
+
method: 'GET'
|
|
1289
|
+
});
|
|
1290
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1291
|
+
const data = body ? JSON.parse(body) : {};
|
|
1292
|
+
return data;
|
|
1293
|
+
};
|
|
1294
|
+
/**
|
|
1295
|
+
* Get the rating, watchlist and favourite status of an account.
|
|
1296
|
+
* @summary Account States
|
|
1297
|
+
*/
|
|
1298
|
+
export const getMovieAccountStatesUrl = (movieId, params) => {
|
|
1299
|
+
const normalizedParams = new URLSearchParams();
|
|
1300
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1301
|
+
if (value !== undefined) {
|
|
1302
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1303
|
+
}
|
|
1304
|
+
});
|
|
1305
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1306
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/movie/${movieId}/account_states?${stringifiedParams}` : `https://api.themoviedb.org/3/movie/${movieId}/account_states`;
|
|
1307
|
+
};
|
|
1308
|
+
export const movieAccountStates = async (movieId, params, options) => {
|
|
1309
|
+
const res = await fetch(getMovieAccountStatesUrl(movieId, params), {
|
|
1310
|
+
...options,
|
|
1311
|
+
method: 'GET'
|
|
1312
|
+
});
|
|
1313
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1314
|
+
const data = body ? JSON.parse(body) : {};
|
|
1315
|
+
return data;
|
|
1316
|
+
};
|
|
1317
|
+
/**
|
|
1318
|
+
* Get the alternative titles for a movie.
|
|
1319
|
+
* @summary Alternative Titles
|
|
1320
|
+
*/
|
|
1321
|
+
export const getMovieAlternativeTitlesUrl = (movieId, params) => {
|
|
1322
|
+
const normalizedParams = new URLSearchParams();
|
|
1323
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1324
|
+
if (value !== undefined) {
|
|
1325
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1326
|
+
}
|
|
1327
|
+
});
|
|
1328
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1329
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/movie/${movieId}/alternative_titles?${stringifiedParams}` : `https://api.themoviedb.org/3/movie/${movieId}/alternative_titles`;
|
|
1330
|
+
};
|
|
1331
|
+
export const movieAlternativeTitles = async (movieId, params, options) => {
|
|
1332
|
+
const res = await fetch(getMovieAlternativeTitlesUrl(movieId, params), {
|
|
1333
|
+
...options,
|
|
1334
|
+
method: 'GET'
|
|
1335
|
+
});
|
|
1336
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1337
|
+
const data = body ? JSON.parse(body) : {};
|
|
1338
|
+
return data;
|
|
1339
|
+
};
|
|
1340
|
+
/**
|
|
1341
|
+
* Get the recent changes for a movie.
|
|
1342
|
+
* @summary Changes
|
|
1343
|
+
*/
|
|
1344
|
+
export const getMovieChangesUrl = (movieId, params) => {
|
|
1345
|
+
const normalizedParams = new URLSearchParams();
|
|
1346
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1347
|
+
if (value !== undefined) {
|
|
1348
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1349
|
+
}
|
|
1350
|
+
});
|
|
1351
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1352
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/movie/${movieId}/changes?${stringifiedParams}` : `https://api.themoviedb.org/3/movie/${movieId}/changes`;
|
|
1353
|
+
};
|
|
1354
|
+
export const movieChanges = async (movieId, params, options) => {
|
|
1355
|
+
const res = await fetch(getMovieChangesUrl(movieId, params), {
|
|
1356
|
+
...options,
|
|
1357
|
+
method: 'GET'
|
|
1358
|
+
});
|
|
1359
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1360
|
+
const data = body ? JSON.parse(body) : {};
|
|
1361
|
+
return data;
|
|
1362
|
+
};
|
|
1363
|
+
/**
|
|
1364
|
+
* @summary Credits
|
|
1365
|
+
*/
|
|
1366
|
+
export const getMovieCreditsUrl = (movieId, params) => {
|
|
1367
|
+
const normalizedParams = new URLSearchParams();
|
|
1368
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1369
|
+
if (value !== undefined) {
|
|
1370
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1371
|
+
}
|
|
1372
|
+
});
|
|
1373
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1374
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/movie/${movieId}/credits?${stringifiedParams}` : `https://api.themoviedb.org/3/movie/${movieId}/credits`;
|
|
1375
|
+
};
|
|
1376
|
+
export const movieCredits = async (movieId, params, options) => {
|
|
1377
|
+
const res = await fetch(getMovieCreditsUrl(movieId, params), {
|
|
1378
|
+
...options,
|
|
1379
|
+
method: 'GET'
|
|
1380
|
+
});
|
|
1381
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1382
|
+
const data = body ? JSON.parse(body) : {};
|
|
1383
|
+
return data;
|
|
1384
|
+
};
|
|
1385
|
+
/**
|
|
1386
|
+
* @summary External IDs
|
|
1387
|
+
*/
|
|
1388
|
+
export const getMovieExternalIdsUrl = (movieId) => {
|
|
1389
|
+
return `https://api.themoviedb.org/3/movie/${movieId}/external_ids`;
|
|
1390
|
+
};
|
|
1391
|
+
export const movieExternalIds = async (movieId, options) => {
|
|
1392
|
+
const res = await fetch(getMovieExternalIdsUrl(movieId), {
|
|
1393
|
+
...options,
|
|
1394
|
+
method: 'GET'
|
|
1395
|
+
});
|
|
1396
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1397
|
+
const data = body ? JSON.parse(body) : {};
|
|
1398
|
+
return data;
|
|
1399
|
+
};
|
|
1400
|
+
/**
|
|
1401
|
+
* Get the images that belong to a movie.
|
|
1402
|
+
* @summary Images
|
|
1403
|
+
*/
|
|
1404
|
+
export const getMovieImagesUrl = (movieId, params) => {
|
|
1405
|
+
const normalizedParams = new URLSearchParams();
|
|
1406
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1407
|
+
if (value !== undefined) {
|
|
1408
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1409
|
+
}
|
|
1410
|
+
});
|
|
1411
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1412
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/movie/${movieId}/images?${stringifiedParams}` : `https://api.themoviedb.org/3/movie/${movieId}/images`;
|
|
1413
|
+
};
|
|
1414
|
+
export const movieImages = async (movieId, params, options) => {
|
|
1415
|
+
const res = await fetch(getMovieImagesUrl(movieId, params), {
|
|
1416
|
+
...options,
|
|
1417
|
+
method: 'GET'
|
|
1418
|
+
});
|
|
1419
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1420
|
+
const data = body ? JSON.parse(body) : {};
|
|
1421
|
+
return data;
|
|
1422
|
+
};
|
|
1423
|
+
/**
|
|
1424
|
+
* @summary Keywords
|
|
1425
|
+
*/
|
|
1426
|
+
export const getMovieKeywordsUrl = (movieId) => {
|
|
1427
|
+
return `https://api.themoviedb.org/3/movie/${movieId}/keywords`;
|
|
1428
|
+
};
|
|
1429
|
+
export const movieKeywords = async (movieId, options) => {
|
|
1430
|
+
const res = await fetch(getMovieKeywordsUrl(movieId), {
|
|
1431
|
+
...options,
|
|
1432
|
+
method: 'GET'
|
|
1433
|
+
});
|
|
1434
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1435
|
+
const data = body ? JSON.parse(body) : {};
|
|
1436
|
+
return data;
|
|
1437
|
+
};
|
|
1438
|
+
/**
|
|
1439
|
+
* Get the newest movie ID.
|
|
1440
|
+
* @summary Latest
|
|
1441
|
+
*/
|
|
1442
|
+
export const getMovieLatestIdUrl = () => {
|
|
1443
|
+
return `https://api.themoviedb.org/3/movie/latest`;
|
|
1444
|
+
};
|
|
1445
|
+
export const movieLatestId = async (options) => {
|
|
1446
|
+
const res = await fetch(getMovieLatestIdUrl(), {
|
|
1447
|
+
...options,
|
|
1448
|
+
method: 'GET'
|
|
1449
|
+
});
|
|
1450
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1451
|
+
const data = body ? JSON.parse(body) : {};
|
|
1452
|
+
return data;
|
|
1453
|
+
};
|
|
1454
|
+
/**
|
|
1455
|
+
* Get the lists that a movie has been added to.
|
|
1456
|
+
* @summary Lists
|
|
1457
|
+
*/
|
|
1458
|
+
export const getMovieListsUrl = (movieId, params) => {
|
|
1459
|
+
const normalizedParams = new URLSearchParams();
|
|
1460
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1461
|
+
if (value !== undefined) {
|
|
1462
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1463
|
+
}
|
|
1464
|
+
});
|
|
1465
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1466
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/movie/${movieId}/lists?${stringifiedParams}` : `https://api.themoviedb.org/3/movie/${movieId}/lists`;
|
|
1467
|
+
};
|
|
1468
|
+
export const movieLists = async (movieId, params, options) => {
|
|
1469
|
+
const res = await fetch(getMovieListsUrl(movieId, params), {
|
|
1470
|
+
...options,
|
|
1471
|
+
method: 'GET'
|
|
1472
|
+
});
|
|
1473
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1474
|
+
const data = body ? JSON.parse(body) : {};
|
|
1475
|
+
return data;
|
|
1476
|
+
};
|
|
1477
|
+
/**
|
|
1478
|
+
* @summary Recommendations
|
|
1479
|
+
*/
|
|
1480
|
+
export const getMovieRecommendationsUrl = (movieId, params) => {
|
|
1481
|
+
const normalizedParams = new URLSearchParams();
|
|
1482
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1483
|
+
if (value !== undefined) {
|
|
1484
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1485
|
+
}
|
|
1486
|
+
});
|
|
1487
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1488
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/movie/${movieId}/recommendations?${stringifiedParams}` : `https://api.themoviedb.org/3/movie/${movieId}/recommendations`;
|
|
1489
|
+
};
|
|
1490
|
+
export const movieRecommendations = async (movieId, params, options) => {
|
|
1491
|
+
const res = await fetch(getMovieRecommendationsUrl(movieId, params), {
|
|
1492
|
+
...options,
|
|
1493
|
+
method: 'GET'
|
|
1494
|
+
});
|
|
1495
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1496
|
+
const data = body ? JSON.parse(body) : {};
|
|
1497
|
+
return data;
|
|
1498
|
+
};
|
|
1499
|
+
/**
|
|
1500
|
+
* Get the release dates and certifications for a movie.
|
|
1501
|
+
* @summary Release Dates
|
|
1502
|
+
*/
|
|
1503
|
+
export const getMovieReleaseDatesUrl = (movieId) => {
|
|
1504
|
+
return `https://api.themoviedb.org/3/movie/${movieId}/release_dates`;
|
|
1505
|
+
};
|
|
1506
|
+
export const movieReleaseDates = async (movieId, options) => {
|
|
1507
|
+
const res = await fetch(getMovieReleaseDatesUrl(movieId), {
|
|
1508
|
+
...options,
|
|
1509
|
+
method: 'GET'
|
|
1510
|
+
});
|
|
1511
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1512
|
+
const data = body ? JSON.parse(body) : {};
|
|
1513
|
+
return data;
|
|
1514
|
+
};
|
|
1515
|
+
/**
|
|
1516
|
+
* Get the user reviews for a movie.
|
|
1517
|
+
* @summary Reviews
|
|
1518
|
+
*/
|
|
1519
|
+
export const getMovieReviewsUrl = (movieId, params) => {
|
|
1520
|
+
const normalizedParams = new URLSearchParams();
|
|
1521
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1522
|
+
if (value !== undefined) {
|
|
1523
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1524
|
+
}
|
|
1525
|
+
});
|
|
1526
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1527
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/movie/${movieId}/reviews?${stringifiedParams}` : `https://api.themoviedb.org/3/movie/${movieId}/reviews`;
|
|
1528
|
+
};
|
|
1529
|
+
export const movieReviews = async (movieId, params, options) => {
|
|
1530
|
+
const res = await fetch(getMovieReviewsUrl(movieId, params), {
|
|
1531
|
+
...options,
|
|
1532
|
+
method: 'GET'
|
|
1533
|
+
});
|
|
1534
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1535
|
+
const data = body ? JSON.parse(body) : {};
|
|
1536
|
+
return data;
|
|
1537
|
+
};
|
|
1538
|
+
/**
|
|
1539
|
+
* Get the similar movies based on genres and keywords.
|
|
1540
|
+
* @summary Similar
|
|
1541
|
+
*/
|
|
1542
|
+
export const getMovieSimilarUrl = (movieId, params) => {
|
|
1543
|
+
const normalizedParams = new URLSearchParams();
|
|
1544
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1545
|
+
if (value !== undefined) {
|
|
1546
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1547
|
+
}
|
|
1548
|
+
});
|
|
1549
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1550
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/movie/${movieId}/similar?${stringifiedParams}` : `https://api.themoviedb.org/3/movie/${movieId}/similar`;
|
|
1551
|
+
};
|
|
1552
|
+
export const movieSimilar = async (movieId, params, options) => {
|
|
1553
|
+
const res = await fetch(getMovieSimilarUrl(movieId, params), {
|
|
1554
|
+
...options,
|
|
1555
|
+
method: 'GET'
|
|
1556
|
+
});
|
|
1557
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1558
|
+
const data = body ? JSON.parse(body) : {};
|
|
1559
|
+
return data;
|
|
1560
|
+
};
|
|
1561
|
+
/**
|
|
1562
|
+
* Get the translations for a movie.
|
|
1563
|
+
* @summary Translations
|
|
1564
|
+
*/
|
|
1565
|
+
export const getMovieTranslationsUrl = (movieId) => {
|
|
1566
|
+
return `https://api.themoviedb.org/3/movie/${movieId}/translations`;
|
|
1567
|
+
};
|
|
1568
|
+
export const movieTranslations = async (movieId, options) => {
|
|
1569
|
+
const res = await fetch(getMovieTranslationsUrl(movieId), {
|
|
1570
|
+
...options,
|
|
1571
|
+
method: 'GET'
|
|
1572
|
+
});
|
|
1573
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1574
|
+
const data = body ? JSON.parse(body) : {};
|
|
1575
|
+
return data;
|
|
1576
|
+
};
|
|
1577
|
+
/**
|
|
1578
|
+
* @summary Videos
|
|
1579
|
+
*/
|
|
1580
|
+
export const getMovieVideosUrl = (movieId, params) => {
|
|
1581
|
+
const normalizedParams = new URLSearchParams();
|
|
1582
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1583
|
+
if (value !== undefined) {
|
|
1584
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1585
|
+
}
|
|
1586
|
+
});
|
|
1587
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1588
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/movie/${movieId}/videos?${stringifiedParams}` : `https://api.themoviedb.org/3/movie/${movieId}/videos`;
|
|
1589
|
+
};
|
|
1590
|
+
export const movieVideos = async (movieId, params, options) => {
|
|
1591
|
+
const res = await fetch(getMovieVideosUrl(movieId, params), {
|
|
1592
|
+
...options,
|
|
1593
|
+
method: 'GET'
|
|
1594
|
+
});
|
|
1595
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1596
|
+
const data = body ? JSON.parse(body) : {};
|
|
1597
|
+
return data;
|
|
1598
|
+
};
|
|
1599
|
+
/**
|
|
1600
|
+
* Get the list of streaming providers we have for a movie.
|
|
1601
|
+
* @summary Watch Providers
|
|
1602
|
+
*/
|
|
1603
|
+
export const getMovieWatchProvidersUrl = (movieId) => {
|
|
1604
|
+
return `https://api.themoviedb.org/3/movie/${movieId}/watch/providers`;
|
|
1605
|
+
};
|
|
1606
|
+
export const movieWatchProviders = async (movieId, options) => {
|
|
1607
|
+
const res = await fetch(getMovieWatchProvidersUrl(movieId), {
|
|
1608
|
+
...options,
|
|
1609
|
+
method: 'GET'
|
|
1610
|
+
});
|
|
1611
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1612
|
+
const data = body ? JSON.parse(body) : {};
|
|
1613
|
+
return data;
|
|
1614
|
+
};
|
|
1615
|
+
/**
|
|
1616
|
+
* Rate a movie and save it to your rated list.
|
|
1617
|
+
* @summary Add Rating
|
|
1618
|
+
*/
|
|
1619
|
+
export const getMovieAddRatingUrl = (movieId, params) => {
|
|
1620
|
+
const normalizedParams = new URLSearchParams();
|
|
1621
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1622
|
+
if (value !== undefined) {
|
|
1623
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1624
|
+
}
|
|
1625
|
+
});
|
|
1626
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1627
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/movie/${movieId}/rating?${stringifiedParams}` : `https://api.themoviedb.org/3/movie/${movieId}/rating`;
|
|
1628
|
+
};
|
|
1629
|
+
export const movieAddRating = async (movieId, movieAddRatingBody, params, options) => {
|
|
1630
|
+
const res = await fetch(getMovieAddRatingUrl(movieId, params), {
|
|
1631
|
+
...options,
|
|
1632
|
+
method: 'POST',
|
|
1633
|
+
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
1634
|
+
body: JSON.stringify(movieAddRatingBody)
|
|
1635
|
+
});
|
|
1636
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1637
|
+
const data = body ? JSON.parse(body) : {};
|
|
1638
|
+
return data;
|
|
1639
|
+
};
|
|
1640
|
+
/**
|
|
1641
|
+
* Delete a user rating.
|
|
1642
|
+
* @summary Delete Rating
|
|
1643
|
+
*/
|
|
1644
|
+
export const getMovieDeleteRatingUrl = (movieId, params) => {
|
|
1645
|
+
const normalizedParams = new URLSearchParams();
|
|
1646
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1647
|
+
if (value !== undefined) {
|
|
1648
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1649
|
+
}
|
|
1650
|
+
});
|
|
1651
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1652
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/movie/${movieId}/rating?${stringifiedParams}` : `https://api.themoviedb.org/3/movie/${movieId}/rating`;
|
|
1653
|
+
};
|
|
1654
|
+
export const movieDeleteRating = async (movieId, params, options) => {
|
|
1655
|
+
const res = await fetch(getMovieDeleteRatingUrl(movieId, params), {
|
|
1656
|
+
...options,
|
|
1657
|
+
method: 'DELETE'
|
|
1658
|
+
});
|
|
1659
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1660
|
+
const data = body ? JSON.parse(body) : {};
|
|
1661
|
+
return data;
|
|
1662
|
+
};
|
|
1663
|
+
/**
|
|
1664
|
+
* @summary Details
|
|
1665
|
+
*/
|
|
1666
|
+
export const getNetworkDetailsUrl = (networkId) => {
|
|
1667
|
+
return `https://api.themoviedb.org/3/network/${networkId}`;
|
|
1668
|
+
};
|
|
1669
|
+
export const networkDetails = async (networkId, options) => {
|
|
1670
|
+
const res = await fetch(getNetworkDetailsUrl(networkId), {
|
|
1671
|
+
...options,
|
|
1672
|
+
method: 'GET'
|
|
1673
|
+
});
|
|
1674
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1675
|
+
const data = body ? JSON.parse(body) : {};
|
|
1676
|
+
return data;
|
|
1677
|
+
};
|
|
1678
|
+
/**
|
|
1679
|
+
* Get the alternative names of a network.
|
|
1680
|
+
* @summary Alternative Names
|
|
1681
|
+
*/
|
|
1682
|
+
export const getDetailsCopyUrl = (networkId) => {
|
|
1683
|
+
return `https://api.themoviedb.org/3/network/${networkId}/alternative_names`;
|
|
1684
|
+
};
|
|
1685
|
+
export const detailsCopy = async (networkId, options) => {
|
|
1686
|
+
const res = await fetch(getDetailsCopyUrl(networkId), {
|
|
1687
|
+
...options,
|
|
1688
|
+
method: 'GET'
|
|
1689
|
+
});
|
|
1690
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1691
|
+
const data = body ? JSON.parse(body) : {};
|
|
1692
|
+
return data;
|
|
1693
|
+
};
|
|
1694
|
+
/**
|
|
1695
|
+
* Get the TV network logos by id.
|
|
1696
|
+
* @summary Images
|
|
1697
|
+
*/
|
|
1698
|
+
export const getAlternativeNamesCopyUrl = (networkId) => {
|
|
1699
|
+
return `https://api.themoviedb.org/3/network/${networkId}/images`;
|
|
1700
|
+
};
|
|
1701
|
+
export const alternativeNamesCopy = async (networkId, options) => {
|
|
1702
|
+
const res = await fetch(getAlternativeNamesCopyUrl(networkId), {
|
|
1703
|
+
...options,
|
|
1704
|
+
method: 'GET'
|
|
1705
|
+
});
|
|
1706
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1707
|
+
const data = body ? JSON.parse(body) : {};
|
|
1708
|
+
return data;
|
|
1709
|
+
};
|
|
1710
|
+
/**
|
|
1711
|
+
* Get a list of people ordered by popularity.
|
|
1712
|
+
* @summary Popular
|
|
1713
|
+
*/
|
|
1714
|
+
export const getPersonPopularListUrl = (params) => {
|
|
1715
|
+
const normalizedParams = new URLSearchParams();
|
|
1716
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1717
|
+
if (value !== undefined) {
|
|
1718
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1719
|
+
}
|
|
1720
|
+
});
|
|
1721
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1722
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/person/popular?${stringifiedParams}` : `https://api.themoviedb.org/3/person/popular`;
|
|
1723
|
+
};
|
|
1724
|
+
export const personPopularList = async (params, options) => {
|
|
1725
|
+
const res = await fetch(getPersonPopularListUrl(params), {
|
|
1726
|
+
...options,
|
|
1727
|
+
method: 'GET'
|
|
1728
|
+
});
|
|
1729
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1730
|
+
const data = body ? JSON.parse(body) : {};
|
|
1731
|
+
return data;
|
|
1732
|
+
};
|
|
1733
|
+
/**
|
|
1734
|
+
* Query the top level details of a person.
|
|
1735
|
+
* @summary Details
|
|
1736
|
+
*/
|
|
1737
|
+
export const getPersonDetailsUrl = (personId, params) => {
|
|
1738
|
+
const normalizedParams = new URLSearchParams();
|
|
1739
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1740
|
+
if (value !== undefined) {
|
|
1741
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1742
|
+
}
|
|
1743
|
+
});
|
|
1744
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1745
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/person/${personId}?${stringifiedParams}` : `https://api.themoviedb.org/3/person/${personId}`;
|
|
1746
|
+
};
|
|
1747
|
+
export const personDetails = async (personId, params, options) => {
|
|
1748
|
+
const res = await fetch(getPersonDetailsUrl(personId, params), {
|
|
1749
|
+
...options,
|
|
1750
|
+
method: 'GET'
|
|
1751
|
+
});
|
|
1752
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1753
|
+
const data = body ? JSON.parse(body) : {};
|
|
1754
|
+
return data;
|
|
1755
|
+
};
|
|
1756
|
+
/**
|
|
1757
|
+
* Get the recent changes for a person.
|
|
1758
|
+
* @summary Changes
|
|
1759
|
+
*/
|
|
1760
|
+
export const getPersonChangesUrl = (personId, params) => {
|
|
1761
|
+
const normalizedParams = new URLSearchParams();
|
|
1762
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1763
|
+
if (value !== undefined) {
|
|
1764
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1765
|
+
}
|
|
1766
|
+
});
|
|
1767
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1768
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/person/${personId}/changes?${stringifiedParams}` : `https://api.themoviedb.org/3/person/${personId}/changes`;
|
|
1769
|
+
};
|
|
1770
|
+
export const personChanges = async (personId, params, options) => {
|
|
1771
|
+
const res = await fetch(getPersonChangesUrl(personId, params), {
|
|
1772
|
+
...options,
|
|
1773
|
+
method: 'GET'
|
|
1774
|
+
});
|
|
1775
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1776
|
+
const data = body ? JSON.parse(body) : {};
|
|
1777
|
+
return data;
|
|
1778
|
+
};
|
|
1779
|
+
/**
|
|
1780
|
+
* Get the combined movie and TV credits that belong to a person.
|
|
1781
|
+
* @summary Combined Credits
|
|
1782
|
+
*/
|
|
1783
|
+
export const getPersonCombinedCreditsUrl = (personId, params) => {
|
|
1784
|
+
const normalizedParams = new URLSearchParams();
|
|
1785
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1786
|
+
if (value !== undefined) {
|
|
1787
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1788
|
+
}
|
|
1789
|
+
});
|
|
1790
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1791
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/person/${personId}/combined_credits?${stringifiedParams}` : `https://api.themoviedb.org/3/person/${personId}/combined_credits`;
|
|
1792
|
+
};
|
|
1793
|
+
export const personCombinedCredits = async (personId, params, options) => {
|
|
1794
|
+
const res = await fetch(getPersonCombinedCreditsUrl(personId, params), {
|
|
1795
|
+
...options,
|
|
1796
|
+
method: 'GET'
|
|
1797
|
+
});
|
|
1798
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1799
|
+
const data = body ? JSON.parse(body) : {};
|
|
1800
|
+
return data;
|
|
1801
|
+
};
|
|
1802
|
+
/**
|
|
1803
|
+
* Get the external ID's that belong to a person.
|
|
1804
|
+
* @summary External IDs
|
|
1805
|
+
*/
|
|
1806
|
+
export const getPersonExternalIdsUrl = (personId) => {
|
|
1807
|
+
return `https://api.themoviedb.org/3/person/${personId}/external_ids`;
|
|
1808
|
+
};
|
|
1809
|
+
export const personExternalIds = async (personId, options) => {
|
|
1810
|
+
const res = await fetch(getPersonExternalIdsUrl(personId), {
|
|
1811
|
+
...options,
|
|
1812
|
+
method: 'GET'
|
|
1813
|
+
});
|
|
1814
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1815
|
+
const data = body ? JSON.parse(body) : {};
|
|
1816
|
+
return data;
|
|
1817
|
+
};
|
|
1818
|
+
/**
|
|
1819
|
+
* Get the profile images that belong to a person.
|
|
1820
|
+
* @summary Images
|
|
1821
|
+
*/
|
|
1822
|
+
export const getPersonImagesUrl = (personId) => {
|
|
1823
|
+
return `https://api.themoviedb.org/3/person/${personId}/images`;
|
|
1824
|
+
};
|
|
1825
|
+
export const personImages = async (personId, options) => {
|
|
1826
|
+
const res = await fetch(getPersonImagesUrl(personId), {
|
|
1827
|
+
...options,
|
|
1828
|
+
method: 'GET'
|
|
1829
|
+
});
|
|
1830
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1831
|
+
const data = body ? JSON.parse(body) : {};
|
|
1832
|
+
return data;
|
|
1833
|
+
};
|
|
1834
|
+
/**
|
|
1835
|
+
* Get the newest created person. This is a live response and will continuously change.
|
|
1836
|
+
* @summary Latest
|
|
1837
|
+
*/
|
|
1838
|
+
export const getPersonLatestIdUrl = () => {
|
|
1839
|
+
return `https://api.themoviedb.org/3/person/latest`;
|
|
1840
|
+
};
|
|
1841
|
+
export const personLatestId = async (options) => {
|
|
1842
|
+
const res = await fetch(getPersonLatestIdUrl(), {
|
|
1843
|
+
...options,
|
|
1844
|
+
method: 'GET'
|
|
1845
|
+
});
|
|
1846
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1847
|
+
const data = body ? JSON.parse(body) : {};
|
|
1848
|
+
return data;
|
|
1849
|
+
};
|
|
1850
|
+
/**
|
|
1851
|
+
* Get the movie credits for a person.
|
|
1852
|
+
* @summary Movie Credits
|
|
1853
|
+
*/
|
|
1854
|
+
export const getPersonMovieCreditsUrl = (personId, params) => {
|
|
1855
|
+
const normalizedParams = new URLSearchParams();
|
|
1856
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1857
|
+
if (value !== undefined) {
|
|
1858
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1859
|
+
}
|
|
1860
|
+
});
|
|
1861
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1862
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/person/${personId}/movie_credits?${stringifiedParams}` : `https://api.themoviedb.org/3/person/${personId}/movie_credits`;
|
|
1863
|
+
};
|
|
1864
|
+
export const personMovieCredits = async (personId, params, options) => {
|
|
1865
|
+
const res = await fetch(getPersonMovieCreditsUrl(personId, params), {
|
|
1866
|
+
...options,
|
|
1867
|
+
method: 'GET'
|
|
1868
|
+
});
|
|
1869
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1870
|
+
const data = body ? JSON.parse(body) : {};
|
|
1871
|
+
return data;
|
|
1872
|
+
};
|
|
1873
|
+
/**
|
|
1874
|
+
* Get the TV credits that belong to a person.
|
|
1875
|
+
* @summary TV Credits
|
|
1876
|
+
*/
|
|
1877
|
+
export const getPersonTvCreditsUrl = (personId, params) => {
|
|
1878
|
+
const normalizedParams = new URLSearchParams();
|
|
1879
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1880
|
+
if (value !== undefined) {
|
|
1881
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1882
|
+
}
|
|
1883
|
+
});
|
|
1884
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1885
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/person/${personId}/tv_credits?${stringifiedParams}` : `https://api.themoviedb.org/3/person/${personId}/tv_credits`;
|
|
1886
|
+
};
|
|
1887
|
+
export const personTvCredits = async (personId, params, options) => {
|
|
1888
|
+
const res = await fetch(getPersonTvCreditsUrl(personId, params), {
|
|
1889
|
+
...options,
|
|
1890
|
+
method: 'GET'
|
|
1891
|
+
});
|
|
1892
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1893
|
+
const data = body ? JSON.parse(body) : {};
|
|
1894
|
+
return data;
|
|
1895
|
+
};
|
|
1896
|
+
/**
|
|
1897
|
+
* Get the tagged images for a person.
|
|
1898
|
+
* @summary Tagged Images
|
|
1899
|
+
*/
|
|
1900
|
+
export const getPersonTaggedImagesUrl = (personId, params) => {
|
|
1901
|
+
const normalizedParams = new URLSearchParams();
|
|
1902
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1903
|
+
if (value !== undefined) {
|
|
1904
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1905
|
+
}
|
|
1906
|
+
});
|
|
1907
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1908
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/person/${personId}/tagged_images?${stringifiedParams}` : `https://api.themoviedb.org/3/person/${personId}/tagged_images`;
|
|
1909
|
+
};
|
|
1910
|
+
export const personTaggedImages = async (personId, params, options) => {
|
|
1911
|
+
const res = await fetch(getPersonTaggedImagesUrl(personId, params), {
|
|
1912
|
+
...options,
|
|
1913
|
+
method: 'GET'
|
|
1914
|
+
});
|
|
1915
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1916
|
+
const data = body ? JSON.parse(body) : {};
|
|
1917
|
+
return data;
|
|
1918
|
+
};
|
|
1919
|
+
/**
|
|
1920
|
+
* Get the translations that belong to a person.
|
|
1921
|
+
* @summary Translations
|
|
1922
|
+
*/
|
|
1923
|
+
export const getTranslationsUrl = (personId) => {
|
|
1924
|
+
return `https://api.themoviedb.org/3/person/${personId}/translations`;
|
|
1925
|
+
};
|
|
1926
|
+
export const translations = async (personId, options) => {
|
|
1927
|
+
const res = await fetch(getTranslationsUrl(personId), {
|
|
1928
|
+
...options,
|
|
1929
|
+
method: 'GET'
|
|
1930
|
+
});
|
|
1931
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1932
|
+
const data = body ? JSON.parse(body) : {};
|
|
1933
|
+
return data;
|
|
1934
|
+
};
|
|
1935
|
+
/**
|
|
1936
|
+
* Retrieve the details of a movie or TV show review.
|
|
1937
|
+
* @summary Details
|
|
1938
|
+
*/
|
|
1939
|
+
export const getReviewDetailsUrl = (reviewId) => {
|
|
1940
|
+
return `https://api.themoviedb.org/3/review/${reviewId}`;
|
|
1941
|
+
};
|
|
1942
|
+
export const reviewDetails = async (reviewId, options) => {
|
|
1943
|
+
const res = await fetch(getReviewDetailsUrl(reviewId), {
|
|
1944
|
+
...options,
|
|
1945
|
+
method: 'GET'
|
|
1946
|
+
});
|
|
1947
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1948
|
+
const data = body ? JSON.parse(body) : {};
|
|
1949
|
+
return data;
|
|
1950
|
+
};
|
|
1951
|
+
/**
|
|
1952
|
+
* Search for collections by their original, translated and alternative names.
|
|
1953
|
+
* @summary Collection
|
|
1954
|
+
*/
|
|
1955
|
+
export const getSearchCollectionUrl = (params) => {
|
|
1956
|
+
const normalizedParams = new URLSearchParams();
|
|
1957
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1958
|
+
if (value !== undefined) {
|
|
1959
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1960
|
+
}
|
|
1961
|
+
});
|
|
1962
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1963
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/search/collection?${stringifiedParams}` : `https://api.themoviedb.org/3/search/collection`;
|
|
1964
|
+
};
|
|
1965
|
+
export const searchCollection = async (params, options) => {
|
|
1966
|
+
const res = await fetch(getSearchCollectionUrl(params), {
|
|
1967
|
+
...options,
|
|
1968
|
+
method: 'GET'
|
|
1969
|
+
});
|
|
1970
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1971
|
+
const data = body ? JSON.parse(body) : {};
|
|
1972
|
+
return data;
|
|
1973
|
+
};
|
|
1974
|
+
/**
|
|
1975
|
+
* Search for companies by their original and alternative names.
|
|
1976
|
+
* @summary Company
|
|
1977
|
+
*/
|
|
1978
|
+
export const getSearchCompanyUrl = (params) => {
|
|
1979
|
+
const normalizedParams = new URLSearchParams();
|
|
1980
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1981
|
+
if (value !== undefined) {
|
|
1982
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
1983
|
+
}
|
|
1984
|
+
});
|
|
1985
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1986
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/search/company?${stringifiedParams}` : `https://api.themoviedb.org/3/search/company`;
|
|
1987
|
+
};
|
|
1988
|
+
export const searchCompany = async (params, options) => {
|
|
1989
|
+
const res = await fetch(getSearchCompanyUrl(params), {
|
|
1990
|
+
...options,
|
|
1991
|
+
method: 'GET'
|
|
1992
|
+
});
|
|
1993
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
1994
|
+
const data = body ? JSON.parse(body) : {};
|
|
1995
|
+
return data;
|
|
1996
|
+
};
|
|
1997
|
+
/**
|
|
1998
|
+
* Search for keywords by their name.
|
|
1999
|
+
* @summary Keyword
|
|
2000
|
+
*/
|
|
2001
|
+
export const getSearchKeywordUrl = (params) => {
|
|
2002
|
+
const normalizedParams = new URLSearchParams();
|
|
2003
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2004
|
+
if (value !== undefined) {
|
|
2005
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2006
|
+
}
|
|
2007
|
+
});
|
|
2008
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2009
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/search/keyword?${stringifiedParams}` : `https://api.themoviedb.org/3/search/keyword`;
|
|
2010
|
+
};
|
|
2011
|
+
export const searchKeyword = async (params, options) => {
|
|
2012
|
+
const res = await fetch(getSearchKeywordUrl(params), {
|
|
2013
|
+
...options,
|
|
2014
|
+
method: 'GET'
|
|
2015
|
+
});
|
|
2016
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2017
|
+
const data = body ? JSON.parse(body) : {};
|
|
2018
|
+
return data;
|
|
2019
|
+
};
|
|
2020
|
+
/**
|
|
2021
|
+
* Search for movies by their original, translated and alternative titles.
|
|
2022
|
+
* @summary Movie
|
|
2023
|
+
*/
|
|
2024
|
+
export const getSearchMovieUrl = (params) => {
|
|
2025
|
+
const normalizedParams = new URLSearchParams();
|
|
2026
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2027
|
+
if (value !== undefined) {
|
|
2028
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2029
|
+
}
|
|
2030
|
+
});
|
|
2031
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2032
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/search/movie?${stringifiedParams}` : `https://api.themoviedb.org/3/search/movie`;
|
|
2033
|
+
};
|
|
2034
|
+
export const searchMovie = async (params, options) => {
|
|
2035
|
+
const res = await fetch(getSearchMovieUrl(params), {
|
|
2036
|
+
...options,
|
|
2037
|
+
method: 'GET'
|
|
2038
|
+
});
|
|
2039
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2040
|
+
const data = body ? JSON.parse(body) : {};
|
|
2041
|
+
return data;
|
|
2042
|
+
};
|
|
2043
|
+
/**
|
|
2044
|
+
* Use multi search when you want to search for movies, TV shows and people in a single request.
|
|
2045
|
+
* @summary Multi
|
|
2046
|
+
*/
|
|
2047
|
+
export const getSearchMultiUrl = (params) => {
|
|
2048
|
+
const normalizedParams = new URLSearchParams();
|
|
2049
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2050
|
+
if (value !== undefined) {
|
|
2051
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2052
|
+
}
|
|
2053
|
+
});
|
|
2054
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2055
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/search/multi?${stringifiedParams}` : `https://api.themoviedb.org/3/search/multi`;
|
|
2056
|
+
};
|
|
2057
|
+
export const searchMulti = async (params, options) => {
|
|
2058
|
+
const res = await fetch(getSearchMultiUrl(params), {
|
|
2059
|
+
...options,
|
|
2060
|
+
method: 'GET'
|
|
2061
|
+
});
|
|
2062
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2063
|
+
const data = body ? JSON.parse(body) : {};
|
|
2064
|
+
return data;
|
|
2065
|
+
};
|
|
2066
|
+
/**
|
|
2067
|
+
* Search for people by their name and also known as names.
|
|
2068
|
+
* @summary Person
|
|
2069
|
+
*/
|
|
2070
|
+
export const getSearchPersonUrl = (params) => {
|
|
2071
|
+
const normalizedParams = new URLSearchParams();
|
|
2072
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2073
|
+
if (value !== undefined) {
|
|
2074
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2075
|
+
}
|
|
2076
|
+
});
|
|
2077
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2078
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/search/person?${stringifiedParams}` : `https://api.themoviedb.org/3/search/person`;
|
|
2079
|
+
};
|
|
2080
|
+
export const searchPerson = async (params, options) => {
|
|
2081
|
+
const res = await fetch(getSearchPersonUrl(params), {
|
|
2082
|
+
...options,
|
|
2083
|
+
method: 'GET'
|
|
2084
|
+
});
|
|
2085
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2086
|
+
const data = body ? JSON.parse(body) : {};
|
|
2087
|
+
return data;
|
|
2088
|
+
};
|
|
2089
|
+
/**
|
|
2090
|
+
* Search for TV shows by their original, translated and also known as names.
|
|
2091
|
+
* @summary TV
|
|
2092
|
+
*/
|
|
2093
|
+
export const getSearchTvUrl = (params) => {
|
|
2094
|
+
const normalizedParams = new URLSearchParams();
|
|
2095
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2096
|
+
if (value !== undefined) {
|
|
2097
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2098
|
+
}
|
|
2099
|
+
});
|
|
2100
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2101
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/search/tv?${stringifiedParams}` : `https://api.themoviedb.org/3/search/tv`;
|
|
2102
|
+
};
|
|
2103
|
+
export const searchTv = async (params, options) => {
|
|
2104
|
+
const res = await fetch(getSearchTvUrl(params), {
|
|
2105
|
+
...options,
|
|
2106
|
+
method: 'GET'
|
|
2107
|
+
});
|
|
2108
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2109
|
+
const data = body ? JSON.parse(body) : {};
|
|
2110
|
+
return data;
|
|
2111
|
+
};
|
|
2112
|
+
/**
|
|
2113
|
+
* Get the trending movies, TV shows and people.
|
|
2114
|
+
* @summary All
|
|
2115
|
+
*/
|
|
2116
|
+
export const getTrendingAllUrl = (params, timeWindow = 'day') => {
|
|
2117
|
+
const normalizedParams = new URLSearchParams();
|
|
2118
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2119
|
+
if (value !== undefined) {
|
|
2120
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2121
|
+
}
|
|
2122
|
+
});
|
|
2123
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2124
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/trending/all/${timeWindow}?${stringifiedParams}` : `https://api.themoviedb.org/3/trending/all/${timeWindow}`;
|
|
2125
|
+
};
|
|
2126
|
+
export const trendingAll = async (params, timeWindow = 'day', options) => {
|
|
2127
|
+
const res = await fetch(getTrendingAllUrl(params, timeWindow), {
|
|
2128
|
+
...options,
|
|
2129
|
+
method: 'GET'
|
|
2130
|
+
});
|
|
2131
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2132
|
+
const data = body ? JSON.parse(body) : {};
|
|
2133
|
+
return data;
|
|
2134
|
+
};
|
|
2135
|
+
/**
|
|
2136
|
+
* Get the trending movies on TMDB.
|
|
2137
|
+
* @summary Movies
|
|
2138
|
+
*/
|
|
2139
|
+
export const getTrendingMoviesUrl = (params, timeWindow = 'day') => {
|
|
2140
|
+
const normalizedParams = new URLSearchParams();
|
|
2141
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2142
|
+
if (value !== undefined) {
|
|
2143
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2144
|
+
}
|
|
2145
|
+
});
|
|
2146
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2147
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/trending/movie/${timeWindow}?${stringifiedParams}` : `https://api.themoviedb.org/3/trending/movie/${timeWindow}`;
|
|
2148
|
+
};
|
|
2149
|
+
export const trendingMovies = async (params, timeWindow = 'day', options) => {
|
|
2150
|
+
const res = await fetch(getTrendingMoviesUrl(params, timeWindow), {
|
|
2151
|
+
...options,
|
|
2152
|
+
method: 'GET'
|
|
2153
|
+
});
|
|
2154
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2155
|
+
const data = body ? JSON.parse(body) : {};
|
|
2156
|
+
return data;
|
|
2157
|
+
};
|
|
2158
|
+
/**
|
|
2159
|
+
* Get the trending people on TMDB.
|
|
2160
|
+
* @summary People
|
|
2161
|
+
*/
|
|
2162
|
+
export const getTrendingPeopleUrl = (params, timeWindow = 'day') => {
|
|
2163
|
+
const normalizedParams = new URLSearchParams();
|
|
2164
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2165
|
+
if (value !== undefined) {
|
|
2166
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2167
|
+
}
|
|
2168
|
+
});
|
|
2169
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2170
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/trending/person/${timeWindow}?${stringifiedParams}` : `https://api.themoviedb.org/3/trending/person/${timeWindow}`;
|
|
2171
|
+
};
|
|
2172
|
+
export const trendingPeople = async (params, timeWindow = 'day', options) => {
|
|
2173
|
+
const res = await fetch(getTrendingPeopleUrl(params, timeWindow), {
|
|
2174
|
+
...options,
|
|
2175
|
+
method: 'GET'
|
|
2176
|
+
});
|
|
2177
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2178
|
+
const data = body ? JSON.parse(body) : {};
|
|
2179
|
+
return data;
|
|
2180
|
+
};
|
|
2181
|
+
/**
|
|
2182
|
+
* Get the trending TV shows on TMDB.
|
|
2183
|
+
* @summary TV
|
|
2184
|
+
*/
|
|
2185
|
+
export const getTrendingTvUrl = (params, timeWindow = 'day') => {
|
|
2186
|
+
const normalizedParams = new URLSearchParams();
|
|
2187
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2188
|
+
if (value !== undefined) {
|
|
2189
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2190
|
+
}
|
|
2191
|
+
});
|
|
2192
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2193
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/trending/tv/${timeWindow}?${stringifiedParams}` : `https://api.themoviedb.org/3/trending/tv/${timeWindow}`;
|
|
2194
|
+
};
|
|
2195
|
+
export const trendingTv = async (params, timeWindow = 'day', options) => {
|
|
2196
|
+
const res = await fetch(getTrendingTvUrl(params, timeWindow), {
|
|
2197
|
+
...options,
|
|
2198
|
+
method: 'GET'
|
|
2199
|
+
});
|
|
2200
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2201
|
+
const data = body ? JSON.parse(body) : {};
|
|
2202
|
+
return data;
|
|
2203
|
+
};
|
|
2204
|
+
/**
|
|
2205
|
+
* Get a list of TV shows airing today.
|
|
2206
|
+
* @summary Airing Today
|
|
2207
|
+
*/
|
|
2208
|
+
export const getTvSeriesAiringTodayListUrl = (params) => {
|
|
2209
|
+
const normalizedParams = new URLSearchParams();
|
|
2210
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2211
|
+
if (value !== undefined) {
|
|
2212
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2213
|
+
}
|
|
2214
|
+
});
|
|
2215
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2216
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/airing_today?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/airing_today`;
|
|
2217
|
+
};
|
|
2218
|
+
export const tvSeriesAiringTodayList = async (params, options) => {
|
|
2219
|
+
const res = await fetch(getTvSeriesAiringTodayListUrl(params), {
|
|
2220
|
+
...options,
|
|
2221
|
+
method: 'GET'
|
|
2222
|
+
});
|
|
2223
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2224
|
+
const data = body ? JSON.parse(body) : {};
|
|
2225
|
+
return data;
|
|
2226
|
+
};
|
|
2227
|
+
/**
|
|
2228
|
+
* Get a list of TV shows that air in the next 7 days.
|
|
2229
|
+
* @summary On The Air
|
|
2230
|
+
*/
|
|
2231
|
+
export const getTvSeriesOnTheAirListUrl = (params) => {
|
|
2232
|
+
const normalizedParams = new URLSearchParams();
|
|
2233
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2234
|
+
if (value !== undefined) {
|
|
2235
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2236
|
+
}
|
|
2237
|
+
});
|
|
2238
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2239
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/on_the_air?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/on_the_air`;
|
|
2240
|
+
};
|
|
2241
|
+
export const tvSeriesOnTheAirList = async (params, options) => {
|
|
2242
|
+
const res = await fetch(getTvSeriesOnTheAirListUrl(params), {
|
|
2243
|
+
...options,
|
|
2244
|
+
method: 'GET'
|
|
2245
|
+
});
|
|
2246
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2247
|
+
const data = body ? JSON.parse(body) : {};
|
|
2248
|
+
return data;
|
|
2249
|
+
};
|
|
2250
|
+
/**
|
|
2251
|
+
* Get a list of TV shows ordered by popularity.
|
|
2252
|
+
* @summary Popular
|
|
2253
|
+
*/
|
|
2254
|
+
export const getTvSeriesPopularListUrl = (params) => {
|
|
2255
|
+
const normalizedParams = new URLSearchParams();
|
|
2256
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2257
|
+
if (value !== undefined) {
|
|
2258
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2259
|
+
}
|
|
2260
|
+
});
|
|
2261
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2262
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/popular?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/popular`;
|
|
2263
|
+
};
|
|
2264
|
+
export const tvSeriesPopularList = async (params, options) => {
|
|
2265
|
+
const res = await fetch(getTvSeriesPopularListUrl(params), {
|
|
2266
|
+
...options,
|
|
2267
|
+
method: 'GET'
|
|
2268
|
+
});
|
|
2269
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2270
|
+
const data = body ? JSON.parse(body) : {};
|
|
2271
|
+
return data;
|
|
2272
|
+
};
|
|
2273
|
+
/**
|
|
2274
|
+
* Get a list of TV shows ordered by rating.
|
|
2275
|
+
* @summary Top Rated
|
|
2276
|
+
*/
|
|
2277
|
+
export const getTvSeriesTopRatedListUrl = (params) => {
|
|
2278
|
+
const normalizedParams = new URLSearchParams();
|
|
2279
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2280
|
+
if (value !== undefined) {
|
|
2281
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2282
|
+
}
|
|
2283
|
+
});
|
|
2284
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2285
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/top_rated?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/top_rated`;
|
|
2286
|
+
};
|
|
2287
|
+
export const tvSeriesTopRatedList = async (params, options) => {
|
|
2288
|
+
const res = await fetch(getTvSeriesTopRatedListUrl(params), {
|
|
2289
|
+
...options,
|
|
2290
|
+
method: 'GET'
|
|
2291
|
+
});
|
|
2292
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2293
|
+
const data = body ? JSON.parse(body) : {};
|
|
2294
|
+
return data;
|
|
2295
|
+
};
|
|
2296
|
+
/**
|
|
2297
|
+
* Get the details of a TV show.
|
|
2298
|
+
* @summary Details
|
|
2299
|
+
*/
|
|
2300
|
+
export const getTvSeriesDetailsUrl = (seriesId, params) => {
|
|
2301
|
+
const normalizedParams = new URLSearchParams();
|
|
2302
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2303
|
+
if (value !== undefined) {
|
|
2304
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2305
|
+
}
|
|
2306
|
+
});
|
|
2307
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2308
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}`;
|
|
2309
|
+
};
|
|
2310
|
+
export const tvSeriesDetails = async (seriesId, params, options) => {
|
|
2311
|
+
const res = await fetch(getTvSeriesDetailsUrl(seriesId, params), {
|
|
2312
|
+
...options,
|
|
2313
|
+
method: 'GET'
|
|
2314
|
+
});
|
|
2315
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2316
|
+
const data = body ? JSON.parse(body) : {};
|
|
2317
|
+
return data;
|
|
2318
|
+
};
|
|
2319
|
+
/**
|
|
2320
|
+
* Get the rating, watchlist and favourite status.
|
|
2321
|
+
* @summary Account States
|
|
2322
|
+
*/
|
|
2323
|
+
export const getTvSeriesAccountStatesUrl = (seriesId, params) => {
|
|
2324
|
+
const normalizedParams = new URLSearchParams();
|
|
2325
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2326
|
+
if (value !== undefined) {
|
|
2327
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2328
|
+
}
|
|
2329
|
+
});
|
|
2330
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2331
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/account_states?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/account_states`;
|
|
2332
|
+
};
|
|
2333
|
+
export const tvSeriesAccountStates = async (seriesId, params, options) => {
|
|
2334
|
+
const res = await fetch(getTvSeriesAccountStatesUrl(seriesId, params), {
|
|
2335
|
+
...options,
|
|
2336
|
+
method: 'GET'
|
|
2337
|
+
});
|
|
2338
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2339
|
+
const data = body ? JSON.parse(body) : {};
|
|
2340
|
+
return data;
|
|
2341
|
+
};
|
|
2342
|
+
/**
|
|
2343
|
+
* Get the aggregate credits (cast and crew) that have been added to a TV show.
|
|
2344
|
+
* @summary Aggregate Credits
|
|
2345
|
+
*/
|
|
2346
|
+
export const getTvSeriesAggregateCreditsUrl = (seriesId, params) => {
|
|
2347
|
+
const normalizedParams = new URLSearchParams();
|
|
2348
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2349
|
+
if (value !== undefined) {
|
|
2350
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2351
|
+
}
|
|
2352
|
+
});
|
|
2353
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2354
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/aggregate_credits?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/aggregate_credits`;
|
|
2355
|
+
};
|
|
2356
|
+
export const tvSeriesAggregateCredits = async (seriesId, params, options) => {
|
|
2357
|
+
const res = await fetch(getTvSeriesAggregateCreditsUrl(seriesId, params), {
|
|
2358
|
+
...options,
|
|
2359
|
+
method: 'GET'
|
|
2360
|
+
});
|
|
2361
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2362
|
+
const data = body ? JSON.parse(body) : {};
|
|
2363
|
+
return data;
|
|
2364
|
+
};
|
|
2365
|
+
/**
|
|
2366
|
+
* Get the alternative titles that have been added to a TV show.
|
|
2367
|
+
* @summary Alternative Titles
|
|
2368
|
+
*/
|
|
2369
|
+
export const getTvSeriesAlternativeTitlesUrl = (seriesId) => {
|
|
2370
|
+
return `https://api.themoviedb.org/3/tv/${seriesId}/alternative_titles`;
|
|
2371
|
+
};
|
|
2372
|
+
export const tvSeriesAlternativeTitles = async (seriesId, options) => {
|
|
2373
|
+
const res = await fetch(getTvSeriesAlternativeTitlesUrl(seriesId), {
|
|
2374
|
+
...options,
|
|
2375
|
+
method: 'GET'
|
|
2376
|
+
});
|
|
2377
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2378
|
+
const data = body ? JSON.parse(body) : {};
|
|
2379
|
+
return data;
|
|
2380
|
+
};
|
|
2381
|
+
/**
|
|
2382
|
+
* Get the recent changes for a TV show.
|
|
2383
|
+
* @summary Changes
|
|
2384
|
+
*/
|
|
2385
|
+
export const getTvSeriesChangesUrl = (seriesId, params) => {
|
|
2386
|
+
const normalizedParams = new URLSearchParams();
|
|
2387
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2388
|
+
if (value !== undefined) {
|
|
2389
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2390
|
+
}
|
|
2391
|
+
});
|
|
2392
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2393
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/changes?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/changes`;
|
|
2394
|
+
};
|
|
2395
|
+
export const tvSeriesChanges = async (seriesId, params, options) => {
|
|
2396
|
+
const res = await fetch(getTvSeriesChangesUrl(seriesId, params), {
|
|
2397
|
+
...options,
|
|
2398
|
+
method: 'GET'
|
|
2399
|
+
});
|
|
2400
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2401
|
+
const data = body ? JSON.parse(body) : {};
|
|
2402
|
+
return data;
|
|
2403
|
+
};
|
|
2404
|
+
/**
|
|
2405
|
+
* Get the content ratings that have been added to a TV show.
|
|
2406
|
+
* @summary Content Ratings
|
|
2407
|
+
*/
|
|
2408
|
+
export const getTvSeriesContentRatingsUrl = (seriesId) => {
|
|
2409
|
+
return `https://api.themoviedb.org/3/tv/${seriesId}/content_ratings`;
|
|
2410
|
+
};
|
|
2411
|
+
export const tvSeriesContentRatings = async (seriesId, options) => {
|
|
2412
|
+
const res = await fetch(getTvSeriesContentRatingsUrl(seriesId), {
|
|
2413
|
+
...options,
|
|
2414
|
+
method: 'GET'
|
|
2415
|
+
});
|
|
2416
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2417
|
+
const data = body ? JSON.parse(body) : {};
|
|
2418
|
+
return data;
|
|
2419
|
+
};
|
|
2420
|
+
/**
|
|
2421
|
+
* Get the latest season credits of a TV show.
|
|
2422
|
+
* @summary Credits
|
|
2423
|
+
*/
|
|
2424
|
+
export const getTvSeriesCreditsUrl = (seriesId, params) => {
|
|
2425
|
+
const normalizedParams = new URLSearchParams();
|
|
2426
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2427
|
+
if (value !== undefined) {
|
|
2428
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2429
|
+
}
|
|
2430
|
+
});
|
|
2431
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2432
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/credits?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/credits`;
|
|
2433
|
+
};
|
|
2434
|
+
export const tvSeriesCredits = async (seriesId, params, options) => {
|
|
2435
|
+
const res = await fetch(getTvSeriesCreditsUrl(seriesId, params), {
|
|
2436
|
+
...options,
|
|
2437
|
+
method: 'GET'
|
|
2438
|
+
});
|
|
2439
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2440
|
+
const data = body ? JSON.parse(body) : {};
|
|
2441
|
+
return data;
|
|
2442
|
+
};
|
|
2443
|
+
/**
|
|
2444
|
+
* Get the episode groups that have been added to a TV show.
|
|
2445
|
+
* @summary Episode Groups
|
|
2446
|
+
*/
|
|
2447
|
+
export const getTvSeriesEpisodeGroupsUrl = (seriesId) => {
|
|
2448
|
+
return `https://api.themoviedb.org/3/tv/${seriesId}/episode_groups`;
|
|
2449
|
+
};
|
|
2450
|
+
export const tvSeriesEpisodeGroups = async (seriesId, options) => {
|
|
2451
|
+
const res = await fetch(getTvSeriesEpisodeGroupsUrl(seriesId), {
|
|
2452
|
+
...options,
|
|
2453
|
+
method: 'GET'
|
|
2454
|
+
});
|
|
2455
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2456
|
+
const data = body ? JSON.parse(body) : {};
|
|
2457
|
+
return data;
|
|
2458
|
+
};
|
|
2459
|
+
/**
|
|
2460
|
+
* Get a list of external IDs that have been added to a TV show.
|
|
2461
|
+
* @summary External IDs
|
|
2462
|
+
*/
|
|
2463
|
+
export const getTvSeriesExternalIdsUrl = (seriesId) => {
|
|
2464
|
+
return `https://api.themoviedb.org/3/tv/${seriesId}/external_ids`;
|
|
2465
|
+
};
|
|
2466
|
+
export const tvSeriesExternalIds = async (seriesId, options) => {
|
|
2467
|
+
const res = await fetch(getTvSeriesExternalIdsUrl(seriesId), {
|
|
2468
|
+
...options,
|
|
2469
|
+
method: 'GET'
|
|
2470
|
+
});
|
|
2471
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2472
|
+
const data = body ? JSON.parse(body) : {};
|
|
2473
|
+
return data;
|
|
2474
|
+
};
|
|
2475
|
+
/**
|
|
2476
|
+
* Get the images that belong to a TV series.
|
|
2477
|
+
* @summary Images
|
|
2478
|
+
*/
|
|
2479
|
+
export const getTvSeriesImagesUrl = (seriesId, params) => {
|
|
2480
|
+
const normalizedParams = new URLSearchParams();
|
|
2481
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2482
|
+
if (value !== undefined) {
|
|
2483
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2484
|
+
}
|
|
2485
|
+
});
|
|
2486
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2487
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/images?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/images`;
|
|
2488
|
+
};
|
|
2489
|
+
export const tvSeriesImages = async (seriesId, params, options) => {
|
|
2490
|
+
const res = await fetch(getTvSeriesImagesUrl(seriesId, params), {
|
|
2491
|
+
...options,
|
|
2492
|
+
method: 'GET'
|
|
2493
|
+
});
|
|
2494
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2495
|
+
const data = body ? JSON.parse(body) : {};
|
|
2496
|
+
return data;
|
|
2497
|
+
};
|
|
2498
|
+
/**
|
|
2499
|
+
* Get a list of keywords that have been added to a TV show.
|
|
2500
|
+
* @summary Keywords
|
|
2501
|
+
*/
|
|
2502
|
+
export const getTvSeriesKeywordsUrl = (seriesId) => {
|
|
2503
|
+
return `https://api.themoviedb.org/3/tv/${seriesId}/keywords`;
|
|
2504
|
+
};
|
|
2505
|
+
export const tvSeriesKeywords = async (seriesId, options) => {
|
|
2506
|
+
const res = await fetch(getTvSeriesKeywordsUrl(seriesId), {
|
|
2507
|
+
...options,
|
|
2508
|
+
method: 'GET'
|
|
2509
|
+
});
|
|
2510
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2511
|
+
const data = body ? JSON.parse(body) : {};
|
|
2512
|
+
return data;
|
|
2513
|
+
};
|
|
2514
|
+
/**
|
|
2515
|
+
* Get the newest TV show ID.
|
|
2516
|
+
* @summary Latest
|
|
2517
|
+
*/
|
|
2518
|
+
export const getTvSeriesLatestIdUrl = () => {
|
|
2519
|
+
return `https://api.themoviedb.org/3/tv/latest`;
|
|
2520
|
+
};
|
|
2521
|
+
export const tvSeriesLatestId = async (options) => {
|
|
2522
|
+
const res = await fetch(getTvSeriesLatestIdUrl(), {
|
|
2523
|
+
...options,
|
|
2524
|
+
method: 'GET'
|
|
2525
|
+
});
|
|
2526
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2527
|
+
const data = body ? JSON.parse(body) : {};
|
|
2528
|
+
return data;
|
|
2529
|
+
};
|
|
2530
|
+
/**
|
|
2531
|
+
* Get the lists that a TV series has been added to.
|
|
2532
|
+
* @summary Lists
|
|
2533
|
+
*/
|
|
2534
|
+
export const getListsCopyUrl = (seriesId, params) => {
|
|
2535
|
+
const normalizedParams = new URLSearchParams();
|
|
2536
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2537
|
+
if (value !== undefined) {
|
|
2538
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2539
|
+
}
|
|
2540
|
+
});
|
|
2541
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2542
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/lists?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/lists`;
|
|
2543
|
+
};
|
|
2544
|
+
export const listsCopy = async (seriesId, params, options) => {
|
|
2545
|
+
const res = await fetch(getListsCopyUrl(seriesId, params), {
|
|
2546
|
+
...options,
|
|
2547
|
+
method: 'GET'
|
|
2548
|
+
});
|
|
2549
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2550
|
+
const data = body ? JSON.parse(body) : {};
|
|
2551
|
+
return data;
|
|
2552
|
+
};
|
|
2553
|
+
/**
|
|
2554
|
+
* @summary Recommendations
|
|
2555
|
+
*/
|
|
2556
|
+
export const getTvSeriesRecommendationsUrl = (seriesId, params) => {
|
|
2557
|
+
const normalizedParams = new URLSearchParams();
|
|
2558
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2559
|
+
if (value !== undefined) {
|
|
2560
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2561
|
+
}
|
|
2562
|
+
});
|
|
2563
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2564
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/recommendations?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/recommendations`;
|
|
2565
|
+
};
|
|
2566
|
+
export const tvSeriesRecommendations = async (seriesId, params, options) => {
|
|
2567
|
+
const res = await fetch(getTvSeriesRecommendationsUrl(seriesId, params), {
|
|
2568
|
+
...options,
|
|
2569
|
+
method: 'GET'
|
|
2570
|
+
});
|
|
2571
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2572
|
+
const data = body ? JSON.parse(body) : {};
|
|
2573
|
+
return data;
|
|
2574
|
+
};
|
|
2575
|
+
/**
|
|
2576
|
+
* Get the reviews that have been added to a TV show.
|
|
2577
|
+
* @summary Reviews
|
|
2578
|
+
*/
|
|
2579
|
+
export const getTvSeriesReviewsUrl = (seriesId, params) => {
|
|
2580
|
+
const normalizedParams = new URLSearchParams();
|
|
2581
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2582
|
+
if (value !== undefined) {
|
|
2583
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2584
|
+
}
|
|
2585
|
+
});
|
|
2586
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2587
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/reviews?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/reviews`;
|
|
2588
|
+
};
|
|
2589
|
+
export const tvSeriesReviews = async (seriesId, params, options) => {
|
|
2590
|
+
const res = await fetch(getTvSeriesReviewsUrl(seriesId, params), {
|
|
2591
|
+
...options,
|
|
2592
|
+
method: 'GET'
|
|
2593
|
+
});
|
|
2594
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2595
|
+
const data = body ? JSON.parse(body) : {};
|
|
2596
|
+
return data;
|
|
2597
|
+
};
|
|
2598
|
+
/**
|
|
2599
|
+
* Get the seasons and episodes that have screened theatrically.
|
|
2600
|
+
* @summary Screened Theatrically
|
|
2601
|
+
*/
|
|
2602
|
+
export const getTvSeriesScreenedTheatricallyUrl = (seriesId) => {
|
|
2603
|
+
return `https://api.themoviedb.org/3/tv/${seriesId}/screened_theatrically`;
|
|
2604
|
+
};
|
|
2605
|
+
export const tvSeriesScreenedTheatrically = async (seriesId, options) => {
|
|
2606
|
+
const res = await fetch(getTvSeriesScreenedTheatricallyUrl(seriesId), {
|
|
2607
|
+
...options,
|
|
2608
|
+
method: 'GET'
|
|
2609
|
+
});
|
|
2610
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2611
|
+
const data = body ? JSON.parse(body) : {};
|
|
2612
|
+
return data;
|
|
2613
|
+
};
|
|
2614
|
+
/**
|
|
2615
|
+
* Get the similar TV shows.
|
|
2616
|
+
* @summary Similar
|
|
2617
|
+
*/
|
|
2618
|
+
export const getTvSeriesSimilarUrl = (seriesId, params) => {
|
|
2619
|
+
const normalizedParams = new URLSearchParams();
|
|
2620
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2621
|
+
if (value !== undefined) {
|
|
2622
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2623
|
+
}
|
|
2624
|
+
});
|
|
2625
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2626
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/similar?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/similar`;
|
|
2627
|
+
};
|
|
2628
|
+
export const tvSeriesSimilar = async (seriesId, params, options) => {
|
|
2629
|
+
const res = await fetch(getTvSeriesSimilarUrl(seriesId, params), {
|
|
2630
|
+
...options,
|
|
2631
|
+
method: 'GET'
|
|
2632
|
+
});
|
|
2633
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2634
|
+
const data = body ? JSON.parse(body) : {};
|
|
2635
|
+
return data;
|
|
2636
|
+
};
|
|
2637
|
+
/**
|
|
2638
|
+
* Get the translations that have been added to a TV show.
|
|
2639
|
+
* @summary Translations
|
|
2640
|
+
*/
|
|
2641
|
+
export const getTvSeriesTranslationsUrl = (seriesId) => {
|
|
2642
|
+
return `https://api.themoviedb.org/3/tv/${seriesId}/translations`;
|
|
2643
|
+
};
|
|
2644
|
+
export const tvSeriesTranslations = async (seriesId, options) => {
|
|
2645
|
+
const res = await fetch(getTvSeriesTranslationsUrl(seriesId), {
|
|
2646
|
+
...options,
|
|
2647
|
+
method: 'GET'
|
|
2648
|
+
});
|
|
2649
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2650
|
+
const data = body ? JSON.parse(body) : {};
|
|
2651
|
+
return data;
|
|
2652
|
+
};
|
|
2653
|
+
/**
|
|
2654
|
+
* Get the videos that belong to a TV show.
|
|
2655
|
+
* @summary Videos
|
|
2656
|
+
*/
|
|
2657
|
+
export const getTvSeriesVideosUrl = (seriesId, params) => {
|
|
2658
|
+
const normalizedParams = new URLSearchParams();
|
|
2659
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2660
|
+
if (value !== undefined) {
|
|
2661
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2662
|
+
}
|
|
2663
|
+
});
|
|
2664
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2665
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/videos?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/videos`;
|
|
2666
|
+
};
|
|
2667
|
+
export const tvSeriesVideos = async (seriesId, params, options) => {
|
|
2668
|
+
const res = await fetch(getTvSeriesVideosUrl(seriesId, params), {
|
|
2669
|
+
...options,
|
|
2670
|
+
method: 'GET'
|
|
2671
|
+
});
|
|
2672
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2673
|
+
const data = body ? JSON.parse(body) : {};
|
|
2674
|
+
return data;
|
|
2675
|
+
};
|
|
2676
|
+
/**
|
|
2677
|
+
* Get the list of streaming providers we have for a TV show.
|
|
2678
|
+
* @summary Watch Providers
|
|
2679
|
+
*/
|
|
2680
|
+
export const getTvSeriesWatchProvidersUrl = (seriesId) => {
|
|
2681
|
+
return `https://api.themoviedb.org/3/tv/${seriesId}/watch/providers`;
|
|
2682
|
+
};
|
|
2683
|
+
export const tvSeriesWatchProviders = async (seriesId, options) => {
|
|
2684
|
+
const res = await fetch(getTvSeriesWatchProvidersUrl(seriesId), {
|
|
2685
|
+
...options,
|
|
2686
|
+
method: 'GET'
|
|
2687
|
+
});
|
|
2688
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2689
|
+
const data = body ? JSON.parse(body) : {};
|
|
2690
|
+
return data;
|
|
2691
|
+
};
|
|
2692
|
+
/**
|
|
2693
|
+
* Rate a TV show and save it to your rated list.
|
|
2694
|
+
* @summary Add Rating
|
|
2695
|
+
*/
|
|
2696
|
+
export const getTvSeriesAddRatingUrl = (seriesId, params) => {
|
|
2697
|
+
const normalizedParams = new URLSearchParams();
|
|
2698
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2699
|
+
if (value !== undefined) {
|
|
2700
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2701
|
+
}
|
|
2702
|
+
});
|
|
2703
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2704
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/rating?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/rating`;
|
|
2705
|
+
};
|
|
2706
|
+
export const tvSeriesAddRating = async (seriesId, tvSeriesAddRatingBody, params, options) => {
|
|
2707
|
+
const res = await fetch(getTvSeriesAddRatingUrl(seriesId, params), {
|
|
2708
|
+
...options,
|
|
2709
|
+
method: 'POST',
|
|
2710
|
+
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
2711
|
+
body: JSON.stringify(tvSeriesAddRatingBody)
|
|
2712
|
+
});
|
|
2713
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2714
|
+
const data = body ? JSON.parse(body) : {};
|
|
2715
|
+
return data;
|
|
2716
|
+
};
|
|
2717
|
+
/**
|
|
2718
|
+
* @summary Delete Rating
|
|
2719
|
+
*/
|
|
2720
|
+
export const getTvSeriesDeleteRatingUrl = (seriesId, params) => {
|
|
2721
|
+
const normalizedParams = new URLSearchParams();
|
|
2722
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2723
|
+
if (value !== undefined) {
|
|
2724
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2725
|
+
}
|
|
2726
|
+
});
|
|
2727
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2728
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/rating?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/rating`;
|
|
2729
|
+
};
|
|
2730
|
+
export const tvSeriesDeleteRating = async (seriesId, params, options) => {
|
|
2731
|
+
const res = await fetch(getTvSeriesDeleteRatingUrl(seriesId, params), {
|
|
2732
|
+
...options,
|
|
2733
|
+
method: 'DELETE'
|
|
2734
|
+
});
|
|
2735
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2736
|
+
const data = body ? JSON.parse(body) : {};
|
|
2737
|
+
return data;
|
|
2738
|
+
};
|
|
2739
|
+
/**
|
|
2740
|
+
* Query the details of a TV season.
|
|
2741
|
+
* @summary Details
|
|
2742
|
+
*/
|
|
2743
|
+
export const getTvSeasonDetailsUrl = (seriesId, seasonNumber, params) => {
|
|
2744
|
+
const normalizedParams = new URLSearchParams();
|
|
2745
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2746
|
+
if (value !== undefined) {
|
|
2747
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2748
|
+
}
|
|
2749
|
+
});
|
|
2750
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2751
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}`;
|
|
2752
|
+
};
|
|
2753
|
+
export const tvSeasonDetails = async (seriesId, seasonNumber, params, options) => {
|
|
2754
|
+
const res = await fetch(getTvSeasonDetailsUrl(seriesId, seasonNumber, params), {
|
|
2755
|
+
...options,
|
|
2756
|
+
method: 'GET'
|
|
2757
|
+
});
|
|
2758
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2759
|
+
const data = body ? JSON.parse(body) : {};
|
|
2760
|
+
return data;
|
|
2761
|
+
};
|
|
2762
|
+
/**
|
|
2763
|
+
* Get the rating, watchlist and favourite status.
|
|
2764
|
+
* @summary Account States
|
|
2765
|
+
*/
|
|
2766
|
+
export const getTvSeasonAccountStatesUrl = (seriesId, seasonNumber, params) => {
|
|
2767
|
+
const normalizedParams = new URLSearchParams();
|
|
2768
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2769
|
+
if (value !== undefined) {
|
|
2770
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2771
|
+
}
|
|
2772
|
+
});
|
|
2773
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2774
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/account_states?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/account_states`;
|
|
2775
|
+
};
|
|
2776
|
+
export const tvSeasonAccountStates = async (seriesId, seasonNumber, params, options) => {
|
|
2777
|
+
const res = await fetch(getTvSeasonAccountStatesUrl(seriesId, seasonNumber, params), {
|
|
2778
|
+
...options,
|
|
2779
|
+
method: 'GET'
|
|
2780
|
+
});
|
|
2781
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2782
|
+
const data = body ? JSON.parse(body) : {};
|
|
2783
|
+
return data;
|
|
2784
|
+
};
|
|
2785
|
+
/**
|
|
2786
|
+
* Get the aggregate credits (cast and crew) that have been added to a TV season.
|
|
2787
|
+
* @summary Aggregate Credits
|
|
2788
|
+
*/
|
|
2789
|
+
export const getTvSeasonAggregateCreditsUrl = (seriesId, seasonNumber, params) => {
|
|
2790
|
+
const normalizedParams = new URLSearchParams();
|
|
2791
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2792
|
+
if (value !== undefined) {
|
|
2793
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2794
|
+
}
|
|
2795
|
+
});
|
|
2796
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2797
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/aggregate_credits?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/aggregate_credits`;
|
|
2798
|
+
};
|
|
2799
|
+
export const tvSeasonAggregateCredits = async (seriesId, seasonNumber, params, options) => {
|
|
2800
|
+
const res = await fetch(getTvSeasonAggregateCreditsUrl(seriesId, seasonNumber, params), {
|
|
2801
|
+
...options,
|
|
2802
|
+
method: 'GET'
|
|
2803
|
+
});
|
|
2804
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2805
|
+
const data = body ? JSON.parse(body) : {};
|
|
2806
|
+
return data;
|
|
2807
|
+
};
|
|
2808
|
+
/**
|
|
2809
|
+
* Get the recent changes for a TV season.
|
|
2810
|
+
* @summary Changes
|
|
2811
|
+
*/
|
|
2812
|
+
export const getTvSeasonChangesByIdUrl = (seasonId, params) => {
|
|
2813
|
+
const normalizedParams = new URLSearchParams();
|
|
2814
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2815
|
+
if (value !== undefined) {
|
|
2816
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2817
|
+
}
|
|
2818
|
+
});
|
|
2819
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2820
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/season/${seasonId}/changes?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/season/${seasonId}/changes`;
|
|
2821
|
+
};
|
|
2822
|
+
export const tvSeasonChangesById = async (seasonId, params, options) => {
|
|
2823
|
+
const res = await fetch(getTvSeasonChangesByIdUrl(seasonId, params), {
|
|
2824
|
+
...options,
|
|
2825
|
+
method: 'GET'
|
|
2826
|
+
});
|
|
2827
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2828
|
+
const data = body ? JSON.parse(body) : {};
|
|
2829
|
+
return data;
|
|
2830
|
+
};
|
|
2831
|
+
/**
|
|
2832
|
+
* @summary Credits
|
|
2833
|
+
*/
|
|
2834
|
+
export const getTvSeasonCreditsUrl = (seriesId, seasonNumber, params) => {
|
|
2835
|
+
const normalizedParams = new URLSearchParams();
|
|
2836
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2837
|
+
if (value !== undefined) {
|
|
2838
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2839
|
+
}
|
|
2840
|
+
});
|
|
2841
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2842
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/credits?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/credits`;
|
|
2843
|
+
};
|
|
2844
|
+
export const tvSeasonCredits = async (seriesId, seasonNumber, params, options) => {
|
|
2845
|
+
const res = await fetch(getTvSeasonCreditsUrl(seriesId, seasonNumber, params), {
|
|
2846
|
+
...options,
|
|
2847
|
+
method: 'GET'
|
|
2848
|
+
});
|
|
2849
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2850
|
+
const data = body ? JSON.parse(body) : {};
|
|
2851
|
+
return data;
|
|
2852
|
+
};
|
|
2853
|
+
/**
|
|
2854
|
+
* Get a list of external IDs that have been added to a TV season.
|
|
2855
|
+
* @summary External IDs
|
|
2856
|
+
*/
|
|
2857
|
+
export const getTvSeasonExternalIdsUrl = (seriesId, seasonNumber) => {
|
|
2858
|
+
return `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/external_ids`;
|
|
2859
|
+
};
|
|
2860
|
+
export const tvSeasonExternalIds = async (seriesId, seasonNumber, options) => {
|
|
2861
|
+
const res = await fetch(getTvSeasonExternalIdsUrl(seriesId, seasonNumber), {
|
|
2862
|
+
...options,
|
|
2863
|
+
method: 'GET'
|
|
2864
|
+
});
|
|
2865
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2866
|
+
const data = body ? JSON.parse(body) : {};
|
|
2867
|
+
return data;
|
|
2868
|
+
};
|
|
2869
|
+
/**
|
|
2870
|
+
* Get the images that belong to a TV season.
|
|
2871
|
+
* @summary Images
|
|
2872
|
+
*/
|
|
2873
|
+
export const getTvSeasonImagesUrl = (seriesId, seasonNumber, params) => {
|
|
2874
|
+
const normalizedParams = new URLSearchParams();
|
|
2875
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2876
|
+
if (value !== undefined) {
|
|
2877
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2878
|
+
}
|
|
2879
|
+
});
|
|
2880
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2881
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/images?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/images`;
|
|
2882
|
+
};
|
|
2883
|
+
export const tvSeasonImages = async (seriesId, seasonNumber, params, options) => {
|
|
2884
|
+
const res = await fetch(getTvSeasonImagesUrl(seriesId, seasonNumber, params), {
|
|
2885
|
+
...options,
|
|
2886
|
+
method: 'GET'
|
|
2887
|
+
});
|
|
2888
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2889
|
+
const data = body ? JSON.parse(body) : {};
|
|
2890
|
+
return data;
|
|
2891
|
+
};
|
|
2892
|
+
/**
|
|
2893
|
+
* Get the translations for a TV season.
|
|
2894
|
+
* @summary Translations
|
|
2895
|
+
*/
|
|
2896
|
+
export const getTvSeasonTranslationsUrl = (seriesId, seasonNumber) => {
|
|
2897
|
+
return `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/translations`;
|
|
2898
|
+
};
|
|
2899
|
+
export const tvSeasonTranslations = async (seriesId, seasonNumber, options) => {
|
|
2900
|
+
const res = await fetch(getTvSeasonTranslationsUrl(seriesId, seasonNumber), {
|
|
2901
|
+
...options,
|
|
2902
|
+
method: 'GET'
|
|
2903
|
+
});
|
|
2904
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2905
|
+
const data = body ? JSON.parse(body) : {};
|
|
2906
|
+
return data;
|
|
2907
|
+
};
|
|
2908
|
+
/**
|
|
2909
|
+
* Get the videos that belong to a TV season.
|
|
2910
|
+
* @summary Videos
|
|
2911
|
+
*/
|
|
2912
|
+
export const getTvSeasonVideosUrl = (seriesId, seasonNumber, params) => {
|
|
2913
|
+
const normalizedParams = new URLSearchParams();
|
|
2914
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2915
|
+
if (value !== undefined) {
|
|
2916
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2917
|
+
}
|
|
2918
|
+
});
|
|
2919
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2920
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/videos?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/videos`;
|
|
2921
|
+
};
|
|
2922
|
+
export const tvSeasonVideos = async (seriesId, seasonNumber, params, options) => {
|
|
2923
|
+
const res = await fetch(getTvSeasonVideosUrl(seriesId, seasonNumber, params), {
|
|
2924
|
+
...options,
|
|
2925
|
+
method: 'GET'
|
|
2926
|
+
});
|
|
2927
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2928
|
+
const data = body ? JSON.parse(body) : {};
|
|
2929
|
+
return data;
|
|
2930
|
+
};
|
|
2931
|
+
/**
|
|
2932
|
+
* Get the list of streaming providers we have for a TV season.
|
|
2933
|
+
* @summary Watch Providers
|
|
2934
|
+
*/
|
|
2935
|
+
export const getTvSeasonWatchProvidersUrl = (seriesId, seasonNumber, params) => {
|
|
2936
|
+
const normalizedParams = new URLSearchParams();
|
|
2937
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2938
|
+
if (value !== undefined) {
|
|
2939
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2940
|
+
}
|
|
2941
|
+
});
|
|
2942
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2943
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/watch/providers?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/watch/providers`;
|
|
2944
|
+
};
|
|
2945
|
+
export const tvSeasonWatchProviders = async (seriesId, seasonNumber, params, options) => {
|
|
2946
|
+
const res = await fetch(getTvSeasonWatchProvidersUrl(seriesId, seasonNumber, params), {
|
|
2947
|
+
...options,
|
|
2948
|
+
method: 'GET'
|
|
2949
|
+
});
|
|
2950
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2951
|
+
const data = body ? JSON.parse(body) : {};
|
|
2952
|
+
return data;
|
|
2953
|
+
};
|
|
2954
|
+
/**
|
|
2955
|
+
* Query the details of a TV episode.
|
|
2956
|
+
* @summary Details
|
|
2957
|
+
*/
|
|
2958
|
+
export const getTvEpisodeDetailsUrl = (seriesId, seasonNumber, episodeNumber, params) => {
|
|
2959
|
+
const normalizedParams = new URLSearchParams();
|
|
2960
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2961
|
+
if (value !== undefined) {
|
|
2962
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2963
|
+
}
|
|
2964
|
+
});
|
|
2965
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2966
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/episode/${episodeNumber}?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/episode/${episodeNumber}`;
|
|
2967
|
+
};
|
|
2968
|
+
export const tvEpisodeDetails = async (seriesId, seasonNumber, episodeNumber, params, options) => {
|
|
2969
|
+
const res = await fetch(getTvEpisodeDetailsUrl(seriesId, seasonNumber, episodeNumber, params), {
|
|
2970
|
+
...options,
|
|
2971
|
+
method: 'GET'
|
|
2972
|
+
});
|
|
2973
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2974
|
+
const data = body ? JSON.parse(body) : {};
|
|
2975
|
+
return data;
|
|
2976
|
+
};
|
|
2977
|
+
/**
|
|
2978
|
+
* Get the rating, watchlist and favourite status.
|
|
2979
|
+
* @summary Account States
|
|
2980
|
+
*/
|
|
2981
|
+
export const getTvEpisodeAccountStatesUrl = (seriesId, seasonNumber, episodeNumber, params) => {
|
|
2982
|
+
const normalizedParams = new URLSearchParams();
|
|
2983
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
2984
|
+
if (value !== undefined) {
|
|
2985
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
2986
|
+
}
|
|
2987
|
+
});
|
|
2988
|
+
const stringifiedParams = normalizedParams.toString();
|
|
2989
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/episode/${episodeNumber}/account_states?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/episode/${episodeNumber}/account_states`;
|
|
2990
|
+
};
|
|
2991
|
+
export const tvEpisodeAccountStates = async (seriesId, seasonNumber, episodeNumber, params, options) => {
|
|
2992
|
+
const res = await fetch(getTvEpisodeAccountStatesUrl(seriesId, seasonNumber, episodeNumber, params), {
|
|
2993
|
+
...options,
|
|
2994
|
+
method: 'GET'
|
|
2995
|
+
});
|
|
2996
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
2997
|
+
const data = body ? JSON.parse(body) : {};
|
|
2998
|
+
return data;
|
|
2999
|
+
};
|
|
3000
|
+
/**
|
|
3001
|
+
* Get the recent changes for a TV episode.
|
|
3002
|
+
* @summary Changes
|
|
3003
|
+
*/
|
|
3004
|
+
export const getTvEpisodeChangesByIdUrl = (episodeId) => {
|
|
3005
|
+
return `https://api.themoviedb.org/3/tv/episode/${episodeId}/changes`;
|
|
3006
|
+
};
|
|
3007
|
+
export const tvEpisodeChangesById = async (episodeId, options) => {
|
|
3008
|
+
const res = await fetch(getTvEpisodeChangesByIdUrl(episodeId), {
|
|
3009
|
+
...options,
|
|
3010
|
+
method: 'GET'
|
|
3011
|
+
});
|
|
3012
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
3013
|
+
const data = body ? JSON.parse(body) : {};
|
|
3014
|
+
return data;
|
|
3015
|
+
};
|
|
3016
|
+
/**
|
|
3017
|
+
* @summary Credits
|
|
3018
|
+
*/
|
|
3019
|
+
export const getTvEpisodeCreditsUrl = (seriesId, seasonNumber, episodeNumber, params) => {
|
|
3020
|
+
const normalizedParams = new URLSearchParams();
|
|
3021
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
3022
|
+
if (value !== undefined) {
|
|
3023
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
3024
|
+
}
|
|
3025
|
+
});
|
|
3026
|
+
const stringifiedParams = normalizedParams.toString();
|
|
3027
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/episode/${episodeNumber}/credits?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/episode/${episodeNumber}/credits`;
|
|
3028
|
+
};
|
|
3029
|
+
export const tvEpisodeCredits = async (seriesId, seasonNumber, episodeNumber, params, options) => {
|
|
3030
|
+
const res = await fetch(getTvEpisodeCreditsUrl(seriesId, seasonNumber, episodeNumber, params), {
|
|
3031
|
+
...options,
|
|
3032
|
+
method: 'GET'
|
|
3033
|
+
});
|
|
3034
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
3035
|
+
const data = body ? JSON.parse(body) : {};
|
|
3036
|
+
return data;
|
|
3037
|
+
};
|
|
3038
|
+
/**
|
|
3039
|
+
* Get a list of external IDs that have been added to a TV episode.
|
|
3040
|
+
* @summary External IDs
|
|
3041
|
+
*/
|
|
3042
|
+
export const getTvEpisodeExternalIdsUrl = (seriesId, seasonNumber, episodeNumber) => {
|
|
3043
|
+
return `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/episode/${episodeNumber}/external_ids`;
|
|
3044
|
+
};
|
|
3045
|
+
export const tvEpisodeExternalIds = async (seriesId, seasonNumber, episodeNumber, options) => {
|
|
3046
|
+
const res = await fetch(getTvEpisodeExternalIdsUrl(seriesId, seasonNumber, episodeNumber), {
|
|
3047
|
+
...options,
|
|
3048
|
+
method: 'GET'
|
|
3049
|
+
});
|
|
3050
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
3051
|
+
const data = body ? JSON.parse(body) : {};
|
|
3052
|
+
return data;
|
|
3053
|
+
};
|
|
3054
|
+
/**
|
|
3055
|
+
* Get the images that belong to a TV episode.
|
|
3056
|
+
* @summary Images
|
|
3057
|
+
*/
|
|
3058
|
+
export const getTvEpisodeImagesUrl = (seriesId, seasonNumber, episodeNumber, params) => {
|
|
3059
|
+
const normalizedParams = new URLSearchParams();
|
|
3060
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
3061
|
+
if (value !== undefined) {
|
|
3062
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
3063
|
+
}
|
|
3064
|
+
});
|
|
3065
|
+
const stringifiedParams = normalizedParams.toString();
|
|
3066
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/episode/${episodeNumber}/images?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/episode/${episodeNumber}/images`;
|
|
3067
|
+
};
|
|
3068
|
+
export const tvEpisodeImages = async (seriesId, seasonNumber, episodeNumber, params, options) => {
|
|
3069
|
+
const res = await fetch(getTvEpisodeImagesUrl(seriesId, seasonNumber, episodeNumber, params), {
|
|
3070
|
+
...options,
|
|
3071
|
+
method: 'GET'
|
|
3072
|
+
});
|
|
3073
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
3074
|
+
const data = body ? JSON.parse(body) : {};
|
|
3075
|
+
return data;
|
|
3076
|
+
};
|
|
3077
|
+
/**
|
|
3078
|
+
* Get the translations that have been added to a TV episode.
|
|
3079
|
+
* @summary Translations
|
|
3080
|
+
*/
|
|
3081
|
+
export const getTvEpisodeTranslationsUrl = (seriesId, seasonNumber, episodeNumber) => {
|
|
3082
|
+
return `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/episode/${episodeNumber}/translations`;
|
|
3083
|
+
};
|
|
3084
|
+
export const tvEpisodeTranslations = async (seriesId, seasonNumber, episodeNumber, options) => {
|
|
3085
|
+
const res = await fetch(getTvEpisodeTranslationsUrl(seriesId, seasonNumber, episodeNumber), {
|
|
3086
|
+
...options,
|
|
3087
|
+
method: 'GET'
|
|
3088
|
+
});
|
|
3089
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
3090
|
+
const data = body ? JSON.parse(body) : {};
|
|
3091
|
+
return data;
|
|
3092
|
+
};
|
|
3093
|
+
/**
|
|
3094
|
+
* Get the videos that belong to a TV episode.
|
|
3095
|
+
* @summary Videos
|
|
3096
|
+
*/
|
|
3097
|
+
export const getTvEpisodeVideosUrl = (seriesId, seasonNumber, episodeNumber, params) => {
|
|
3098
|
+
const normalizedParams = new URLSearchParams();
|
|
3099
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
3100
|
+
if (value !== undefined) {
|
|
3101
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
3102
|
+
}
|
|
3103
|
+
});
|
|
3104
|
+
const stringifiedParams = normalizedParams.toString();
|
|
3105
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/episode/${episodeNumber}/videos?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/episode/${episodeNumber}/videos`;
|
|
3106
|
+
};
|
|
3107
|
+
export const tvEpisodeVideos = async (seriesId, seasonNumber, episodeNumber, params, options) => {
|
|
3108
|
+
const res = await fetch(getTvEpisodeVideosUrl(seriesId, seasonNumber, episodeNumber, params), {
|
|
3109
|
+
...options,
|
|
3110
|
+
method: 'GET'
|
|
3111
|
+
});
|
|
3112
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
3113
|
+
const data = body ? JSON.parse(body) : {};
|
|
3114
|
+
return data;
|
|
3115
|
+
};
|
|
3116
|
+
/**
|
|
3117
|
+
* Rate a TV episode and save it to your rated list.
|
|
3118
|
+
* @summary Add Rating
|
|
3119
|
+
*/
|
|
3120
|
+
export const getTvEpisodeAddRatingUrl = (seriesId, seasonNumber, episodeNumber, params) => {
|
|
3121
|
+
const normalizedParams = new URLSearchParams();
|
|
3122
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
3123
|
+
if (value !== undefined) {
|
|
3124
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
3125
|
+
}
|
|
3126
|
+
});
|
|
3127
|
+
const stringifiedParams = normalizedParams.toString();
|
|
3128
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/episode/${episodeNumber}/rating?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/episode/${episodeNumber}/rating`;
|
|
3129
|
+
};
|
|
3130
|
+
export const tvEpisodeAddRating = async (seriesId, seasonNumber, episodeNumber, tvEpisodeAddRatingBody, params, options) => {
|
|
3131
|
+
const res = await fetch(getTvEpisodeAddRatingUrl(seriesId, seasonNumber, episodeNumber, params), {
|
|
3132
|
+
...options,
|
|
3133
|
+
method: 'POST',
|
|
3134
|
+
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
3135
|
+
body: JSON.stringify(tvEpisodeAddRatingBody)
|
|
3136
|
+
});
|
|
3137
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
3138
|
+
const data = body ? JSON.parse(body) : {};
|
|
3139
|
+
return data;
|
|
3140
|
+
};
|
|
3141
|
+
/**
|
|
3142
|
+
* Delete your rating on a TV episode.
|
|
3143
|
+
* @summary Delete Rating
|
|
3144
|
+
*/
|
|
3145
|
+
export const getTvEpisodeDeleteRatingUrl = (seriesId, seasonNumber, episodeNumber, params) => {
|
|
3146
|
+
const normalizedParams = new URLSearchParams();
|
|
3147
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
3148
|
+
if (value !== undefined) {
|
|
3149
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
3150
|
+
}
|
|
3151
|
+
});
|
|
3152
|
+
const stringifiedParams = normalizedParams.toString();
|
|
3153
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/episode/${episodeNumber}/rating?${stringifiedParams}` : `https://api.themoviedb.org/3/tv/${seriesId}/season/${seasonNumber}/episode/${episodeNumber}/rating`;
|
|
3154
|
+
};
|
|
3155
|
+
export const tvEpisodeDeleteRating = async (seriesId, seasonNumber, episodeNumber, params, options) => {
|
|
3156
|
+
const res = await fetch(getTvEpisodeDeleteRatingUrl(seriesId, seasonNumber, episodeNumber, params), {
|
|
3157
|
+
...options,
|
|
3158
|
+
method: 'DELETE'
|
|
3159
|
+
});
|
|
3160
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
3161
|
+
const data = body ? JSON.parse(body) : {};
|
|
3162
|
+
return data;
|
|
3163
|
+
};
|
|
3164
|
+
/**
|
|
3165
|
+
* Get the details of a TV episode group.
|
|
3166
|
+
* @summary Details
|
|
3167
|
+
*/
|
|
3168
|
+
export const getTvEpisodeGroupDetailsUrl = (tvEpisodeGroupId) => {
|
|
3169
|
+
return `https://api.themoviedb.org/3/tv/episode_group/${tvEpisodeGroupId}`;
|
|
3170
|
+
};
|
|
3171
|
+
export const tvEpisodeGroupDetails = async (tvEpisodeGroupId, options) => {
|
|
3172
|
+
const res = await fetch(getTvEpisodeGroupDetailsUrl(tvEpisodeGroupId), {
|
|
3173
|
+
...options,
|
|
3174
|
+
method: 'GET'
|
|
3175
|
+
});
|
|
3176
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
3177
|
+
const data = body ? JSON.parse(body) : {};
|
|
3178
|
+
return data;
|
|
3179
|
+
};
|
|
3180
|
+
/**
|
|
3181
|
+
* Get the list of the countries we have watch provider (OTT/streaming) data for.
|
|
3182
|
+
* @summary Available Regions
|
|
3183
|
+
*/
|
|
3184
|
+
export const getWatchProvidersAvailableRegionsUrl = (params) => {
|
|
3185
|
+
const normalizedParams = new URLSearchParams();
|
|
3186
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
3187
|
+
if (value !== undefined) {
|
|
3188
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
3189
|
+
}
|
|
3190
|
+
});
|
|
3191
|
+
const stringifiedParams = normalizedParams.toString();
|
|
3192
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/watch/providers/regions?${stringifiedParams}` : `https://api.themoviedb.org/3/watch/providers/regions`;
|
|
3193
|
+
};
|
|
3194
|
+
export const watchProvidersAvailableRegions = async (params, options) => {
|
|
3195
|
+
const res = await fetch(getWatchProvidersAvailableRegionsUrl(params), {
|
|
3196
|
+
...options,
|
|
3197
|
+
method: 'GET'
|
|
3198
|
+
});
|
|
3199
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
3200
|
+
const data = body ? JSON.parse(body) : {};
|
|
3201
|
+
return data;
|
|
3202
|
+
};
|
|
3203
|
+
/**
|
|
3204
|
+
* Get the list of streaming providers we have for movies.
|
|
3205
|
+
* @summary Movie Providers
|
|
3206
|
+
*/
|
|
3207
|
+
export const getWatchProvidersMovieListUrl = (params) => {
|
|
3208
|
+
const normalizedParams = new URLSearchParams();
|
|
3209
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
3210
|
+
if (value !== undefined) {
|
|
3211
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
3212
|
+
}
|
|
3213
|
+
});
|
|
3214
|
+
const stringifiedParams = normalizedParams.toString();
|
|
3215
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/watch/providers/movie?${stringifiedParams}` : `https://api.themoviedb.org/3/watch/providers/movie`;
|
|
3216
|
+
};
|
|
3217
|
+
export const watchProvidersMovieList = async (params, options) => {
|
|
3218
|
+
const res = await fetch(getWatchProvidersMovieListUrl(params), {
|
|
3219
|
+
...options,
|
|
3220
|
+
method: 'GET'
|
|
3221
|
+
});
|
|
3222
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
3223
|
+
const data = body ? JSON.parse(body) : {};
|
|
3224
|
+
return data;
|
|
3225
|
+
};
|
|
3226
|
+
/**
|
|
3227
|
+
* Get the list of streaming providers we have for TV shows.
|
|
3228
|
+
* @summary TV Providers
|
|
3229
|
+
*/
|
|
3230
|
+
export const getWatchProviderTvListUrl = (params) => {
|
|
3231
|
+
const normalizedParams = new URLSearchParams();
|
|
3232
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
3233
|
+
if (value !== undefined) {
|
|
3234
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
3235
|
+
}
|
|
3236
|
+
});
|
|
3237
|
+
const stringifiedParams = normalizedParams.toString();
|
|
3238
|
+
return stringifiedParams.length > 0 ? `https://api.themoviedb.org/3/watch/providers/tv?${stringifiedParams}` : `https://api.themoviedb.org/3/watch/providers/tv`;
|
|
3239
|
+
};
|
|
3240
|
+
export const watchProviderTvList = async (params, options) => {
|
|
3241
|
+
const res = await fetch(getWatchProviderTvListUrl(params), {
|
|
3242
|
+
...options,
|
|
3243
|
+
method: 'GET'
|
|
3244
|
+
});
|
|
3245
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
3246
|
+
const data = body ? JSON.parse(body) : {};
|
|
3247
|
+
return data;
|
|
3248
|
+
};
|