[scraper] uses forked rd library
This commit is contained in:
5
package-lock.json
generated
5
package-lock.json
generated
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 };
|
||||
module.exports = { getRandomUserAgent, getRandomProxy };
|
||||
@@ -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 };
|
||||
Reference in New Issue
Block a user