Keep the queue across restarts; add shuffle, loop, renaming and live events

- Save the queue to storage/runtime/queue.json and restore it at startup,
  the interrupted track first; playback resumes once someone is in the
  voice channel. Shutdown keeps the queued files instead of deleting them.
- Shuffle the upcoming tracks; loop mode sends finished tracks back to the
  end of the queue, except removed or failed ones.
- Rename library tracks (queued copies follow), enqueue the whole library,
  optionally shuffled.
- Stream queue and library changes to the web page with Server-Sent Events
  (GET /api/events).
- Sanitise the requester name sent when queueing a library track.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-29 12:15:25 +01:00
parent 39d2b6acfb
commit 9fb54798dd
12 changed files with 390 additions and 18 deletions

View file

@ -179,7 +179,11 @@ function createQueueTrackFromLibrary(libraryTrack, requestedBy = "library") {
duration: libraryTrack.duration ?? null,
artist: libraryTrack.artist ?? null,
permanent: true,
uploader: requestedBy,
uploader:
String(requestedBy ?? "")
.replace(/[\u0000-\u001f]/g, "")
.trim()
.slice(0, 80) || "library",
libraryTrackId: libraryTrack.id,
createdAt: new Date().toISOString(),
};