feat: emit now-playing json on track change
This commit is contained in:
parent
fd3453c5bc
commit
f0ae93a522
1 changed files with 15 additions and 0 deletions
|
|
@ -6,12 +6,27 @@ settings.log.level.set(3)
|
|||
|
||||
source_pw = environment.get(default="", "SOURCE_PW")
|
||||
|
||||
def emit_now_playing(station, m) =
|
||||
filename = m["filename"]
|
||||
if filename != "" then
|
||||
payload = json()
|
||||
payload.add("station", station)
|
||||
payload.add("artist", m["artist"])
|
||||
payload.add("title", m["title"])
|
||||
payload.add("album", m["album"])
|
||||
payload.add("filename", filename)
|
||||
payload.add("started_at", string(int_of_float(time())))
|
||||
file.write(data=payload.stringify(), atomic=true, temp_dir="/now-playing", "/now-playing/#{station}.json")
|
||||
end
|
||||
end
|
||||
|
||||
# === station: minecraft ===
|
||||
minecraft = playlist(
|
||||
reload_mode="watch",
|
||||
mode="randomize",
|
||||
"/library/minecraft/tracks"
|
||||
)
|
||||
minecraft.on_track(fun (m) -> emit_now_playing("minecraft", m))
|
||||
minecraft = crossfade(minecraft)
|
||||
minecraft = mksafe(minecraft)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue