@tdanks2000/tmdb-wrapper 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.
Files changed (207) hide show
  1. package/README.md +137 -0
  2. package/dist/@types/endpoints/account.d.ts +16 -0
  3. package/dist/@types/endpoints/account.d.ts.map +1 -0
  4. package/dist/@types/endpoints/account.js +2 -0
  5. package/dist/@types/endpoints/certification.d.ts +19 -0
  6. package/dist/@types/endpoints/certification.d.ts.map +1 -0
  7. package/dist/@types/endpoints/certification.js +2 -0
  8. package/dist/@types/endpoints/changes.d.ts +26 -0
  9. package/dist/@types/endpoints/changes.d.ts.map +1 -0
  10. package/dist/@types/endpoints/changes.js +2 -0
  11. package/dist/@types/endpoints/collection.d.ts +21 -0
  12. package/dist/@types/endpoints/collection.d.ts.map +1 -0
  13. package/dist/@types/endpoints/collection.js +2 -0
  14. package/dist/@types/endpoints/companies.d.ts +29 -0
  15. package/dist/@types/endpoints/companies.d.ts.map +1 -0
  16. package/dist/@types/endpoints/companies.js +2 -0
  17. package/dist/@types/endpoints/configuration.d.ts +105 -0
  18. package/dist/@types/endpoints/configuration.d.ts.map +1 -0
  19. package/dist/@types/endpoints/configuration.js +2 -0
  20. package/dist/@types/endpoints/credits.d.ts +135 -0
  21. package/dist/@types/endpoints/credits.d.ts.map +1 -0
  22. package/dist/@types/endpoints/credits.js +2 -0
  23. package/dist/@types/endpoints/discover.d.ts +15 -0
  24. package/dist/@types/endpoints/discover.d.ts.map +1 -0
  25. package/dist/@types/endpoints/discover.js +2 -0
  26. package/dist/@types/endpoints/find.d.ts +20 -0
  27. package/dist/@types/endpoints/find.d.ts.map +1 -0
  28. package/dist/@types/endpoints/find.js +2 -0
  29. package/dist/@types/endpoints/index.d.ts +22 -0
  30. package/dist/@types/endpoints/index.d.ts.map +1 -0
  31. package/dist/@types/endpoints/index.js +37 -0
  32. package/dist/@types/endpoints/keywords.d.ts +21 -0
  33. package/dist/@types/endpoints/keywords.d.ts.map +1 -0
  34. package/dist/@types/endpoints/keywords.js +2 -0
  35. package/dist/@types/endpoints/movies.d.ts +144 -0
  36. package/dist/@types/endpoints/movies.d.ts.map +1 -0
  37. package/dist/@types/endpoints/movies.js +12 -0
  38. package/dist/@types/endpoints/networks.d.ts +14 -0
  39. package/dist/@types/endpoints/networks.d.ts.map +1 -0
  40. package/dist/@types/endpoints/networks.js +2 -0
  41. package/dist/@types/endpoints/options.d.ts +73 -0
  42. package/dist/@types/endpoints/options.d.ts.map +1 -0
  43. package/dist/@types/endpoints/options.js +2 -0
  44. package/dist/@types/endpoints/people.d.ts +135 -0
  45. package/dist/@types/endpoints/people.d.ts.map +1 -0
  46. package/dist/@types/endpoints/people.js +2 -0
  47. package/dist/@types/endpoints/review.d.ts +8 -0
  48. package/dist/@types/endpoints/review.d.ts.map +1 -0
  49. package/dist/@types/endpoints/review.js +2 -0
  50. package/dist/@types/endpoints/search.d.ts +9 -0
  51. package/dist/@types/endpoints/search.d.ts.map +1 -0
  52. package/dist/@types/endpoints/search.js +2 -0
  53. package/dist/@types/endpoints/trending.d.ts +12 -0
  54. package/dist/@types/endpoints/trending.d.ts.map +1 -0
  55. package/dist/@types/endpoints/trending.js +2 -0
  56. package/dist/@types/endpoints/tvEpisode.d.ts +53 -0
  57. package/dist/@types/endpoints/tvEpisode.d.ts.map +1 -0
  58. package/dist/@types/endpoints/tvEpisode.js +2 -0
  59. package/dist/@types/endpoints/tvSeasons.d.ts +19 -0
  60. package/dist/@types/endpoints/tvSeasons.d.ts.map +1 -0
  61. package/dist/@types/endpoints/tvSeasons.js +2 -0
  62. package/dist/@types/endpoints/tvShows.d.ts +260 -0
  63. package/dist/@types/endpoints/tvShows.d.ts.map +1 -0
  64. package/dist/@types/endpoints/tvShows.js +2 -0
  65. package/dist/@types/endpoints/watchProviders.d.ts +295 -0
  66. package/dist/@types/endpoints/watchProviders.d.ts.map +1 -0
  67. package/dist/@types/endpoints/watchProviders.js +2 -0
  68. package/dist/@types/index.d.ts +4 -0
  69. package/dist/@types/index.d.ts.map +1 -0
  70. package/dist/@types/index.js +19 -0
  71. package/dist/@types/models/baseEndpoint.d.ts +7 -0
  72. package/dist/@types/models/baseEndpoint.d.ts.map +1 -0
  73. package/dist/@types/models/baseEndpoint.js +11 -0
  74. package/dist/@types/models/index.d.ts +2 -0
  75. package/dist/@types/models/index.d.ts.map +1 -0
  76. package/dist/@types/models/index.js +17 -0
  77. package/dist/@types/types.d.ts +174 -0
  78. package/dist/@types/types.d.ts.map +1 -0
  79. package/dist/@types/types.js +2 -0
  80. package/dist/endpoints/account.d.ts +6 -0
  81. package/dist/endpoints/account.d.ts.map +1 -0
  82. package/dist/endpoints/account.js +24 -0
  83. package/dist/endpoints/certification.d.ts +8 -0
  84. package/dist/endpoints/certification.d.ts.map +1 -0
  85. package/dist/endpoints/certification.js +30 -0
  86. package/dist/endpoints/changes.d.ts +9 -0
  87. package/dist/endpoints/changes.d.ts.map +1 -0
  88. package/dist/endpoints/changes.js +35 -0
  89. package/dist/endpoints/collections.d.ts +9 -0
  90. package/dist/endpoints/collections.d.ts.map +1 -0
  91. package/dist/endpoints/collections.js +41 -0
  92. package/dist/endpoints/companies.d.ts +9 -0
  93. package/dist/endpoints/companies.d.ts.map +1 -0
  94. package/dist/endpoints/companies.js +35 -0
  95. package/dist/endpoints/configuration.d.ts +7 -0
  96. package/dist/endpoints/configuration.d.ts.map +1 -0
  97. package/dist/endpoints/configuration.js +25 -0
  98. package/dist/endpoints/credits.d.ts +7 -0
  99. package/dist/endpoints/credits.d.ts.map +1 -0
  100. package/dist/endpoints/credits.js +25 -0
  101. package/dist/endpoints/discover.d.ts +61 -0
  102. package/dist/endpoints/discover.d.ts.map +1 -0
  103. package/dist/endpoints/discover.js +30 -0
  104. package/dist/endpoints/find.d.ts +6 -0
  105. package/dist/endpoints/find.d.ts.map +1 -0
  106. package/dist/endpoints/find.js +24 -0
  107. package/dist/endpoints/genre.d.ts +14 -0
  108. package/dist/endpoints/genre.d.ts.map +1 -0
  109. package/dist/endpoints/genre.js +30 -0
  110. package/dist/endpoints/index.d.ts +19 -0
  111. package/dist/endpoints/index.d.ts.map +1 -0
  112. package/dist/endpoints/index.js +34 -0
  113. package/dist/endpoints/keywords.d.ts +7 -0
  114. package/dist/endpoints/keywords.d.ts.map +1 -0
  115. package/dist/endpoints/keywords.js +30 -0
  116. package/dist/endpoints/movies.d.ts +36 -0
  117. package/dist/endpoints/movies.d.ts.map +1 -0
  118. package/dist/endpoints/movies.js +134 -0
  119. package/dist/endpoints/networks.d.ts +9 -0
  120. package/dist/endpoints/networks.d.ts.map +1 -0
  121. package/dist/endpoints/networks.js +35 -0
  122. package/dist/endpoints/people.d.ts +16 -0
  123. package/dist/endpoints/people.d.ts.map +1 -0
  124. package/dist/endpoints/people.js +79 -0
  125. package/dist/endpoints/review.d.ts +6 -0
  126. package/dist/endpoints/review.d.ts.map +1 -0
  127. package/dist/endpoints/review.js +24 -0
  128. package/dist/endpoints/search.d.ts +39 -0
  129. package/dist/endpoints/search.d.ts.map +1 -0
  130. package/dist/endpoints/search.js +56 -0
  131. package/dist/endpoints/trending.d.ts +6 -0
  132. package/dist/endpoints/trending.d.ts.map +1 -0
  133. package/dist/endpoints/trending.js +24 -0
  134. package/dist/endpoints/tvEpisodes.d.ts +24 -0
  135. package/dist/endpoints/tvEpisodes.d.ts.map +1 -0
  136. package/dist/endpoints/tvEpisodes.js +68 -0
  137. package/dist/endpoints/tvSeasons.d.ts +25 -0
  138. package/dist/endpoints/tvSeasons.d.ts.map +1 -0
  139. package/dist/endpoints/tvSeasons.js +73 -0
  140. package/dist/endpoints/tvShows.d.ts +33 -0
  141. package/dist/endpoints/tvShows.d.ts.map +1 -0
  142. package/dist/endpoints/tvShows.js +154 -0
  143. package/dist/index.d.ts +26 -0
  144. package/dist/index.d.ts.map +1 -0
  145. package/dist/index.js +43 -0
  146. package/dist/utils/api.d.ts +7 -0
  147. package/dist/utils/api.d.ts.map +1 -0
  148. package/dist/utils/api.js +39 -0
  149. package/dist/utils/getimagePath.d.ts +12 -0
  150. package/dist/utils/getimagePath.d.ts.map +1 -0
  151. package/dist/utils/getimagePath.js +19 -0
  152. package/dist/utils/index.d.ts +3 -0
  153. package/dist/utils/index.d.ts.map +1 -0
  154. package/dist/utils/index.js +18 -0
  155. package/package.json +40 -0
  156. package/src/@types/endpoints/account.ts +17 -0
  157. package/src/@types/endpoints/certification.ts +19 -0
  158. package/src/@types/endpoints/changes.ts +29 -0
  159. package/src/@types/endpoints/collection.ts +23 -0
  160. package/src/@types/endpoints/companies.ts +33 -0
  161. package/src/@types/endpoints/configuration.ts +111 -0
  162. package/src/@types/endpoints/credits.ts +149 -0
  163. package/src/@types/endpoints/discover.ts +31 -0
  164. package/src/@types/endpoints/find.ts +28 -0
  165. package/src/@types/endpoints/index.ts +21 -0
  166. package/src/@types/endpoints/keywords.ts +24 -0
  167. package/src/@types/endpoints/movies.ts +162 -0
  168. package/src/@types/endpoints/networks.ts +15 -0
  169. package/src/@types/endpoints/options.ts +189 -0
  170. package/src/@types/endpoints/people.ts +151 -0
  171. package/src/@types/endpoints/review.ts +8 -0
  172. package/src/@types/endpoints/search.ts +10 -0
  173. package/src/@types/endpoints/trending.ts +20 -0
  174. package/src/@types/endpoints/tvEpisode.ts +58 -0
  175. package/src/@types/endpoints/tvSeasons.ts +23 -0
  176. package/src/@types/endpoints/tvShows.ts +284 -0
  177. package/src/@types/endpoints/watchProviders.ts +298 -0
  178. package/src/@types/index.ts +3 -0
  179. package/src/@types/models/baseEndpoint.ts +9 -0
  180. package/src/@types/models/index.ts +1 -0
  181. package/src/@types/types.ts +199 -0
  182. package/src/endpoints/account.ts +11 -0
  183. package/src/endpoints/certification.ts +15 -0
  184. package/src/endpoints/changes.ts +19 -0
  185. package/src/endpoints/collections.ts +32 -0
  186. package/src/endpoints/companies.ts +19 -0
  187. package/src/endpoints/configuration.ts +11 -0
  188. package/src/endpoints/credits.ts +11 -0
  189. package/src/endpoints/discover.ts +73 -0
  190. package/src/endpoints/find.ts +11 -0
  191. package/src/endpoints/genre.ts +19 -0
  192. package/src/endpoints/index.ts +18 -0
  193. package/src/endpoints/keywords.ts +17 -0
  194. package/src/endpoints/movies.ts +138 -0
  195. package/src/endpoints/networks.ts +19 -0
  196. package/src/endpoints/people.ts +79 -0
  197. package/src/endpoints/review.ts +11 -0
  198. package/src/endpoints/search.ts +78 -0
  199. package/src/endpoints/trending.ts +15 -0
  200. package/src/endpoints/tvEpisodes.ts +88 -0
  201. package/src/endpoints/tvSeasons.ts +93 -0
  202. package/src/endpoints/tvShows.ts +151 -0
  203. package/src/index.ts +66 -0
  204. package/src/utils/api.ts +31 -0
  205. package/src/utils/getimagePath.ts +16 -0
  206. package/src/utils/index.ts +2 -0
  207. package/tsconfig.json +108 -0
