|
125 | 125 | this.initKeyboardShortcuts();
|
126 | 126 | healthButton.render();
|
127 | 127 |
|
128 |
| - if (curSynopsis.vstatus !== null && curSynopsis.cast === '') { |
129 |
| - this.showCast(); |
130 |
| - } |
131 |
| - |
132 | 128 | $('[data-toggle="tooltip"]').tooltip({
|
133 | 129 | html: true
|
134 | 130 | });
|
|
214 | 210 | }
|
215 | 211 | },
|
216 | 212 |
|
217 |
| - getMetaData: function () { |
| 213 | + getMetaData: async function () { |
218 | 214 | curSynopsis.vstatus = false;
|
219 | 215 | var imdb = this.model.get('imdb_id'),
|
220 |
| - api_key = Settings.tmdb.api_key, |
221 |
| - lang = Settings.language, |
222 |
| - movie = (function () { |
223 |
| - var tmp = null; |
224 |
| - $.ajax({ |
225 |
| - url: 'http://api.themoviedb.org/3/movie/' + imdb + '?api_key=' + api_key + '&language=' + lang + '&append_to_response=videos,credits', |
226 |
| - type: 'get', |
227 |
| - dataType: 'json', |
228 |
| - timeout: 5000, |
229 |
| - async: false, |
230 |
| - global: false, |
231 |
| - success: function (data) { |
232 |
| - tmp = data; |
233 |
| - } |
234 |
| - }); |
235 |
| - return tmp; |
236 |
| - }()); |
| 216 | + api_key = Settings.tmdb.api_key, |
| 217 | + lang = Settings.language; |
| 218 | + const response = await fetch('http://api.themoviedb.org/3/movie/' + imdb + '?api_key=' + api_key + '&language=' + lang + '&append_to_response=videos,credits'); |
| 219 | + const movie = await response.json(); |
| 220 | + |
237 | 221 | (!this.model.get('synopsis') || (Settings.translateSynopsis && Settings.language !== 'en')) && movie && movie.overview ? this.model.set('synopsis', movie.overview) : null;
|
238 | 222 | (!this.model.get('rating') || this.model.get('rating') === '0' || this.model.get('rating') === '0.0') && movie && movie.vote_average ? this.model.set('rating', movie.vote_average) : null;
|
239 | 223 | (!this.model.get('runtime') || this.model.get('runtime') === '0') && movie && movie.runtime ? this.model.set('runtime', movie.runtime) : null;
|
|
249 | 233 | }
|
250 | 234 | // Fallback to english when source and TMDb call in default language that is other than english fail to fetch synopsis
|
251 | 235 | if (!this.model.get('synopsis') && Settings.language !== 'en') {
|
252 |
| - movie = (function () { |
253 |
| - var tmp = null; |
254 |
| - $.ajax({ |
255 |
| - url: 'http://api.themoviedb.org/3/movie/' + imdb + '?api_key=' + api_key, |
256 |
| - type: 'get', |
257 |
| - dataType: 'json', |
258 |
| - timeout: 5000, |
259 |
| - async: false, |
260 |
| - global: false, |
261 |
| - success: function (data) { |
262 |
| - tmp = data; |
263 |
| - } |
264 |
| - }); |
265 |
| - return tmp; |
266 |
| - }()); |
267 |
| - movie && movie.overview ? this.model.set('synopsis', movie.overview) : null; |
| 236 | + const responseEn = await fetch('http://api.themoviedb.org/3/movie/' + imdb + '?api_key=' + api_key); |
| 237 | + const movieEn = await responseEn.json(); |
| 238 | + movieEn && movieEn.overview ? this.model.set('synopsis', movieEn.overview) : null; |
| 239 | + } |
| 240 | + |
| 241 | + if (curSynopsis.vstatus === false && curSynopsis.cast === '') { |
| 242 | + this.showCast(); |
268 | 243 | }
|
269 | 244 | },
|
270 | 245 |
|
|
400 | 375 | }
|
401 | 376 | },
|
402 | 377 |
|
403 |
| - openTmdb: function(e) { |
| 378 | + openTmdb: async function(e) { |
404 | 379 | let imdb = this.model.get('imdb_id'),
|
405 | 380 | tmdb = this.model.get('tmdb_id'),
|
406 | 381 | api_key = Settings.tmdb.api_key;
|
407 | 382 |
|
408 | 383 | if (!tmdb && !this.model.get('getmetarunned')) {
|
409 |
| - let movie = (function () { |
410 |
| - let tmp = null; |
411 |
| - $.ajax({ |
412 |
| - url: 'http://api.themoviedb.org/3/find/' + imdb + '?api_key=' + api_key + '&external_source=imdb_id', |
413 |
| - type: 'get', |
414 |
| - dataType: 'json', |
415 |
| - timeout: 5000, |
416 |
| - async: false, |
417 |
| - global: false, |
418 |
| - success: function (data) { |
419 |
| - tmp = data; |
420 |
| - } |
421 |
| - }); |
422 |
| - return tmp; |
423 |
| - }()); |
| 384 | + const response = await fetch('http://api.themoviedb.org/3/movie/' + imdb + '?api_key=' + api_key + '&external_source=imdb_id'); |
| 385 | + const movie = await response.json(); |
424 | 386 | movie && movie.movie_results && movie.movie_results[0] && movie.movie_results[0].id ? this.model.set('tmdb_id', movie.movie_results[0].id) : null;
|
425 | 387 | tmdb = this.model.get('tmdb_id');
|
426 | 388 | }
|
|
0 commit comments