added dl speed translator
Some checks failed
auto-documentation / documentation (push) Has been cancelled
build and push docker image / build-node (push) Has been cancelled
Style and build test / eslint (push) Has been cancelled
Style and build test / test (push) Has been cancelled

This commit is contained in:
stratumadev 2025-07-31 18:24:46 +02:00
parent e1fb674e86
commit 011f61c0a7

View file

@ -281,8 +281,18 @@ class hlsDownload {
total: totalSeg
})
);
function formatDLSpeedB(s: number) {
if (s < 1000000) return `${(s / 1000).toFixed(2)} KB/s`;
if (s < 1000000000) return `${(s / 1000000).toFixed(2)} MB/s`;
return `${(s / 1000000000).toFixed(2)} GB/s`;
}
function formatDLSpeedBit(s: number) {
if (s * 8 < 1000000) return `${(s * 8 / 1000).toFixed(2)} KBit/s`;
if (s * 8 < 1000000000) return `${(s * 8 / 1000000).toFixed(2)} MBit/s`;
return `${(s * 8 / 1000000000).toFixed(2)} GBit/s`;
}
console.info(
`${downloadedSeg} of ${totalSeg} parts downloaded [${data.percent}%] (${Helper.formatTime(parseInt((data.time / 1000).toFixed(0)))} | ${(data.downloadSpeed / 1000000).toFixed(2)} MB/s / ${(data.downloadSpeed * 8 / 1000000).toFixed(2)} Mbit/s)`
`${downloadedSeg} of ${totalSeg} parts downloaded [${data.percent}%] (${Helper.formatTime(parseInt((data.time / 1000).toFixed(0)))} | ${formatDLSpeedB(data.downloadSpeed)} / ${formatDLSpeedBit(data.downloadSpeed)})`
);
if (this.data.callback)
this.data.callback({