add netflix info method
This commit is contained in:
30
lib/index.js
30
lib/index.js
@@ -14,6 +14,35 @@ class FlixInfo {
|
||||
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
|
||||
@@ -87,7 +116,6 @@ class FlixInfo {
|
||||
|
||||
request(encodeURI(tmdbURL), (err, resultBody, body) => {
|
||||
// Api find all result (for get tmdb id)
|
||||
|
||||
const getJson = JSON.parse(resultBody.body);
|
||||
|
||||
if (getJson.status_code > 1) {
|
||||
|
||||
Reference in New Issue
Block a user