diff --git a/stream/Dockerfile b/stream/Dockerfile index 5315fc4..643f4f0 100644 --- a/stream/Dockerfile +++ b/stream/Dockerfile @@ -1,5 +1,6 @@ FROM savonet/liquidsoap:v2.4.5 COPY radio.liq /etc/liquidsoap/radio.liq +COPY index.html /etc/liquidsoap/index.html CMD ["/etc/liquidsoap/radio.liq"] diff --git a/stream/index.html b/stream/index.html new file mode 100644 index 0000000..741ad58 --- /dev/null +++ b/stream/index.html @@ -0,0 +1,66 @@ + + + + + + radieo + + + +
+ +
en cours
+
+
+ +
+ + + diff --git a/stream/radio.liq b/stream/radio.liq index 96a51e7..eb9c73c 100644 --- a/stream/radio.liq +++ b/stream/radio.liq @@ -4,6 +4,7 @@ # La source principale est pilotée par le daemon d'ingestion via GET /next. # Le dossier /cache sert de secours quand le daemon n'a rien à proposer # (daemon indisponible, file momentanément vide…). Si tout est vide : silence. +# Le harbor sert aussi une petite page web (/) et le titre courant (/nowplaying). # --- Journalisation : tout sur la sortie standard (pratique en conteneur) --- settings.log.stdout := true @@ -59,6 +60,11 @@ radio = crossfade(duration=3.0, fade_in=3.0, fade_out=3.0, radio) # mksafe garantit un flux continu : silence plutôt que plantage si tout est vide. radio = mksafe(radio) +# --- Métadonnées « en cours de lecture » ----------------------------------- +# On mémorise les dernières métadonnées vues sur le flux réellement diffusé. +now_playing = ref([]) +radio.on_metadata(synchronous=false, fun(m) -> now_playing := m) + # --- Sortie : flux MP3 sur http://:8000/radio.mp3 --- output.harbor( %mp3(bitrate=192), @@ -66,3 +72,22 @@ output.harbor( mount="radio.mp3", radio ) + +# --- Page web et API de lecture (mêmes port/harbor que le flux) --- +home_html = file.contents("/etc/liquidsoap/index.html") + +harbor.http.register( + port=8000, method="GET", "/", + fun(_, resp) -> begin + resp.content_type("text/html; charset=utf-8") + resp.html(home_html) + end +) + +harbor.http.register( + port=8000, method="GET", "/nowplaying", + fun(_, resp) -> begin + m = now_playing() + resp.json({title=m["title"], artist=m["artist"]}) + end +)