From c96fd13affa06962d37187682ccfa17574446b91 Mon Sep 17 00:00:00 2001 From: xRangerDE Date: Fri, 20 Mar 2026 09:39:27 +0100 Subject: [PATCH] feat: add ETA calculation for download progress display Co-Authored-By: Claude Opus 4.6 (1M context) --- src/main.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 27be3ac..3900dc1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2685,11 +2685,26 @@ function downloadVODPart( lastBytes = downloadedBytes; lastTime = now; + let etaStr = ''; + if (speed > 0 && downloadedBytes > 0) { + const elapsedSec = (Date.now() - downloadStartTime) / 1000; + if (elapsedSec > 3) { + const avgSpeed = downloadedBytes / elapsedSec; + if (expectedDurationSeconds && expectedDurationSeconds > 0) { + const estimatedTotalBytes = avgSpeed * expectedDurationSeconds; + if (estimatedTotalBytes > downloadedBytes) { + const remainingSec = (estimatedTotalBytes - downloadedBytes) / avgSpeed; + etaStr = formatETA(remainingSec); + } + } + } + } + onProgress({ id: itemId, progress: -1, // Unknown total speed: formatSpeed(speed), - eta: '', + eta: etaStr, status: `${formatBytes(downloadedBytes)} heruntergeladen`, currentPart: partNum, totalParts: totalParts,