Skip to content

Commit

Permalink
Disable cache check
Browse files Browse the repository at this point in the history
  • Loading branch information
arvida42 committed Nov 22, 2024
1 parent 4f34ae8 commit 432ced4
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/lib/debrid/realdebrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,20 @@ export default class RealDebrid {
}

async getTorrentsCached(torrents, isValidCachedFiles){
const hashList = torrents.map(torrent => torrent.infos.infoHash).filter(Boolean);
const res = await this.#request('GET', `/torrents/instantAvailability/${hashList.join('/')}`);
return torrents.filter(torrent => {
const cachedFiles = [];
const caches = (res[torrent.infos.infoHash]?.rd || []).filter(this.#isVideoCache);
for(const cache of caches){
for(const file of Object.values(cache)){
const f = {name: file.filename, size: file.filesize};
if(!cachedFiles.includes(f))cachedFiles.push(f);
}
}
return cachedFiles.length > 0 && isValidCachedFiles(cachedFiles);
});
return [];
// const hashList = torrents.map(torrent => torrent.infos.infoHash).filter(Boolean);
// const res = await this.#request('GET', `/torrents/instantAvailability/${hashList.join('/')}`);
// return torrents.filter(torrent => {
// const cachedFiles = [];
// const caches = (res[torrent.infos.infoHash]?.rd || []).filter(this.#isVideoCache);
// for(const cache of caches){
// for(const file of Object.values(cache)){
// const f = {name: file.filename, size: file.filesize};
// if(!cachedFiles.includes(f))cachedFiles.push(f);
// }
// }
// return cachedFiles.length > 0 && isValidCachedFiles(cachedFiles);
// });
}

async getProgressTorrents(torrents){
Expand Down Expand Up @@ -83,13 +84,14 @@ export default class RealDebrid {

if(torrent.status == 'waiting_files_selection'){

const caches = await this.#request('GET', `/torrents/instantAvailability/${torrent.hash}`);
const bestCache = (caches[torrent.hash]?.rd || [])
.filter(cache => cache[fileId] && this.#isVideoCache(cache))
.sort((a, b) => Object.values(b).length - Object.values(a).length)
.shift();
// const caches = await this.#request('GET', `/torrents/instantAvailability/${torrent.hash}`);
// const bestCache = (caches[torrent.hash]?.rd || [])
// .filter(cache => cache[fileId] && this.#isVideoCache(cache))
// .sort((a, b) => Object.values(b).length - Object.values(a).length)
// .shift();

const fileIds = bestCache ? Object.keys(bestCache) : torrent.files.filter(file => isVideo(file.path)).map(file => file.id);
// const fileIds = bestCache ? Object.keys(bestCache) : torrent.files.filter(file => isVideo(file.path)).map(file => file.id);
const fileIds = torrent.files.filter(file => isVideo(file.path)).map(file => file.id);
body = new FormData();
body.append('files', fileIds.join(','));

Expand Down

0 comments on commit 432ced4

Please sign in to comment.