mirror of
https://github.com/TheBeastLT/torrentio-scraper.git
synced 2026-05-18 10:51:45 +00:00
improve TB downloading status check
This commit is contained in:
parent
d8ddec1638
commit
703c655620
1 changed files with 4 additions and 3 deletions
|
|
@ -149,10 +149,12 @@ async function freeLastActiveTorrent(apiKey) {
|
||||||
const torrents = await getTorrentList(apiKey);
|
const torrents = await getTorrentList(apiKey);
|
||||||
const seedingTorrent = torrents.filter(statusSeeding).pop();
|
const seedingTorrent = torrents.filter(statusSeeding).pop();
|
||||||
if (seedingTorrent) {
|
if (seedingTorrent) {
|
||||||
|
console.log(`Stopping seeded item in TorBox to make space...`);
|
||||||
return controlTorrent(apiKey, seedingTorrent.id, 'stop_seeding');
|
return controlTorrent(apiKey, seedingTorrent.id, 'stop_seeding');
|
||||||
}
|
}
|
||||||
const downloadingTorrent = torrents.filter(statusDownloading).pop();
|
const downloadingTorrent = torrents.filter(statusDownloading).pop();
|
||||||
if (downloadingTorrent) {
|
if (downloadingTorrent) {
|
||||||
|
console.log(`Deleting downloading item in TorBox to make space...`);
|
||||||
return controlTorrent(apiKey, downloadingTorrent.id, 'delete');
|
return controlTorrent(apiKey, downloadingTorrent.id, 'delete');
|
||||||
}
|
}
|
||||||
return Promise.reject({ detail: 'No torrent to pause found' });
|
return Promise.reject({ detail: 'No torrent to pause found' });
|
||||||
|
|
@ -268,8 +270,7 @@ export function toCommonError(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function statusDownloading(torrent) {
|
function statusDownloading(torrent) {
|
||||||
return ['metaDL', 'downloading', 'stalled (no seeds)', 'processing', 'checking', 'completed']
|
return !statusReady(torrent) && !statusError(torrent);
|
||||||
.includes(torrent?.download_state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function statusError(torrent) {
|
function statusError(torrent) {
|
||||||
|
|
@ -281,7 +282,7 @@ function statusReady(torrent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function statusSeeding(torrent) {
|
function statusSeeding(torrent) {
|
||||||
return ['seeding', 'uploading (no peers)'].includes(torrent?.download_state);
|
return ['seeding', 'uploading', 'uploading (no peers)'].includes(torrent?.download_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isAccessDeniedError(error) {
|
function isAccessDeniedError(error) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue