feat: add ETA calculation for download progress display
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6a32387add
commit
c96fd13aff
17
src/main.ts
17
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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user