add search by language
This commit is contained in:
@@ -3,7 +3,7 @@ const GetFlix = require('../index');
|
|||||||
const getflix = new GetFlix('d9d6007d1bcf12043db5a085ae3e5bbb');
|
const getflix = new GetFlix('d9d6007d1bcf12043db5a085ae3e5bbb');
|
||||||
const getInfo = async () => {
|
const getInfo = async () => {
|
||||||
try {
|
try {
|
||||||
const info = await getflix.get(80244780);
|
const info = await getflix.get(80209184, 'tr-TR');
|
||||||
console.log(info);
|
console.log(info);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
12
lib/index.js
12
lib/index.js
@@ -20,7 +20,7 @@ class FlixInfo {
|
|||||||
* @param {number} netflixId
|
* @param {number} netflixId
|
||||||
* @return {JSON}
|
* @return {JSON}
|
||||||
*/
|
*/
|
||||||
get(netflixId) {
|
get(netflixId, language) {
|
||||||
|
|
||||||
// Imdb id page
|
// Imdb id page
|
||||||
const flixableURL = config.filexibleURL + netflixId;
|
const flixableURL = config.filexibleURL + netflixId;
|
||||||
@@ -59,13 +59,14 @@ class FlixInfo {
|
|||||||
if (netflixButton != null) {
|
if (netflixButton != null) {
|
||||||
const imdbId = ($($('[class="imdbRatingPlugin"]')).attr('data-title'));
|
const imdbId = ($($('[class="imdbRatingPlugin"]')).attr('data-title'));
|
||||||
|
|
||||||
if (imdbId) {
|
if (imdbId && language) {
|
||||||
// create (find) tmdb api url
|
// create (find) tmdb api url
|
||||||
const tmdbURL = theMovieDbURL + 'find/' + imdbId + '?api_key=' + tmdbApiKey + '&language=en-EN&external_source=imdb_id'
|
const tmdbURL = theMovieDbURL + 'find/' + imdbId + '?api_key=' + tmdbApiKey + '&language=' + language + '&external_source=imdb_id';
|
||||||
|
|
||||||
request(tmdbURL, (err, resultBody, body) => {
|
request(tmdbURL, (err, resultBody, body) => {
|
||||||
// Api find all result (for get tmdb id)
|
// Api find all result (for get tmdb id)
|
||||||
const getJson = JSON.parse(resultBody.body);
|
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
|
||||||
returnResult = { error: 1, errorMsg: 'tmdb find id wrong api key error' };
|
returnResult = { error: 1, errorMsg: 'tmdb find id wrong api key error' };
|
||||||
@@ -92,7 +93,8 @@ class FlixInfo {
|
|||||||
var thmdbId = getJson.tv_results[0].id;
|
var thmdbId = getJson.tv_results[0].id;
|
||||||
}
|
}
|
||||||
// Get detail info
|
// Get detail info
|
||||||
modules.getDetails(thmdbId, watchParameter, tmdbApiKey, (err, getDetailResult) => {
|
modules.getDetails(thmdbId, watchParameter, tmdbApiKey, language,(err, getDetailResult) => {
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
returnResult = { error: 1, errorMsg: err };
|
returnResult = { error: 1, errorMsg: err };
|
||||||
reject(returnResult);
|
reject(returnResult);
|
||||||
@@ -130,7 +132,7 @@ class FlixInfo {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
returnResult = { error: 1, errorMsg: 'imdb id not found.' };
|
returnResult = { error: 1, errorMsg: 'imdb id or language parameters not found.' };
|
||||||
reject(returnResult)
|
reject(returnResult)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
const config = require('../config');
|
const config = require('../config');
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
|
|
||||||
module.exports.getDetails = function (detailsId, movieOrTv, tmdbApiKey, cb) {
|
module.exports.getDetails = function (detailsId, movieOrTv, tmdbApiKey, language, cb) {
|
||||||
|
|
||||||
if (movieOrTv == 'movie' || movieOrTv == 'tv') {
|
if (movieOrTv == 'movie' || movieOrTv == 'tv') {
|
||||||
|
|
||||||
const detailURL = config.theMovieDbURL + movieOrTv + '/' + detailsId + '?api_key=' + tmdbApiKey + '&language=en-US';
|
const detailURL = config.theMovieDbURL + movieOrTv + '/' + detailsId + '?api_key=' + tmdbApiKey + '&language=' + language;
|
||||||
|
|
||||||
request(detailURL, (err, resultBody, body) => {
|
request(detailURL, (err, resultBody, body) => {
|
||||||
|
|
||||||
|
|||||||
3187
package-lock.json
generated
Normal file
3187
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user