feat: progress bar now shows conversions
This commit is contained in:
@@ -277,16 +277,23 @@
|
|||||||
function parseProgress(output) {
|
function parseProgress(output) {
|
||||||
if (!output || output.length === 0) return null;
|
if (!output || output.length === 0) return null;
|
||||||
let current = 0, total = 0, dlPct = 0;
|
let current = 0, total = 0, dlPct = 0;
|
||||||
|
let mp3Total = 0, mp3Done = 0, inMp3 = false;
|
||||||
for (const line of output) {
|
for (const line of output) {
|
||||||
const tm = line.match(/Track (\d+)\/(\d+)/);
|
const tm = line.match(/Track (\d+)\/(\d+)/);
|
||||||
if (tm) { current = parseInt(tm[1]); total = parseInt(tm[2]); }
|
if (tm) { current = parseInt(tm[1]); total = parseInt(tm[2]); }
|
||||||
const dm = line.match(/\[download\]\s+([\d.]+)%/);
|
const dm = line.match(/\[download\]\s+([\d.]+)%/);
|
||||||
if (dm) dlPct = parseFloat(dm[1]);
|
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;
|
if (total <= 0) return null;
|
||||||
// Combine track progress with current download percentage
|
|
||||||
const pct = ((current - 1 + dlPct / 100) / total) * 100;
|
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) {
|
function toggleJobLog(jobId, currentlyOpen) {
|
||||||
@@ -317,7 +324,11 @@
|
|||||||
|
|
||||||
let progressHtml = '';
|
let progressHtml = '';
|
||||||
if (progress) {
|
if (progress) {
|
||||||
progressHtml = `<div class="job-progress"><div class="job-progress-bar" style="width:${progress.pct}%"></div></div>`;
|
const label = progress.phase === 'mp3'
|
||||||
|
? `Converting to MP3 ${progress.current}/${progress.total}`
|
||||||
|
: `Downloading ${progress.current}/${progress.total}`;
|
||||||
|
progressHtml = `<div style="font-size:0.75rem;color:var(--text2);margin-bottom:4px">${label}</div>
|
||||||
|
<div class="job-progress"><div class="job-progress-bar" style="width:${progress.pct}%"></div></div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
let logHtml = '';
|
let logHtml = '';
|
||||||
|
|||||||
Reference in New Issue
Block a user