mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[scraper] check if episode imdbid fro eztv
This commit is contained in:
@@ -104,7 +104,7 @@ async function getImdbId(info, type) {
|
|||||||
return cacheWrapImdbId(key,
|
return cacheWrapImdbId(key,
|
||||||
() => new Promise((resolve, reject) => {
|
() => new Promise((resolve, reject) => {
|
||||||
nameToImdb({ name, year, type }, function (err, res) {
|
nameToImdb({ name, year, type }, function (err, res) {
|
||||||
if (res) {
|
if (res && !info.date) {
|
||||||
resolve(res);
|
resolve(res);
|
||||||
} else {
|
} else {
|
||||||
reject(err || new Error('failed imdbId search'));
|
reject(err || new Error('failed imdbId search'));
|
||||||
@@ -112,7 +112,7 @@ async function getImdbId(info, type) {
|
|||||||
});
|
});
|
||||||
}).catch(() => googleIt({ query, userAgent: getRandomUserAgent(), disableConsole: true })
|
}).catch(() => googleIt({ query, userAgent: getRandomUserAgent(), disableConsole: true })
|
||||||
.then(results => results.length ? results : Promise.reject('No results'))
|
.then(results => results.length ? results : Promise.reject('No results'))
|
||||||
.catch(() => bing.web(query))
|
// .catch(() => bing.web(query))
|
||||||
.then(results => results
|
.then(results => results
|
||||||
.map(result => result.link)
|
.map(result => result.link)
|
||||||
.find(result => result.includes('imdb.com/title/')))
|
.find(result => result.includes('imdb.com/title/')))
|
||||||
@@ -139,4 +139,13 @@ async function getKitsuId(info) {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { getMetadata, getImdbId, getKitsuId, escapeHTML, escapeTitle };
|
async function isEpisodeImdbId(imdbId) {
|
||||||
|
if (!imdbId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return needle('get', `https://www.imdb.com/title/${imdbId}/`, { open_timeout: 10000, follow: 2 })
|
||||||
|
.then(response => !!(response.body && response.body.includes('video.episode')))
|
||||||
|
.catch((err) => false);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { getMetadata, getImdbId, getKitsuId, isEpisodeImdbId, escapeHTML, escapeTitle };
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ const eztv = require('./eztv_api');
|
|||||||
const { Type } = require('../../lib/types');
|
const { Type } = require('../../lib/types');
|
||||||
const repository = require('../../lib/repository');
|
const repository = require('../../lib/repository');
|
||||||
const { createTorrentEntry, checkAndUpdateTorrent } = require('../../lib/torrentEntries');
|
const { createTorrentEntry, checkAndUpdateTorrent } = require('../../lib/torrentEntries');
|
||||||
|
const { isEpisodeImdbId } = require('../../lib/metadata');
|
||||||
|
|
||||||
const NAME = 'EZTV';
|
const NAME = 'EZTV';
|
||||||
const UNTIL_PAGE = 10;
|
const UNTIL_PAGE = 10;
|
||||||
@@ -63,6 +64,9 @@ async function processTorrentRecord(record) {
|
|||||||
// imdb id for talk shows is usually incorrect on eztv
|
// imdb id for talk shows is usually incorrect on eztv
|
||||||
const parsedTitle = parse(record.name);
|
const parsedTitle = parse(record.name);
|
||||||
const dateEpisode = !parsedTitle.season && parsedTitle.date;
|
const dateEpisode = !parsedTitle.season && parsedTitle.date;
|
||||||
|
if (dateEpisode && await isEpisodeImdbId(record.imdbId)) {
|
||||||
|
delete record.imdbId;
|
||||||
|
}
|
||||||
|
|
||||||
const torrent = {
|
const torrent = {
|
||||||
infoHash: record.infoHash,
|
infoHash: record.infoHash,
|
||||||
@@ -73,7 +77,7 @@ async function processTorrentRecord(record) {
|
|||||||
size: record.size,
|
size: record.size,
|
||||||
seeders: record.seeders,
|
seeders: record.seeders,
|
||||||
uploadDate: record.uploadDate,
|
uploadDate: record.uploadDate,
|
||||||
imdbId: !dateEpisode && record.imdbId,
|
imdbId: record.imdbId,
|
||||||
};
|
};
|
||||||
|
|
||||||
return createTorrentEntry(torrent).then(() => torrent);
|
return createTorrentEntry(torrent).then(() => torrent);
|
||||||
|
|||||||
Reference in New Issue
Block a user