[addon] uses forked rd library

This commit is contained in:
TheBeastLT
2020-04-03 10:50:24 +02:00
parent c2e42634b7
commit 4ea86742a6
3 changed files with 11 additions and 16 deletions

View File

@@ -6,7 +6,11 @@ const RESOLVER_HOST = process.env.RESOLVER_HOST || 'http://localhost:7000';
async function applyMoch(streams, apiKey) {
const RD = new RealDebridClient(apiKey);
const hashes = streams.map(stream => stream.infoHash);
const available = await _instantAvailability(RD, hashes);
const available = await RD.torrents.instantAvailability(hashes)
.catch(error => {
console.warn('Failed cached torrent availability request: ', error);
return undefined;
});
if (available) {
streams.forEach(stream => {
const cachedEntry = available[stream.infoHash];
@@ -23,14 +27,6 @@ async function applyMoch(streams, apiKey) {
return streams;
}
async function _instantAvailability(RD, hashes) {
return RD._get(`torrents/instantAvailability/${hashes.join('/')}`)
.catch(error => {
console.warn('Failed cached torrent availability request: ', error);
return undefined;
});
}
function getCachedFileIds(fileIndex, hosterResults) {
if (!hosterResults || Array.isArray(hosterResults)) {
return [];