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

@ -45,7 +45,7 @@ npm run check
Le dossier `storage/` est une donnée applicative et ne doit pas être remplacé
pendant un déploiement. Sauvegarder régulièrement :
- `storage/runtime/library.json` ;
- `storage/runtime/library.json` (et `storage/runtime/queue.json`, la file en cours) ;
- `storage/permanent/`.
Les fichiers placés dans `storage/temp/` sont temporaires et nettoyés après
@ -93,6 +93,11 @@ file d'attente.
- Chaque morceau passe par `ffmpeg`, qui normalise le volume (EBU R128) et
encode en Opus : Discord reçoit l'audio sans réencodage.
- La file est enregistrée dans `storage/runtime/queue.json` : après un
redémarrage, elle reprend dès que quelqu'un est dans le salon vocal.
- La page web reçoit les changements en direct par `GET /api/events`
(Server-Sent Events, même clé que le reste de l'API).
Après l'ajout ou la modification d'une commande, relancer `npm run deploy` pour
les enregistrer auprès de Discord.