mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[addon] removes excessive logging from rd
This commit is contained in:
@@ -57,10 +57,9 @@ async function resolve({ apiKey, infoHash, cachedEntryInfo, fileIndex }) {
|
|||||||
const options = await getDefaultOptions(apiKey);
|
const options = await getDefaultOptions(apiKey);
|
||||||
const RD = new RealDebridClient(apiKey, options);
|
const RD = new RealDebridClient(apiKey, options);
|
||||||
const torrentId = await _createOrFindTorrentId(RD, infoHash, cachedEntryInfo, fileIndex);
|
const torrentId = await _createOrFindTorrentId(RD, infoHash, cachedEntryInfo, fileIndex);
|
||||||
console.log(`Getting torrent info ${infoHash}`)
|
|
||||||
const torrent = await _getTorrentInfo(RD, torrentId);
|
const torrent = await _getTorrentInfo(RD, torrentId);
|
||||||
if (torrent && statusReady(torrent.status)) {
|
if (torrent && statusReady(torrent.status)) {
|
||||||
console.log(`Trying unrestrict torrent ${infoHash}`)
|
console.log(`Trying to unrestrict torrent ${infoHash} [${fileIndex}]`)
|
||||||
return _unrestrictLink(RD, torrent, fileIndex);
|
return _unrestrictLink(RD, torrent, fileIndex);
|
||||||
} else if (torrent && statusDownloading(torrent.status)) {
|
} else if (torrent && statusDownloading(torrent.status)) {
|
||||||
console.log(`Downloading to RealDebrid ${infoHash} [${fileIndex}]...`);
|
console.log(`Downloading to RealDebrid ${infoHash} [${fileIndex}]...`);
|
||||||
@@ -97,13 +96,11 @@ async function _retryCreateTorrent(RD, infoHash, cachedFileIds, fileIndex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function _findTorrent(RD, infoHash, fileIndex) {
|
async function _findTorrent(RD, infoHash, fileIndex) {
|
||||||
console.log(`Finding torrent ${infoHash}`)
|
|
||||||
const torrents = await RD.torrents.get(0, 1) || [];
|
const torrents = await RD.torrents.get(0, 1) || [];
|
||||||
const foundTorrents = torrents.filter(torrent => torrent.hash.toLowerCase() === infoHash);
|
const foundTorrents = torrents.filter(torrent => torrent.hash.toLowerCase() === infoHash);
|
||||||
const nonFailedTorrents = foundTorrents.filter(torrent => !statusError(torrent.status));
|
const nonFailedTorrents = foundTorrents.filter(torrent => !statusError(torrent.status));
|
||||||
const nonFailedTorrent = await _findBestFitTorrent(RD, nonFailedTorrents, fileIndex);
|
const nonFailedTorrent = await _findBestFitTorrent(RD, nonFailedTorrents, fileIndex);
|
||||||
const foundTorrent = nonFailedTorrent || foundTorrents[0];
|
const foundTorrent = nonFailedTorrent || foundTorrents[0];
|
||||||
console.log(`Found torrent ${foundTorrent && foundTorrent.hash}`)
|
|
||||||
return foundTorrent && foundTorrent.id || Promise.reject('No recent torrent found');
|
return foundTorrent && foundTorrent.id || Promise.reject('No recent torrent found');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,16 +123,13 @@ async function _getTorrentInfo(RD, torrentId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function _createTorrentId(RD, infoHash, cachedFileIds) {
|
async function _createTorrentId(RD, infoHash, cachedFileIds) {
|
||||||
console.log(`Creating torrent ${infoHash}`)
|
|
||||||
const addedMagnet = await RD.torrents.addMagnet(encode({ infoHash }));
|
const addedMagnet = await RD.torrents.addMagnet(encode({ infoHash }));
|
||||||
await _selectTorrentFiles(RD, { id: addedMagnet.id }, cachedFileIds);
|
await _selectTorrentFiles(RD, { id: addedMagnet.id }, cachedFileIds);
|
||||||
console.log(`Selected files ${infoHash}`)
|
|
||||||
return addedMagnet.id;
|
return addedMagnet.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function _selectTorrentFiles(RD, torrent, cachedFileIds) {
|
async function _selectTorrentFiles(RD, torrent, cachedFileIds) {
|
||||||
if (cachedFileIds && !['null', 'undefined'].includes(cachedFileIds)) {
|
if (cachedFileIds && !['null', 'undefined'].includes(cachedFileIds)) {
|
||||||
console.log(`Selecting files ${torrent.hash}`)
|
|
||||||
return RD.torrents.selectFiles(torrent.id, cachedFileIds);
|
return RD.torrents.selectFiles(torrent.id, cachedFileIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user