@@ -0,0 +1,199 @@
1
+ export interface ErrorResponse {
2
+ status_code: number;
3
+ status_message: string;
4
+ success: boolean;
5
+ }
6
+
7
+ export type MediaType = 'movie' | 'tv' | 'person';
8
+
9
+ export interface AuthorDetails {
10
+ name: string;
11
+ username: string;
12
+ avatar_path: string;
13
+ rating?: number;
14
+ }
15
+
16
+ export type KnownFor = MovieWithMediaType | TVWithMediaType;
17
+
18
+ export interface Person {
19
+ id: number;
20
+ name: string;
21
+ known_for: KnownFor[];
22
+ profile_path: string;
23
+ adult: boolean;
24
+ known_for_department: string;
25
+ gender: number;
26
+ popularity: number;
27
+ }
28
+
29
+ export interface PersonWithMediaType extends Person {
30
+ media_type: 'person';
31
+ }
32
+
33
+ export interface Movie {
34
+ id: number;
35
+ poster_path: string;
36
+ adult: boolean;
37
+ overview: string;
38
+ release_date: string;
39
+ genre_ids: number[];
40
+ original_title: string;
41
+ original_language: string;
42
+ title: string;
43
+ backdrop_path: string;
44
+ popularity: number;
45
+ vote_count: number;
46
+ video: boolean;
47
+ vote_average: number;
48
+ }
49
+
50
+ export interface MovieWithMediaType extends Movie {
51
+ media_type: 'movie';
52
+ }
53
+
54
+ export interface Company {
55
+ id: number;
56
+ logo_path: string;
57
+ name: string;
58
+ origin_country: string;
59
+ }
60
+
61
+ export interface TV {
62
+ id: number;
63
+ name: string;
64
+ first_air_date: string;
65
+ backdrop_path: string;
66
+ genre_ids: number[];
67
+ origin_country: string[];
68
+ original_language: string;
69
+ original_name: string;
70
+ overview: string;
71
+ poster_path: string;
72
+ popularity: number;
73
+ vote_count: number;
74
+ vote_average: number;
75
+ }
76
+
77
+ export interface TVWithMediaType extends TV {
78
+ media_type: 'tv';
79
+ }
80
+
81
+ export interface Genre {
82
+ id: number;
83
+ name: string;
84
+ }
85
+
86
+ export interface ExternalIds {
87
+ imdb_id: string;
88
+ facebook_id: string;
89
+ instagram_id: string;
90
+ twitter_id: string;
91
+ id: number;
92
+ }
93
+
94
+ export interface ProductionCompany {
95
+ id: number;
96
+ logo_path: string;
97
+ name: string;
98
+ origin_country: string;
99
+ }
100
+
101
+ export interface ProductionCountry {
102
+ iso_3166_1: string;
103
+ name: string;
104
+ }
105
+
106
+ export interface SpokenLanguage {
107
+ english_name: string;
108
+ iso_639_1: string;
109
+ name: string;
110
+ }
111
+
112
+ export interface ContentRatings {
113
+ results: ContentRatingsResult[];
114
+ id: number;
115
+ }
116
+
117
+ export interface ContentRatingsResult {
118
+ descriptor: unknown[];
119
+ iso_3166_1: string;
120
+ rating: string;
121
+ }
122
+
123
+ export interface Recommendation {
124
+ adult: boolean;
125
+ backdrop_path?: string;
126
+ genre_ids: number[];
127
+ id: number;
128
+ original_language: string;
129
+ original_title: string;
130
+ overview: string;
131
+ release_date: string;
132
+ poster_path?: string;
133
+ popularity: number;
134
+ title: string;
135
+ video: boolean;
136
+ vote_average: number;
137
+ vote_count: number;
138
+ }
139
+
140
+ export interface Recommendations {
141
+ page: number;
142
+ results: Recommendation[];
143
+ total_pages: number;
144
+ total_results: number;
145
+ }
146
+
147
+ export interface Review {
148
+ author: string;
149
+ author_details: AuthorDetails;
150
+ content: string;
151
+ created_at: Date;
152
+ id: string;
153
+ updated_at: Date;
154
+ url: string;
155
+ }
156
+
157
+ export interface Reviews {
158
+ id: number;
159
+ page: number;
160
+ results: Review[];
161
+ total_pages: number;
162
+ total_results: number;
163
+ }
164
+
165
+ export interface TranslationData {
166
+ title: string;
167
+ overview: string;
168
+ homepage: string;
169
+ }
170
+
171
+ export interface Translation {
172
+ iso_3166_1: string;
173
+ iso_639_1: string;
174
+ name: string;
175
+ english_name: string;
176
+ data: TranslationData;
177
+ }
178
+
179
+ export interface Translations {
180
+ id: number;
181
+ translations: Translation[];
182
+ }
183
+
184
+ export interface Image {
185
+ aspect_ratio: number;
186
+ file_path: string;
187
+ height: number;
188
+ iso_639_1: string;
189
+ vote_average: number;
190
+ vote_count: number;
191
+ width: number;
192
+ }
193
+
194
+ export interface Images {
195
+ id: number;
196
+ backdrops: Image[];
197
+ logos: Image[];
198
+ posters: Image[];
199
+ }
@@ -0,0 +1,11 @@
1
+ import { AccountDetails, BaseEndpoint } from '@/@types';
2
+
3
+ export class AccountEndpoint extends BaseEndpoint {
4
+ constructor(access_token: string) {
5
+ super(access_token);
6
+ }
7
+
8
+ async details(): Promise<AccountDetails> {
9
+ return await this.api.get('/account');
10
+ }
11
+ }
@@ -0,0 +1,15 @@
1
+ import { BaseEndpoint, Certifications } from '@/@types';
2
+
3
+ export class CertificationEndpoint extends BaseEndpoint {
4
+ constructor(protected readonly access_token: string) {
5
+ super(access_token);
6
+ }
7
+
8
+ async movies(): Promise<Certifications> {
9
+ return await this.api.get<Certifications>('/certification/movie/list');
10
+ }
11
+
12
+ async tv(): Promise<Certifications> {
13
+ return await this.api.get<Certifications>('/certification/tv/list');
14
+ }
15
+ }
@@ -0,0 +1,19 @@
1
+ import { BaseEndpoint, ChangeOption, MediaChanges } from '@/@types';
2
+
3
+ export class ChangeEndpoint extends BaseEndpoint {
4
+ constructor(protected readonly access_token: string) {
5
+ super(access_token);
6
+ }
7
+
8
+ async movies(options?: ChangeOption): Promise<MediaChanges> {
9
+ return await this.api.get<MediaChanges>(`/movie/changes`, options);
10
+ }
11
+
12
+ async tv(options?: ChangeOption): Promise<MediaChanges> {
13
+ return await this.api.get<MediaChanges>(`/tv/changes`, options);
14
+ }
15
+
16
+ async person(options?: ChangeOption): Promise<MediaChanges> {
17
+ return await this.api.get<MediaChanges>(`/person/change`, options);
18
+ }
19
+ }
@@ -0,0 +1,32 @@
1
+ import {
2
+ BaseEndpoint,
3
+ CollectionImageOptions,
4
+ DetailedCollection,
5
+ ImageCollection,
6
+ LanguageOption,
7
+ Translations,
8
+ } from '@/@types';
9
+
10
+ const BASE_COLLECTION = '/collection';
11
+
12
+ export class CollectionsEndpoint extends BaseEndpoint {
13
+ constructor(protected readonly access_token: string) {
14
+ super(access_token);
15
+ }
16
+
17
+ async details(id: number, options?: LanguageOption): Promise<DetailedCollection> {
18
+ return await this.api.get<DetailedCollection>(`${BASE_COLLECTION}/${id}`, options);
19
+ }
20
+
21
+ async images(id: number, options?: CollectionImageOptions): Promise<ImageCollection> {
22
+ const computedOptions = {
23
+ include_image_language: options?.include_image_language?.join(','),
24
+ language: options?.language,
25
+ };
26
+ return await this.api.get<ImageCollection>(`${BASE_COLLECTION}/${id}/images`, computedOptions);
27
+ }
28
+
29
+ async translations(id: number, options?: LanguageOption): Promise<Translations> {
30
+ return await this.api.get<Translations>(`${BASE_COLLECTION}/${id}/translations`, options);
31
+ }
32
+ }
@@ -0,0 +1,19 @@
1
+ import { AlternativeNames, BaseEndpoint, CompanyDetails, CompanyImages } from '@/@types';
2
+
3
+ export class CompaniesEndpoint extends BaseEndpoint {
4
+ constructor(protected readonly access_token: string) {
5
+ super(access_token);
6
+ }
7
+
8
+ async details(id: number): Promise<CompanyDetails> {
9
+ return await this.api.get<CompanyDetails>(`/company/${id}`);
10
+ }
11
+
12
+ async alternativeNames(id: number): Promise<AlternativeNames> {
13
+ return await this.api.get<AlternativeNames>(`/company/${id}/alternative_names`);
14
+ }
15
+
16
+ async images(id: number): Promise<CompanyImages> {
17
+ return await this.api.get<CompanyImages>(`/company/${id}/images`);
18
+ }
19
+ }
@@ -0,0 +1,11 @@
1
+ import { BaseEndpoint, Configuration } from '@/@types';
2
+
3
+ export class ConfigurationEndpoint extends BaseEndpoint {
4
+ constructor(protected readonly access_token: string) {
5
+ super(access_token);
6
+ }
7
+
8
+ async getCurrent(): Promise<Configuration> {
9
+ return await this.api.get<Configuration>(`/configuration`);
10
+ }
11
+ }
@@ -0,0 +1,11 @@
1
+ import { BaseEndpoint, CreditResponse } from '@/@types';
2
+
3
+ export class CreditsEndpoint extends BaseEndpoint {
4
+ constructor(protected readonly access_token: string) {
5
+ super(access_token);
6
+ }
7
+
8
+ async getById(id: string): Promise<CreditResponse> {
9
+ return await this.api.get<CreditResponse>(`/credit/${id}`);
10
+ }
11
+ }
@@ -0,0 +1,73 @@
1
+ import { BaseEndpoint, MovieDiscoverResult, SortOption, TvShowDiscoverResult } from '@/@types';
2
+
3
+ const BASE_DISCOVER = '/discover';
4
+
5
+ interface DiscoverQueryOptions {
6
+ language?: string;
7
+ sort_by?: SortOption;
8
+ page?: number;
9
+ 'vote_average.gte'?: number;
10
+ 'vote_count.gte'?: number;
11
+ 'vote_count.lte'?: number;
12
+ 'vote_average.lte'?: number;
13
+ with_watch_providers?: string;
14
+ watch_region?: string;
15
+ without_companies?: string;
16
+ with_watch_monetization_types?: 'flatrate' | 'free' | 'ads' | 'rent' | 'buy';
17
+ 'with_runtime.gte'?: number;
18
+ 'with_runtime.lte'?: number;
19
+ with_genres?: string;
20
+ without_genres?: string;
21
+ with_original_language?: string;
22
+ without_keywords?: string;
23
+ with_keywords?: string;
24
+ with_companies?: string;
25
+ }
26
+
27
+ interface MovieQueryOptions extends DiscoverQueryOptions {
28
+ region?: string;
29
+ certification_country?: string;
30
+ certification?: string;
31
+ 'certification.lte'?: string;
32
+ 'certification.gte'?: string;
33
+ include_adult?: boolean;
34
+ include_video?: boolean;
35
+ primary_release_year?: number;
36
+ 'primary_release_date.gte'?: string;
37
+ 'primary_release_date.lte'?: string;
38
+ 'release_date.gte'?: string;
39
+ 'release_date.lte'?: string;
40
+ with_release_type?: string;
41
+ year?: number;
42
+ with_cast?: string;
43
+ with_crew?: string;
44
+ with_people?: string;
45
+ }
46
+
47
+ interface TvShowQueryOptions extends DiscoverQueryOptions {
48
+ 'air_date.gte'?: string;
49
+ 'air_date.lte'?: string;
50
+ 'first_air_date.gte'?: string;
51
+ 'first_air_date.lte'?: string;
52
+ first_air_date_year?: number;
53
+ timezone?: string;
54
+ with_networks?: string;
55
+ include_null_first_air_dates?: boolean;
56
+ screened_theatrically?: boolean;
57
+ with_status?: string;
58
+ with_type?: string;
59
+ }
60
+
61
+ export class DiscoverEndpoint extends BaseEndpoint {
62
+ constructor(access_token: string) {
63
+ super(access_token);
64
+ }
65
+
66
+ async movie(options?: MovieQueryOptions): Promise<MovieDiscoverResult> {
67
+ return await this.api.get<MovieDiscoverResult>(`${BASE_DISCOVER}/movie`, options);
68
+ }
69
+
70
+ async tvShow(options?: TvShowQueryOptions): Promise<TvShowDiscoverResult> {
71
+ return await this.api.get<TvShowDiscoverResult>(`${BASE_DISCOVER}/tv`, options);
72
+ }
73
+ }
@@ -0,0 +1,11 @@
1
+ import { BaseEndpoint, ExternalIdOptions, FindResult } from '@/@types';
2
+
3
+ export class FindEndpoint extends BaseEndpoint {
4
+ constructor(access_token: string) {
5
+ super(access_token);
6
+ }
7
+
8
+ async byId(externalId: string, options: ExternalIdOptions): Promise<FindResult> {
9
+ return await this.api.get<FindResult>(`/find/${externalId}`, options);
10
+ }
11
+ }
@@ -0,0 +1,19 @@
1
+ import { BaseEndpoint, LanguageOption } from '@/@types';
2
+
3
+ export interface Genres {
4
+ genres: Array<{ id: number; name: string }>;
5
+ }
6
+
7
+ export class GenreEndpoint extends BaseEndpoint {
8
+ constructor(protected readonly access_token: string) {
9
+ super(access_token);
10
+ }
11
+
12
+ async movies(options?: LanguageOption): Promise<Genres> {
13
+ return await this.api.get<Genres>('/genre/movie/list', options);
14
+ }
15
+
16
+ async tv(options?: LanguageOption): Promise<Genres> {
17
+ return await this.api.get<Genres>('/genre/tv/list', options);
18
+ }
19
+ }
@@ -0,0 +1,18 @@
1
+ export * from './account';
2
+ export * from './certification';
3
+ export * from './changes';
4
+ export * from './collections';
5
+ export * from './configuration';
6
+ export * from './credits';
7
+ export * from './discover';
8
+ export * from './find';
9
+ export * from './genre';
10
+ export * from './keywords';
11
+ export * from './movies';
12
+ export * from './people';
13
+ export * from './review';
14
+ export * from './search';
15
+ export * from './trending';
16
+ export * from './tvEpisodes';
17
+ export * from './tvSeasons';
18
+ export * from './tvShows';
@@ -0,0 +1,17 @@
1
+ import { BaseEndpoint, BelongingMovies, Keyword, KeywordsOptions } from '@/@types';
2
+
3
+ const BASE_Keyword = '/keyword';
4
+
5
+ export class KeywordsEndpoint extends BaseEndpoint {
6
+ constructor(access_token: string) {
7
+ super(access_token);
8
+ }
9
+
10
+ async details(keywordId: number): Promise<Keyword> {
11
+ return await this.api.get<Keyword>(`${BASE_Keyword}/${keywordId}`);
12
+ }
13
+
14
+ async belongingMovies(keywordId: number, options?: KeywordsOptions): Promise<BelongingMovies> {
15
+ return await this.api.get<BelongingMovies>(`${BASE_Keyword}/${keywordId}/movies`, options);
16
+ }
17
+ }
@@ -0,0 +1,138 @@
1
+ import {
2
+ AlternativeTitles,
3
+ AppendToResponse,
4
+ AppendToResponseMovieKey,
5
+ BaseEndpoint,
6
+ ChangeOption,
7
+ Changes,
8
+ Credits,
9
+ ExternalIds,
10
+ Images,
11
+ Keywords,
12
+ LanguageOption,
13
+ LatestMovie,
14
+ MovieChangeValue,
15
+ MovieDetails,
16
+ MovieLists,
17
+ MoviesPlayingNow,
18
+ PageOption,
19
+ PopularMovies,
20
+ Recommendations,
21
+ RegionOption,
22
+ ReleaseDates,
23
+ Reviews,
24
+ SimilarMovies,
25
+ TopRatedMovies,
26
+ Translations,
27
+ UpcomingMovies,
28
+ Videos,
29
+ WatchProviders,
30
+ } from '@/@types';
31
+
32
+ const BASE_MOVIE = '/movie';
33
+
34
+ export interface MoviesImageSearchOptions extends LanguageOption {
35
+ /**
36
+ * a list of ISO-639-1 values to query
37
+ */
38
+ include_image_language?: string[];
39
+ }
40
+
41
+ export class MoviesEndpoint extends BaseEndpoint {
42
+ constructor(protected readonly access_token: string) {
43
+ super(access_token);
44
+ }
45
+
46
+ async details<T extends AppendToResponseMovieKey[] | undefined>(id: number, appendToResponse?: T, language?: string) {
47
+ const options = {
48
+ append_to_response: appendToResponse ? appendToResponse.join(',') : undefined,
49
+ language: language,
50
+ };
51
+
52
+ return await this.api.get<AppendToResponse<MovieDetails, T, 'movie'>>(`${BASE_MOVIE}/${id}`, options);
53
+ }
54
+
55
+ async alternativeTitles(id: number): Promise<AlternativeTitles> {
56
+ return await this.api.get<AlternativeTitles>(`${BASE_MOVIE}/${id}/alternative_titles`);
57
+ }
58
+
59
+ async changes(id: number, options?: ChangeOption): Promise<Changes<MovieChangeValue>> {
60
+ return await this.api.get<Changes<MovieChangeValue>>(`${BASE_MOVIE}/${id}/changes`, options);
61
+ }
62
+
63
+ async credits(id: number, options?: LanguageOption): Promise<Credits> {
64
+ return await this.api.get<Credits>(`${BASE_MOVIE}/${id}/credits`, options);
65
+ }
66
+
67
+ async externalIds(id: number): Promise<ExternalIds> {
68
+ return await this.api.get<ExternalIds>(`${BASE_MOVIE}/${id}/external_ids`);
69
+ }
70
+
71
+ async images(id: number, options?: MoviesImageSearchOptions): Promise<Images> {
72
+ const computedOptions = {
73
+ include_image_language: options?.include_image_language?.join(','),
74
+ language: options?.language,
75
+ };
76
+ return await this.api.get<Images>(`${BASE_MOVIE}/${id}/images`, computedOptions);
77
+ }
78
+
79
+ async keywords(id: number): Promise<Keywords> {
80
+ return await this.api.get<Keywords>(`${BASE_MOVIE}/${id}/keywords`);
81
+ }
82
+
83
+ async lists(id: number, options?: LanguageOption & PageOption): Promise<MovieLists> {
84
+ return await this.api.get<MovieLists>(`${BASE_MOVIE}/${id}/lists`, options);
85
+ }
86
+
87
+ async recommendations(id: number, options?: LanguageOption & PageOption): Promise<Recommendations> {
88
+ return await this.api.get<Recommendations>(`${BASE_MOVIE}/${id}/recommendations`, options);
89
+ }
90
+
91
+ async releaseDates(id: number): Promise<ReleaseDates> {
92
+ return await this.api.get<ReleaseDates>(`${BASE_MOVIE}/${id}/release_dates`);
93
+ }
94
+
95
+ async reviews(id: number, options?: LanguageOption & PageOption): Promise<Reviews> {
96
+ return await this.api.get<Reviews>(`${BASE_MOVIE}/${id}/reviews`, options);
97
+ }
98
+
99
+ async similar(id: number, options?: LanguageOption & PageOption): Promise<SimilarMovies> {
100
+ return await this.api.get<SimilarMovies>(`${BASE_MOVIE}/${id}/similar`, options);
101
+ }
102
+
103
+ async translations(id: number): Promise<Translations> {
104
+ return await this.api.get<Translations>(`${BASE_MOVIE}/${id}/translations`);
105
+ }
106
+
107
+ async videos(id: number, options?: LanguageOption): Promise<Videos> {
108
+ return await this.api.get<Videos>(`${BASE_MOVIE}/${id}/videos`, options);
109
+ }
110
+
111
+ /**
112
+ * Powered by JustWatch
113
+ * @param id
114
+ */
115
+ async watchProviders(id: number): Promise<WatchProviders> {
116
+ return await this.api.get<WatchProviders>(`${BASE_MOVIE}/${id}/watch/providers`);
117
+ }
118
+
119
+ async latest(): Promise<LatestMovie> {
120
+ return await this.api.get<LatestMovie>(`${BASE_MOVIE}/latest`);
121
+ }
122
+
123
+ async nowPlaying(options?: PageOption & LanguageOption & RegionOption): Promise<MoviesPlayingNow> {
124
+ return await this.api.get<MoviesPlayingNow>(`${BASE_MOVIE}/now_playing`, options);
125
+ }
126
+
127
+ async popular(options?: LanguageOption & PageOption): Promise<PopularMovies> {
128
+ return await this.api.get<PopularMovies>(`${BASE_MOVIE}/popular`, options);
129
+ }
130
+
131
+ async topRated(options?: PageOption & LanguageOption & RegionOption): Promise<TopRatedMovies> {
132
+ return await this.api.get<TopRatedMovies>(`${BASE_MOVIE}/top_rated`, options);
133
+ }
134
+
135
+ async upcoming(options?: PageOption & LanguageOption & RegionOption): Promise<UpcomingMovies> {
136
+ return await this.api.get<UpcomingMovies>(`${BASE_MOVIE}/upcoming`, options);
137
+ }
138
+ }
@@ -0,0 +1,19 @@
1
+ import { AlternativeNames, BaseEndpoint, NetworkDetails, NetworkImages } from '@/@types';
2
+
3
+ export class NetworksEndpoint extends BaseEndpoint {
4
+ constructor(protected readonly access_token: string) {
5
+ super(access_token);
6
+ }
7
+
8
+ async details(id: number): Promise<NetworkDetails> {
9
+ return await this.api.get<NetworkDetails>(`/network/${id}`);
10
+ }
11
+
12
+ async alternativeNames(id: number): Promise<AlternativeNames> {
13
+ return await this.api.get<AlternativeNames>(`/network/${id}/alternative_names`);
14
+ }
15
+
16
+ async images(id: number): Promise<NetworkImages> {
17
+ return await this.api.get<NetworkImages>(`/network/${id}/images`);
18
+ }
19
+ }