[scraper] reduces number of calls to 1337x

This commit is contained in:
TheBeastLT
2020-10-02 12:49:45 +02:00
parent 42714d19a9
commit 5426707dd9
5 changed files with 18 additions and 17 deletions

View File

@@ -4,7 +4,7 @@ const Sugar = require('sugar-date');
const decode = require('magnet-uri');
const Promises = require('../../lib/promises');
const { escapeHTML } = require('../../lib/metadata');
const { defaultOptionsWithProxy } = require('../../lib/request_helper');
const { getRandomUserAgent, defaultOptionsWithProxy } = require('../../lib/request_helper');
const defaultProxies = [
'https://1337x.to'
@@ -80,7 +80,7 @@ function browse(config = {}, retries = 2) {
function singleRequest(requestUrl, config = {}) {
const timeout = config.timeout || defaultTimeout;
const options = { ...defaultOptionsWithProxy(), open_timeout: timeout, follow: 2 };
const options = { userAgent: getRandomUserAgent(), open_timeout: timeout, follow: 2 };
return needle('get', requestUrl, options)
.then((response) => {

View File

@@ -56,6 +56,10 @@ async function scrapeLatestTorrentsForCategory(category, page = 1) {
}
async function processTorrentRecord(record) {
if (await checkAndUpdateTorrent({ provider: NAME, ...record })) {
return record;
}
const torrentFound = await leetx.torrent(record.torrentId).catch(() => undefined);
if (!torrentFound || !TYPE_MAPPING[torrentFound.category]) {
@@ -65,9 +69,6 @@ async function processTorrentRecord(record) {
console.warn(`Incorrect upload date for [${torrentFound.infoHash}] ${torrentFound.name}`);
return;
}
if (await checkAndUpdateTorrent(torrentFound)) {
return torrentFound;
}
const torrent = {
infoHash: torrentFound.infoHash,

View File

@@ -639,7 +639,7 @@
},
"Grisaia no Meikyuu": {
"showId": "159",
"kitsu_id": "11236"
"kitsu_id": "10154"
},
"Grisaia no Rakuen": {
"showId": "160",