diff --git a/scraper/lib/cache.js b/scraper/lib/cache.js index 7fdf5a4..f904c28 100644 --- a/scraper/lib/cache.js +++ b/scraper/lib/cache.js @@ -92,7 +92,7 @@ function cacheWrapResolvedUrl(id, method) { return cacheWrap(memoryCache, `${RESOLVED_URL_KEY_PREFIX}:${id}`, method, { ttl: { RESOLVED_URL_TTL } }); } -function cacheWrapProxy(id, method) { +function cacheWrapOptions(id, method) { return cacheWrap(memoryCache, `${PROXY_KEY_PREFIX}:${id}`, method, { ttl: { PROXY_TTL } }); } @@ -102,6 +102,6 @@ module.exports = { cacheWrapMetadata, retrieveTorrentFiles, cacheWrapResolvedUrl, - cacheWrapProxy + cacheWrapOptions }; diff --git a/scraper/moch/realdebrid.js b/scraper/moch/realdebrid.js index c09a426..ec8e8ad 100644 --- a/scraper/moch/realdebrid.js +++ b/scraper/moch/realdebrid.js @@ -1,7 +1,7 @@ const { encode } = require('magnet-uri'); const RealDebridClient = require('real-debrid-api'); const namedQueue = require('named-queue'); -const { cacheWrapResolvedUrl, cacheWrapProxy } = require('../lib/cache'); +const { cacheWrapResolvedUrl, cacheWrapOptions } = require('../lib/cache'); const { getRandomProxy, getRandomUserAgent } = require('../lib/request_helper'); const unrestrictQueue = new namedQueue((task, callback) => task.method() @@ -22,7 +22,8 @@ async function resolve(ip, apiKey, infoHash, cachedFileIds, fileIndex) { async function _unrestrict(ip, apiKey, infoHash, cachedFileIds, fileIndex) { console.log(`Unrestricting ${infoHash} [${fileIndex}]`); - const RD = await getDefaultOptions(ip).then(options => new RealDebridClient(apiKey, options)); + const options = await getDefaultOptions(ip); + const RD = new RealDebridClient(apiKey, options); const torrentId = await _createOrFindTorrentId(RD, infoHash, cachedFileIds); if (torrentId) { const info = await RD.torrents.info(torrentId); @@ -74,7 +75,7 @@ function getDefaultOptions(ip) { 'User-Agent': getRandomUserAgent() } }); - return cacheWrapProxy(ip, generateOptions).catch(() => generateOptions()); + return cacheWrapOptions(ip, generateOptions).catch(() => generateOptions()); } module.exports = { resolve }; \ No newline at end of file