This commit is contained in:
Wise Colt
2020-04-24 00:12:43 +03:00
parent e7d258e20b
commit 5b0f06e6ee
2 changed files with 25 additions and 20 deletions

View File

@@ -5,8 +5,8 @@ module.exports.getDetails = function (detailsId, movieOrTv, tmdbApiKey, language
if (movieOrTv == 'movie' || movieOrTv == 'tv') { if (movieOrTv == 'movie' || movieOrTv == 'tv') {
const detailURL = config.theMovieDbURL + movieOrTv + '/' + detailsId + '?api_key=' + tmdbApiKey + '&language=' + language; const detailURL = config.theMovieDbURL + movieOrTv + '/' + detailsId + '?api_key=' + tmdbApiKey + '&language=' + language;
request(detailURL, (err, resultBody, body) => { request(detailURL, (err, resultBody, body) => {
if (resultBody != '') { if (resultBody != '') {
const getJson = JSON.parse(resultBody.body); const getJson = JSON.parse(resultBody.body);
@@ -110,7 +110,7 @@ module.exports.getTrailers = function (detailsId, movieOrTv, tmdbApiKey, cb) {
else { else {
const error = null; const error = null;
const result = getJson; const result = getJson;
cb(error, result); cb(error, result);
} }
} }
@@ -132,28 +132,33 @@ module.exports.getImages = function (detailsId, movieOrTv, tmdbApiKey, cb) {
request(creditsURL, (err, resultBody, body) => { request(creditsURL, (err, resultBody, body) => {
const getJson = JSON.parse(resultBody.body); if (resultBody != []) {
const getJson = JSON.parse(resultBody.body);
if (getJson.status_code > 1) { if (getJson.status_code > 1) {
// if wrong api key error // if wrong api key error
const error = 'tmdb get images wrong api key error'; const error = 'tmdb get images wrong api key error';
const result = null;
cb(error, result);
}
else {
if (err) {
// if thmdb api connection error
const error = 'tmdb get images api connection error';
const result = null; const result = null;
cb(error, result); cb(error, result);
} }
else { else {
const error = null; if (err) {
const result = getJson; // if thmdb api connection error
cb(error, result); const error = 'tmdb get images api connection error';
const result = null;
cb(error, result);
}
else {
const error = null;
const result = getJson;
cb(error, result);
}
} }
} else {
// if wrong api key error
const error = 'error getting data';
const result = null;
cb(error, result);
} }
}); });
} }
else { else {

View File

@@ -1,6 +1,6 @@
{ {
"name": "flixinfo", "name": "flixinfo",
"version": "1.1.8", "version": "1.1.9",
"description": "Get movie detail with netflix id", "description": "Get movie detail with netflix id",
"main": "index.js", "main": "index.js",
"directories": { "directories": {