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

@ -9,6 +9,7 @@ import {
createBearerAuth,
localOnly,
} from "./middlewares/auth.js";
import { eventsRouter } from "./routes/events.js";
import { libraryRouter } from "./routes/library.js";
import { notificationsRouter } from "./routes/notifications.js";
import { playerRouter } from "./routes/player.js";
@ -86,6 +87,7 @@ function createApp(
apiRouter.use("/queue", queueRouter(dependencies));
apiRouter.use("/library", libraryRouter(dependencies));
apiRouter.use("/player", playerRouter(dependencies));
apiRouter.use("/events", eventsRouter(dependencies));
app.use("/api", apiRouter);
app.get(["/jukebox", "/jukebox/"], (_req, res) =>