test update

This commit is contained in:
Wise Colt
2019-01-02 19:34:35 +03:00
parent ac8a4dd8d9
commit ac7bfd2925
3 changed files with 43 additions and 20 deletions

View File

@@ -41,14 +41,14 @@ class FlixInfo {
if (imdbResult) {
$('[class="imdbRatingPlugin"]').each(function (i, element) {
// find imdb id attribute and catch
const imdbId = $(this).attr('data-title');
// create (find) tmdb api url
const tmdbURL = theMovieDbURL + 'find/' + imdbId + '?api_key=' + tmdbApiKey + '&language=en-EN&external_source=imdb_id'
request(tmdbURL, (err, resultBody, body) => {
// Api find all result (for get tmdb id)
const getJson = JSON.parse(resultBody.body);
if (getJson.status_code > 1) {
// if wrong api key error
returnResult = { error: 1, errorMsg: 'tmdb find id wrong api key error' };
@@ -62,8 +62,10 @@ class FlixInfo {
cb(returnResult)
}
else {
// if tmdb api result not empty
if (getJson.tv_results.length || getJson.movie_results.length) {
if (getJson.movie_results.length) {
var watchParameter = 'movie';
var thmdbId = getJson.movie_results[0].id;
@@ -93,7 +95,7 @@ class FlixInfo {
cb(returnResult);
}
else {
returnResult = { result: 1, error: 0, tv_results: getDetailResult, credits: getCreditsResult, images: getImagesResult };
returnResult = { result: 1, error: 0, watch: watchParameter, details: getDetailResult, credits: getCreditsResult, images: getImagesResult };
cb(returnResult);
}
});
@@ -104,7 +106,7 @@ class FlixInfo {
}
else {
// Return the empty result if tmdb return empty
const returnResult = { result: 0, error: 0 };
const returnResult = { result: 0, error: 0, msg: 'tmdb api return is empty'};
cb(returnResult)
}
}
@@ -114,7 +116,7 @@ class FlixInfo {
}
else {
// Return the empty result if imdb id cannot be found
const returnResult = { result: 0, error: 0 };
const returnResult = { result: 0, error: 0, msg: 'imdb id cannot be found' };
cb(returnResult)
}
}