Apply overall SABnzbd speed to active download only
Build and Push Docker Image / build (push) Successful in 34s
Licence Check / Licence compatibility and copyright header verification (push) Successful in 39s
CI / Security audit (push) Successful in 1m12s
CI / Tests & coverage (push) Failing after 1m13s

This commit is contained in:
2026-05-20 00:58:38 +01:00
parent 63fc370262
commit 8549746721
+11 -5
View File
@@ -45,9 +45,10 @@ class SABnzbdClient extends DownloadClient {
async getActiveDownloads() { async getActiveDownloads() {
try { try {
// Get both queue and history to provide complete picture // Get both queue and history to provide complete picture
const [queueResponse, historyResponse] = await Promise.all([ const [queueResponse, historyResponse, clientStatus] = await Promise.all([
this.makeRequest({ mode: 'queue' }), this.makeRequest({ mode: 'queue' }),
this.makeRequest({ mode: 'history', limit: 10 }) this.makeRequest({ mode: 'history', limit: 10 }),
this.getClientStatus()
]); ]);
const queueData = queueResponse.data; const queueData = queueResponse.data;
@@ -57,15 +58,19 @@ class SABnzbdClient extends DownloadClient {
// Process active queue items // Process active queue items
if (queueData.queue && queueData.queue.slots) { if (queueData.queue && queueData.queue.slots) {
// Find the currently downloading slot (first one with status 'Downloading')
const activeSlot = queueData.queue.slots.find(slot => slot.status === 'Downloading');
const activeSpeed = activeSlot && clientStatus ? (clientStatus.kbpersec ? clientStatus.kbpersec * 1024 : 0) : 0;
for (const slot of queueData.queue.slots) { for (const slot of queueData.queue.slots) {
downloads.push(this.normalizeDownload(slot, 'queue')); downloads.push(this.normalizeDownload(slot, 'queue', activeSlot === slot ? activeSpeed : 0));
} }
} }
// Process recent history items (last 10) // Process recent history items (last 10)
if (historyData.history && historyData.history.slots) { if (historyData.history && historyData.history.slots) {
for (const slot of historyData.history.slots) { for (const slot of historyData.history.slots) {
downloads.push(this.normalizeDownload(slot, 'history')); downloads.push(this.normalizeDownload(slot, 'history', 0));
} }
} }
@@ -102,7 +107,7 @@ class SABnzbdClient extends DownloadClient {
} }
} }
normalizeDownload(slot, source) { normalizeDownload(slot, source, speed = 0) {
const isHistory = source === 'history'; const isHistory = source === 'history';
// Map SABnzbd statuses to normalized status // Map SABnzbd statuses to normalized status
@@ -164,6 +169,7 @@ class SABnzbdClient extends DownloadClient {
progress: Math.round(progress), progress: Math.round(progress),
size: Math.round(size), size: Math.round(size),
downloaded: Math.round(downloaded), downloaded: Math.round(downloaded),
speed: speed,
eta: this.calculateEta(slot.timeleft || slot.eta), eta: this.calculateEta(slot.timeleft || slot.eta),
category: slot.cat || undefined, category: slot.cat || undefined,
tags: slot.labels ? (Array.isArray(slot.labels) ? slot.labels : slot.labels.split(',')).filter(tag => tag && tag.trim()) : [], tags: slot.labels ? (Array.isArray(slot.labels) ? slot.labels : slot.labels.split(',')).filter(tag => tag && tag.trim()) : [],