mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[scraper] uses forked rd library
This commit is contained in:
@@ -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