big change in the results returned by the api
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,3 +10,4 @@ public/src/thumbs
|
||||
.Trashes
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
.vscode/
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
const GetFlix = require('../index');
|
||||
|
||||
const getflix = new GetFlix('d9d6007d1bcf12043db5a085ae3e5bbb');
|
||||
const getInfo = async () => {
|
||||
try {
|
||||
const info = await getflix.getNetflixInfo(81159258);
|
||||
// const info = await getflix.get(80241239, 'en-EN', 'tr');
|
||||
console.log(info);
|
||||
|
||||
getInfo = async () => {
|
||||
try {
|
||||
const info = await getflix.getNetflixInfo(81082225, 'en-EN', 'en');
|
||||
console.log(info);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
290
lib/index.js
290
lib/index.js
@@ -6,135 +6,170 @@ const config = require('../config');
|
||||
// Modules
|
||||
const modules = require('./module');
|
||||
|
||||
process.setMaxListeners(0)
|
||||
|
||||
// imdb.com adresine bağlanarak imdb id'sinin geçerliliğini sorgulamayı sağlayan method
|
||||
const imdbIdReal = async (flixableFindImdbId) => {
|
||||
|
||||
const imdbIdURL = "https://www.imdb.com/title/" + flixableFindImdbId
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
request(imdbIdURL, (error, response, body) => {
|
||||
if (error) {
|
||||
reject('imdb id alinirken hata olustu')
|
||||
} else {
|
||||
const $ = cheerio.load(body, {
|
||||
normalizeWhitespace: true,
|
||||
xmlMode: true
|
||||
});
|
||||
const imdbId = ($($('[property="pageId"]')).attr('content'));
|
||||
const imdbRate = /<span itemprop="ratingValue">(.*?)<\/span>/img.exec(body)[1]
|
||||
if (imdbId == undefined) {
|
||||
reject('imdb id bulunamadi')
|
||||
} else {
|
||||
resolve({
|
||||
id: imdbId,
|
||||
rate: imdbRate
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
class FlixInfo {
|
||||
|
||||
/**
|
||||
* Get movie/show info
|
||||
* @param {string} tmdbApiKey The Movie DB Api ye ait key girilir
|
||||
* @description Netflix içeriğine ulaşmayı sağlayan sınıf
|
||||
*/
|
||||
constructor(opt = '') {
|
||||
if (opt == '') throw new Error('missing tmdb api key');
|
||||
|
||||
this.tmdbApiKey = opt;
|
||||
}
|
||||
|
||||
|
||||
getNetflixInfo(netflixId) {
|
||||
|
||||
const flixableUrl = config.filexibleTrURL + netflixId
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
request(flixableUrl, (error, response, body) => {
|
||||
|
||||
const $ = cheerio.load(body, {
|
||||
normalizeWhitespace: true,
|
||||
xmlMode: true
|
||||
});
|
||||
|
||||
const findImdb = ($($('[class="mb-2 rating-container"]')).attr()) ? ($($('[class="imdbRatingPlugin"]')).attr('data-title')) : null;
|
||||
|
||||
if (findImdb) {
|
||||
request(("https://www.imdb.com/title/" + findImdb), (error, response, body) => {
|
||||
const $ = cheerio.load(body, {
|
||||
normalizeWhitespace: true,
|
||||
xmlMode: true
|
||||
});
|
||||
const imdbCleanId = ($($('[property="pageId"]')).attr('content'));
|
||||
console.log(imdbCleanId);
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Get movie/show info
|
||||
* @param {number} netflixId Aranan netflix içeriğine ait id bilgisi girilir
|
||||
* @param {string} theMovieDbLanguage The Movie DB Api de hangi dilde arama yapılacağı girilir (e.g. tr-TR)
|
||||
* @param {string} netflixLocation flixinfo üzerinde hangi lokasyonda sorgulama yapılacağı girilir (e.g. tr -> tr.flixinfo.com)
|
||||
* @description Netflix içeriğinde id bilgisine ve netflix lokasyonuna göre arama yapmayı sağlar
|
||||
* @return {JSON}
|
||||
*/
|
||||
get(netflixId, theMovieDbLanguage, netflixLocation) {
|
||||
getNetflixInfo(netflixId, theMovieDbLanguage, netflixLocation) {
|
||||
|
||||
// Imdb id page
|
||||
const flixableURL = netflixLocation == 'tr' ? (config.filexibleTrURL + netflixId) : (config.filexibleGlobalURL + netflixId);
|
||||
|
||||
// The Movie DB api page
|
||||
const theMovieDbURL = config.theMovieDbURL;
|
||||
// API Key
|
||||
const tmdbApiKey = this.tmdbApiKey;
|
||||
// Result Object
|
||||
var returnResult = {};
|
||||
let returnResult = {};
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
request(flixableURL, (err, response, body) => {
|
||||
request(encodeURI(flixableURL), async (err, response, body) => {
|
||||
if (err) {
|
||||
returnResult = { error: 1, errorMsg: 'flixable.com connection error' };
|
||||
reject(returnResult);
|
||||
reject('flixable.com connection error: ' + err.message);
|
||||
}
|
||||
else {
|
||||
if (body) {
|
||||
const $ = cheerio.load(body, {
|
||||
normalizeWhitespace: true,
|
||||
xmlMode: true
|
||||
});
|
||||
|
||||
|
||||
let netflixButton = null;
|
||||
|
||||
try {
|
||||
// netflix butonu varsa içerik bulunuyordur.
|
||||
netflixButton = /class=\"btn btn-danger btn-block watch-on-service\"(.*?)/img.exec(body)[0];
|
||||
} catch (error) {
|
||||
returnResult = { error: 1, errorMsg: 'this content was not found!' };
|
||||
reject(returnResult)
|
||||
reject('this content was not found!')
|
||||
}
|
||||
|
||||
|
||||
if (netflixButton != null) {
|
||||
|
||||
|
||||
const findImdb = ($($('[class="mb-2 rating-container"]')).attr());
|
||||
let imdbId = null
|
||||
let imdbRate = null
|
||||
let netflixSeasonNumber = null
|
||||
let netflixRuntime = null
|
||||
let tmdbURL, netflixTitle
|
||||
// flixable'da bulunan imdb id (bu id değişmiş olabileceğinden imdb.com üzerinden kontrol ediliyor)
|
||||
const findFlixableImdbId = ($($('[class="mb-2 rating-container"]')).attr()) ? ($($('[class="imdbRatingPlugin"]')).attr('data-title')) : null;
|
||||
// media type (movie or tv show)
|
||||
const type = netflixLocation == 'tr' ? (body.search("Sezon") > 0 ? 'tv' : 'movie') : (body.search("Season") > 0 ? 'tv' : 'movie');
|
||||
// netflix üzerindeki overview bilgisi
|
||||
const netflixOverview = ($($('[name="description"]')).attr('content'));
|
||||
const netflixPoster = ($($('[class="img lazyload poster"]')).attr('data-src'));
|
||||
let tmdbURL
|
||||
let title
|
||||
|
||||
if (theMovieDbLanguage) {
|
||||
|
||||
// Sayfada imdb id varsa, tmdb üzerinden imdb id'ye göre arama yapılır
|
||||
if (findImdb) {
|
||||
const imdbId = ($($('[class="imdbRatingPlugin"]')).attr('data-title'));
|
||||
tmdbURL = theMovieDbURL + 'find/' + imdbId + '?api_key=' + tmdbApiKey + '&language=' + theMovieDbLanguage + '&external_source=imdb_id';
|
||||
}
|
||||
// Sayfada imdb id yoksa, tmdb üzerinden title ve year'a göre arama yapılır
|
||||
else {
|
||||
// netlflix üzerindeki poster url
|
||||
const netflixPosterUrl = ($($('[class="img lazyload poster"]')).attr('data-src'));
|
||||
// netflix üzerindeki age rate bilgisi
|
||||
const netflixAgeRates = /<span class="border border-secondary mr-2 px-1">(.*?)<\/span>/img.exec(body)[1]
|
||||
// find title
|
||||
const findTitle = ($($('[property="og:title"]')).attr('content'));
|
||||
const splitString = findTitle.split("- Netflix");
|
||||
title = splitString[0].split("(")[0].trim();
|
||||
const year = splitString[0].split("(")[1].split(")")[0].trim();
|
||||
// create (find) tmdb api url
|
||||
tmdbURL = theMovieDbURL + 'search/' + type + '?api_key=' + tmdbApiKey + '&language=' + theMovieDbLanguage + '&query=' + title + '&first_air_date_year=' + year;
|
||||
// netflix title
|
||||
netflixTitle = splitString[0].split("(")[0].trim();
|
||||
// netflix year
|
||||
const netflixYear = splitString[0].split("(")[1].split(")")[0].trim();
|
||||
// type tv ise sezon sayısını, movie ise filmin süresini ayarlar
|
||||
if (type == 'tv') {
|
||||
netflixSeasonNumber = (/<\/span><span>(.*?)<\/h6>/img.exec(body)[1]).split('</span> ')[0]
|
||||
} else {
|
||||
netflixRuntime = (/<\/span><span>(.*?)<\/h6>/img.exec(body)[1]).split('</span> ')[0]
|
||||
}
|
||||
// genre ayarlar
|
||||
let netflixGenres = []
|
||||
const netflixGenresFind = body.match(/<a href="\/genre\/(.*?)<\/a>/img)
|
||||
if (netflixGenresFind) {
|
||||
netflixGenresFind.forEach((genre) => {
|
||||
netflixGenres.push((/\/">(.*?)<\/a>/img).exec(genre)[1])
|
||||
})
|
||||
}
|
||||
// actor name ayarlar
|
||||
let netflixCast = []
|
||||
const netflixActorNamesFind = body.match(/<a href="\/actor\/\?name=(.*?)<\/a>/img)
|
||||
if (netflixActorNamesFind) {
|
||||
netflixActorNamesFind.forEach((actors) => {
|
||||
netflixCast.push((/\">(.*?)<\/a>/img).exec(actors)[1])
|
||||
})
|
||||
}
|
||||
|
||||
request(encodeURI(tmdbURL), (err, resultBody, body) => {
|
||||
if (theMovieDbLanguage) {
|
||||
// Sayfada imdb id varsa, tmdb üzerinden imdb id'ye göre arama yapılır
|
||||
if (findFlixableImdbId) {
|
||||
const imdb = await imdbIdReal(findFlixableImdbId)
|
||||
imdbId = imdb.id
|
||||
imdbRate = imdb.rate
|
||||
tmdbURL = theMovieDbURL + 'find/' + imdbId + '?api_key=' + tmdbApiKey + '&language=' + theMovieDbLanguage + '&external_source=imdb_id';
|
||||
}
|
||||
else {
|
||||
// Sayfada imdb id yoksa, tmdb üzerinden title ve year'a göre arama yapılır
|
||||
tmdbURL = theMovieDbURL + 'search/' + type + '?api_key=' + tmdbApiKey + '&language=' + theMovieDbLanguage + '&query=' + netflixTitle + '&first_air_date_year=' + netflixYear;
|
||||
}
|
||||
|
||||
request(encodeURI(tmdbURL), async (err, resultBody, body) => {
|
||||
|
||||
if (err) {
|
||||
// if thmdb api connection error
|
||||
reject('tmdb api find id connection error: ' + err.message)
|
||||
} else {
|
||||
|
||||
if (resultBody) {
|
||||
// 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' };
|
||||
reject(returnResult)
|
||||
}
|
||||
else {
|
||||
|
||||
if (err) {
|
||||
// if thmdb api connection error
|
||||
returnResult = { error: 1, errorMsg: 'tmdb find id connection api error' };
|
||||
reject(returnResult)
|
||||
reject('tmdb find id wrong api key error')
|
||||
}
|
||||
else {
|
||||
|
||||
let result;
|
||||
|
||||
if (findImdb) {
|
||||
if (imdbId) {
|
||||
result = type == 'movie' ? getJson.movie_results : getJson.tv_results
|
||||
|
||||
} else {
|
||||
@@ -146,64 +181,91 @@ class FlixInfo {
|
||||
|
||||
const thmdbId = result[0].id;
|
||||
|
||||
try {
|
||||
// Get detail info
|
||||
modules.getDetails(thmdbId, type, tmdbApiKey, theMovieDbLanguage, (err, getDetailResult) => {
|
||||
|
||||
if (err) {
|
||||
returnResult = { error: 1, errorMsg: err };
|
||||
reject(returnResult);
|
||||
}
|
||||
else {
|
||||
const getDetailResult = await modules.getTmdbDetails('details', thmdbId, type, tmdbApiKey, theMovieDbLanguage)
|
||||
// Get credits info
|
||||
modules.getCredits(thmdbId, type, tmdbApiKey, (err, getCreditsResult) => {
|
||||
if (err) {
|
||||
returnResult = { error: 1, errorMsg: err };
|
||||
reject(returnResult);
|
||||
}
|
||||
else {
|
||||
const getCreditsResult = await modules.getTmdbDetails('credits', thmdbId, type, tmdbApiKey)
|
||||
// Get images info
|
||||
modules.getImages(thmdbId, type, tmdbApiKey, (err, getImagesResult) => {
|
||||
if (err) {
|
||||
returnResult = { error: 1, errorMsg: err };
|
||||
reject(returnResult);
|
||||
const getImagesResult = await modules.getTmdbDetails('images', thmdbId, type, tmdbApiKey)
|
||||
// Get trailers
|
||||
const getTrailersResult = await modules.getTmdbDetails('trailers', thmdbId, type, tmdbApiKey)
|
||||
|
||||
// Result Object
|
||||
result = {
|
||||
result: 1,
|
||||
error: 0,
|
||||
watch: type,
|
||||
imdb: {
|
||||
// imdb üzerinden id alınamadıysa tmdb üzerinden alınmaya çalışılır. tmdb'de de yoksa null döner
|
||||
id: (imdbId != null ? imdbId : (getDetailResult.imdb_id != undefined ? getDetailResult.imdb_id : null)),
|
||||
rate: imdbRate
|
||||
},
|
||||
netflix: {
|
||||
title: netflixTitle,
|
||||
year: netflixYear,
|
||||
poster_url: netflixPosterUrl,
|
||||
age_rates: netflixAgeRates,
|
||||
season: netflixSeasonNumber,
|
||||
runtime: netflixRuntime,
|
||||
overview: netflixOverview,
|
||||
genres: netflixGenres,
|
||||
cast: netflixCast
|
||||
},
|
||||
tmdb: {
|
||||
details: getDetailResult,
|
||||
credits: getCreditsResult,
|
||||
images: getImagesResult,
|
||||
trailers: getTrailersResult
|
||||
}
|
||||
};
|
||||
resolve(result);
|
||||
} catch (error) {
|
||||
reject('tmdb bilgileri alinirken hata olustu: ' + error);
|
||||
}
|
||||
}
|
||||
else {
|
||||
modules.getTrailers(thmdbId, type, tmdbApiKey, (err, getTrailersResult) => {
|
||||
if (err) {
|
||||
returnResult = { error: 1, errorMsg: err };
|
||||
reject(returnResult);
|
||||
// Tmdb verisi yoksa sadece netflix verisi döndür
|
||||
result = {
|
||||
result: 1,
|
||||
error: 0,
|
||||
watch: type,
|
||||
imdb: {
|
||||
id: imdbId,
|
||||
rate: imdbRate
|
||||
},
|
||||
netflix: {
|
||||
title: netflixTitle,
|
||||
year: netflixYear,
|
||||
age_rates: netflixAgeRates,
|
||||
season: netflixSeasonNumber,
|
||||
runtime: netflixRuntime,
|
||||
overview: netflixOverview,
|
||||
genres: netflixGenres,
|
||||
cast: netflixCast
|
||||
},
|
||||
tmdb: null
|
||||
};
|
||||
resolve(result);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
getDetailResult.netflix_overview = netflixOverview;
|
||||
getDetailResult.netflix_poster = netflixPoster;
|
||||
getDetailResult.netflix_title = title;
|
||||
returnResult = { result: 1, error: 0, watch: type, details: getDetailResult, credits: getCreditsResult, images: getImagesResult, trailers: getTrailersResult };
|
||||
resolve(returnResult);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
// Return the empty result if tmdb return empty
|
||||
const returnResult = { result: 0, error: 1, msg: 'tmdb api return is empty' };
|
||||
reject(returnResult)
|
||||
}
|
||||
// thmdb verisi hatalı döndüyse
|
||||
reject('tmdb api result.body hatalı döndü')
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
returnResult = { error: 1, errorMsg: 'language parameters not found.' };
|
||||
reject(returnResult)
|
||||
// language bilgisi hatalı
|
||||
reject('language parameters not found')
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Return the empty result if imdb id cannot be found
|
||||
const returnResult = { result: 0, error: 0, msg: 'imdb id cannot be found' };
|
||||
reject(returnResult)
|
||||
reject('imdb id cannot be found')
|
||||
}
|
||||
} else {
|
||||
reject('netflix verileri alınamadı')
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
181
lib/module.js
181
lib/module.js
@@ -1,169 +1,54 @@
|
||||
const config = require('../config');
|
||||
const request = require('request');
|
||||
|
||||
module.exports.getDetails = function (detailsId, movieOrTv, tmdbApiKey, language, cb) {
|
||||
module.exports.getTmdbDetails = function (getParamaters, thmdbId, type, tmdbApiKey, language) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
if (movieOrTv == 'movie' || movieOrTv == 'tv') {
|
||||
if (type == 'movie' || type == 'tv') {
|
||||
|
||||
const detailURL = config.theMovieDbURL + movieOrTv + '/' + detailsId + '?api_key=' + tmdbApiKey + '&language=' + language;
|
||||
let url
|
||||
|
||||
request(detailURL, (err, resultBody, body) => {
|
||||
switch (getParamaters) {
|
||||
case 'details':
|
||||
url = config.theMovieDbURL + type + '/' + thmdbId + '?api_key=' + tmdbApiKey + '&language=' + language;
|
||||
break;
|
||||
case 'credits':
|
||||
url = config.theMovieDbURL + type + '/' + thmdbId + '/credits?api_key=' + tmdbApiKey + '&language=en-US';
|
||||
break;
|
||||
case 'trailers':
|
||||
url = config.theMovieDbURL + type + '/' + thmdbId + '/videos?api_key=' + tmdbApiKey;
|
||||
break;
|
||||
case 'images':
|
||||
url = config.theMovieDbURL + type + '/' + thmdbId + '/images?api_key=' + tmdbApiKey + '&language=en-US&include_image_language=en,null';
|
||||
break;
|
||||
}
|
||||
|
||||
request(encodeURI(url), (err, resultBody, body) => {
|
||||
|
||||
if (err) {
|
||||
// if thmdb api connection error
|
||||
reject('tmdb get detail api connection error');
|
||||
}
|
||||
else {
|
||||
if (resultBody != '') {
|
||||
const getJson = JSON.parse(resultBody.body);
|
||||
|
||||
if (getJson.status_code > 1) {
|
||||
// if wrong api key error
|
||||
const error = 'tmdb get detail wrong api key error';
|
||||
const result = null;
|
||||
cb(error, result);
|
||||
reject('tmdb get detail wrong api key error');
|
||||
}
|
||||
else {
|
||||
if (err) {
|
||||
// if thmdb api connection error
|
||||
const error = 'tmdb get detail api connection error';
|
||||
const result = null;
|
||||
cb(error, result);
|
||||
}
|
||||
else {
|
||||
const error = null;
|
||||
const result = getJson;
|
||||
cb(error, result);
|
||||
}
|
||||
resolve(getJson);
|
||||
}
|
||||
} else {
|
||||
const error = 'tmdb get detail api connection error';
|
||||
const result = null;
|
||||
cb(error, result);
|
||||
// request sonucu boş dönmüşse null döndür
|
||||
resolve(null)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
const error = 'tmdb get detail wrong watch parameter';
|
||||
const result = null;
|
||||
cb(error, result);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.getCredits = function (detailsId, movieOrTv, tmdbApiKey, cb) {
|
||||
|
||||
if (movieOrTv == 'movie' || movieOrTv == 'tv') {
|
||||
|
||||
const creditsURL = config.theMovieDbURL + movieOrTv + '/' + detailsId + '/credits?api_key=' + tmdbApiKey + '&language=en-US';
|
||||
|
||||
request(creditsURL, (err, resultBody, body) => {
|
||||
|
||||
const getJson = JSON.parse(resultBody.body);
|
||||
|
||||
if (getJson.status_code > 1) {
|
||||
// if wrong api key error
|
||||
const error = 'tmdb get credits wrong api key error';
|
||||
const result = null;
|
||||
cb(error, result);
|
||||
}
|
||||
else {
|
||||
if (err) {
|
||||
// if thmdb api connection error
|
||||
const error = 'tmdb get credits api connection error';
|
||||
const result = null;
|
||||
cb(error, result);
|
||||
}
|
||||
else {
|
||||
const error = null;
|
||||
const result = getJson;
|
||||
cb(error, result);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
else {
|
||||
const error = 'tmdb get credits wrong watch parameter';
|
||||
const result = null;
|
||||
cb(error, result);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.getTrailers = function (detailsId, movieOrTv, tmdbApiKey, cb) {
|
||||
|
||||
if (movieOrTv == 'movie' || movieOrTv == 'tv') {
|
||||
|
||||
// https://api.themoviedb.org/3/movie/157336/videos?api_key=API-KEY
|
||||
const trailersURL = config.theMovieDbURL + movieOrTv + '/' + detailsId + '/videos?api_key=' + tmdbApiKey;
|
||||
|
||||
request(trailersURL, (err, resultBody, body) => {
|
||||
|
||||
const getJson = JSON.parse(resultBody.body);
|
||||
|
||||
if (getJson.status_code > 1) {
|
||||
// if wrong api key error
|
||||
const error = 'tmdb get credits wrong api key error';
|
||||
const result = null;
|
||||
cb(error, result);
|
||||
}
|
||||
else {
|
||||
if (err) {
|
||||
// if thmdb api connection error
|
||||
const error = 'tmdb get trailers api connection error';
|
||||
const result = null;
|
||||
cb(error, result);
|
||||
}
|
||||
else {
|
||||
const error = null;
|
||||
const result = getJson;
|
||||
|
||||
cb(error, result);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
else {
|
||||
const error = 'tmdb get trailers wrong watch parameter';
|
||||
const result = null;
|
||||
cb(error, result);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.getImages = function (detailsId, movieOrTv, tmdbApiKey, cb) {
|
||||
|
||||
if (movieOrTv == 'movie' || movieOrTv == 'tv') {
|
||||
|
||||
const creditsURL = config.theMovieDbURL + movieOrTv + '/' + detailsId + '/images?api_key=' + tmdbApiKey + '&language=en-US&include_image_language=en,null';
|
||||
|
||||
request(creditsURL, (err, resultBody, body) => {
|
||||
|
||||
if (resultBody != []) {
|
||||
const getJson = JSON.parse(resultBody.body);
|
||||
if (getJson.status_code > 1) {
|
||||
// if 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;
|
||||
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 {
|
||||
const error = 'tmdb get images wrong watch parameter';
|
||||
const result = null;
|
||||
cb(error, result);
|
||||
reject('tmdb get detail wrong watch parameter');
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "flixinfo",
|
||||
"version": "1.2.5",
|
||||
"version": "1.3.0",
|
||||
"description": "Get movie detail with netflix id",
|
||||
"main": "index.js",
|
||||
"directories": {
|
||||
|
||||
Reference in New Issue
Block a user