From db848123ebf97e8aa8d183e35af92ef404975067 Mon Sep 17 00:00:00 2001 From: David Trattnig <david@subsquare.at> Date: Fri, 28 Jan 2022 14:27:37 +0100 Subject: [PATCH] Fix(playlog): Metadata encoding (engine#80) --- src/engine.liq | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/engine.liq b/src/engine.liq index 82b8194..3320952 100644 --- a/src/engine.liq +++ b/src/engine.liq @@ -38,11 +38,12 @@ inputs = ref [] def on_metadata_notification(meta) = filename = meta["filename"] track_duration = request.duration(filename) - json_data = json_of(meta) - json_data = '{ "action": "on_metadata", "data": #{json_data}, "track_duration": "#{track_duration}" }' - # There's currently an issue with Liquidsoap http.post requests: - # headers = [("Content-Type","application/json; charset=utf-8")] - # ignore(http.post(headers=headers, data="#{json_data}", "http://#{engine_control}")) + json_data = json_of(meta, compact=true) + json_data = url.encode(json_data) + json_data = '{ "action": "on_metadata", "meta": "#{json_data}", "track_duration": "#{track_duration}" }' + # There's currently an issue with Liquidsoap http.post requests (should be gone with Liquidsoap 2): + #headers = [("Content-Type","application/json; charset=utf-8")] + #ignore(http.post(headers=headers, data="#{json_data}", "localhost:1337")) ignore(system("curl -X POST -H 'Content-Type: application/json' --data '#{json_data}' #{engine_control}")) end -- GitLab