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;
|
lastBytes = downloadedBytes;
|
||||||
lastTime = now;
|
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({
|
onProgress({
|
||||||
id: itemId,
|
id: itemId,
|
||||||
progress: -1, // Unknown total
|
progress: -1, // Unknown total
|
||||||
speed: formatSpeed(speed),
|
speed: formatSpeed(speed),
|
||||||
eta: '',
|
eta: etaStr,
|
||||||
status: `${formatBytes(downloadedBytes)} heruntergeladen`,
|
status: `${formatBytes(downloadedBytes)} heruntergeladen`,
|
||||||
currentPart: partNum,
|
currentPart: partNum,
|
||||||
totalParts: totalParts,
|
totalParts: totalParts,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user