diff --git a/templates/index.html b/templates/index.html index 0a07c0d..97e4cdc 100644 --- a/templates/index.html +++ b/templates/index.html @@ -277,16 +277,23 @@ function parseProgress(output) { if (!output || output.length === 0) return null; let current = 0, total = 0, dlPct = 0; + let mp3Total = 0, mp3Done = 0, inMp3 = false; for (const line of output) { const tm = line.match(/Track (\d+)\/(\d+)/); if (tm) { current = parseInt(tm[1]); total = parseInt(tm[2]); } const dm = line.match(/\[download\]\s+([\d.]+)%/); if (dm) dlPct = parseFloat(dm[1]); + const mm = line.match(/\[mp3\] Converting (\d+) file/); + if (mm) { mp3Total = parseInt(mm[1]); inMp3 = true; } + if (/\[mp3\] (Done:|Failed:)/.test(line)) mp3Done++; + } + if (inMp3 && mp3Total > 0) { + const pct = (mp3Done / mp3Total) * 100; + return { current: mp3Done, total: mp3Total, pct: Math.min(Math.round(pct), 100), phase: 'mp3' }; } if (total <= 0) return null; - // Combine track progress with current download percentage const pct = ((current - 1 + dlPct / 100) / total) * 100; - return { current, total, pct: Math.min(Math.round(pct), 100) }; + return { current, total, pct: Math.min(Math.round(pct), 100), phase: 'download' }; } function toggleJobLog(jobId, currentlyOpen) { @@ -317,7 +324,11 @@ let progressHtml = ''; if (progress) { - progressHtml = `