mirror of
https://github.com/TheBeastLT/torrentio-scraper.git
synced 2026-01-11 22:40:22 +00:00
delete error entry from TB before retrying
This commit is contained in:
parent
0cd3bd4d22
commit
6b693e4321
1 changed files with 16 additions and 1 deletions
|
|
@ -100,7 +100,8 @@ async function _resolve(apiKey, infoHash, cachedEntryInfo, fileIndex, ip) {
|
|||
return StaticResponse.DOWNLOADING;
|
||||
} else if (torrent && statusError(torrent)) {
|
||||
console.log(`Retry failed download in TorBox ${infoHash} [${fileIndex}]...`);
|
||||
return _retryCreateTorrent(apiKey, infoHash, cachedEntryInfo, fileIndex);
|
||||
return controlTorrent(apiKey, torrent.id, 'delete')
|
||||
.then(() => _retryCreateTorrent(apiKey, infoHash, cachedEntryInfo, fileIndex));
|
||||
}
|
||||
|
||||
return Promise.reject(`Failed TorBox adding torrent ${JSON.stringify(torrent)}`);
|
||||
|
|
@ -188,6 +189,20 @@ async function createTorrent(apiKey, magnetLink){
|
|||
.catch(error => Promise.reject(error.response?.data || error));
|
||||
}
|
||||
|
||||
async function controlTorrent(apiKey, torrent_id, operation){
|
||||
const url = `${baseUrl}/api/torrents/controltorrent`
|
||||
const headers = getHeaders(apiKey);
|
||||
const data = { torrent_id, operation}
|
||||
return axios.post(url, data, { headers, timeout })
|
||||
.then(response => {
|
||||
if (response.data?.success) {
|
||||
return Promise.resolve(response.data.data);
|
||||
}
|
||||
return Promise.reject(response.data);
|
||||
})
|
||||
.catch(error => Promise.reject(error.response?.data || error));
|
||||
}
|
||||
|
||||
async function getTorrentList(apiKey, id = undefined, offset = 0) {
|
||||
return getItemList(apiKey, 'torrents', id, offset);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue