feat: media controls

This commit is contained in:
end-4
2025-05-18 18:54:28 +02:00
parent 931b276d60
commit 314a6c67b6
6 changed files with 347 additions and 17 deletions
@@ -108,4 +108,32 @@ function wordWrap(str, maxLen) {
}
if (current.length > 0) lines.push(current);
return lines.join("\n");
}
function cleanMusicTitle(title) {
if (!title) return "";
// Brackets
title = title.replace(/ *\([^)]*\) */g, " "); // Round brackets
title = title.replace(/ *\[[^\]]*\] */g, " "); // Square brackets
title = title.replace(/ *\{[^\}]*\} */g, " "); // Curly brackets
// Japenis brackets
title = title.replace(/【[^】]*】/, "") // Touhou
title = title.replace(/《[^》]*》/, "") // ??
title = title.replace(/「[^」]*」/, "") // OP/ED
title = title.replace(/『[^』]*』/, "") // OP/ED
return title;
}
function friendlyTimeForSeconds(seconds) {
if (isNaN(seconds) || seconds < 0) return "0:00";
seconds = Math.floor(seconds);
const h = Math.floor(seconds / 3600);
const m = Math.floor((seconds % 3600) / 60);
const s = seconds % 60;
if (h > 0) {
return `${h}:${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`;
} else {
return `${m}:${s.toString().padStart(2, '0')}`;
}
}