diff --git a/package-lock.json b/package-lock.json index 05a2f90..6435ef5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1995,9 +1995,8 @@ } }, "real-debrid-api": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/real-debrid-api/-/real-debrid-api-1.0.1.tgz", - "integrity": "sha512-Rva3aZ62R/KDV7ydUALrVu8YbAuPLLmThWMlmVMshUEBQk74ybRyUv5WTvfrd9i94v+0V9YeZle0pldv5cQ2+g==", + "version": "git://github.com/TheBeastLT/node-real-debrid.git#935a5c23ae809edbcd2a111526a7f74d6767c50d", + "from": "git://github.com/TheBeastLT/node-real-debrid.git#935a5c23ae809edbcd2a111526a7f74d6767c50d", "requires": { "request": "^2.83.0" } diff --git a/package.json b/package.json index f727e23..7c03f53 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "pg": "^7.8.2", "pg-hstore": "^2.3.2", "rarbg-api": "^1.1.3", - "real-debrid-api": "^1.0.1", + "real-debrid-api": "git://github.com/TheBeastLT/node-real-debrid.git#935a5c23ae809edbcd2a111526a7f74d6767c50d", "sequelize": "^5.21.5", "sugar-date": "^2.0.6", "torrent-stream": "^1.1.0", diff --git a/scraper/lib/request_helper.js b/scraper/lib/request_helper.js index ce241d7..c9860fa 100644 --- a/scraper/lib/request_helper.js +++ b/scraper/lib/request_helper.js @@ -16,11 +16,4 @@ function getRandomProxy() { return undefined; } -function getProxy() { - if (PROXY_HOSTS && PROXY_HOSTS.length && PROXY_USERNAME && PROXY_PASSWORD) { - return `http://${PROXY_USERNAME}:${PROXY_PASSWORD}@${PROXY_HOSTS[0]}`; - } - return undefined; -} - -module.exports = { getRandomUserAgent, getRandomProxy, getProxy }; \ No newline at end of file +module.exports = { getRandomUserAgent, getRandomProxy }; \ No newline at end of file diff --git a/scraper/moch/realdebrid.js b/scraper/moch/realdebrid.js index ad35771..c7e32ed 100644 --- a/scraper/moch/realdebrid.js +++ b/scraper/moch/realdebrid.js @@ -2,7 +2,7 @@ const { encode } = require('magnet-uri'); const RealDebridClient = require('real-debrid-api'); const namedQueue = require('named-queue'); const { cacheWrapResolvedUrl } = require('../lib/cache'); -const { getProxy } = require('../lib/request_helper'); +const { getRandomProxy, getRandomUserAgent } = require('../lib/request_helper'); const unrestrictQueue = new namedQueue((task, callback) => task.method() .then(result => callback(false, result)) @@ -22,7 +22,7 @@ async function resolve(apiKey, infoHash, cachedFileIds, fileIndex) { async function _unrestrict(apiKey, infoHash, cachedFileIds, fileIndex) { console.log(`Unrestricting ${infoHash} [${fileIndex}]`); - const RD = new RealDebridClient(apiKey); + const RD = new RealDebridClient(apiKey, getDefaultOptions()); const torrentId = await _createOrFindTorrentId(RD, infoHash, cachedFileIds); if (torrentId) { const info = await RD.torrents.info(torrentId); @@ -56,7 +56,7 @@ async function _unrestrictLink(RD, link) { if (!link || !link.length) { return Promise.reject("No available links found"); } - return RD._post('unrestrict/link', { form: { link }, proxy: getProxy() }) + return RD.unrestrict.link(link) .then(unrestrictedLink => unrestrictedLink.download); // .then(unrestrictedLink => RD.streaming.transcode(unrestrictedLink.id)) // .then(transcodedLink => { @@ -67,4 +67,13 @@ async function _unrestrictLink(RD, link) { // }); } +function getDefaultOptions() { + return { + proxy: getRandomProxy(), + headers: { + 'User-Agent': getRandomUserAgent() + } + }; +} + module.exports = { resolve }; \ No newline at end of file