diff --git a/src/engine.liq b/src/engine.liq index 23efbf36d7c4fdd666a66b86ea3b43da0a488257..f02ca0e48fe75d06eb86dc97e9fae6294dd83239 100644 --- a/src/engine.liq +++ b/src/engine.liq @@ -38,13 +38,19 @@ inputs = ref ([]) def on_metadata_notification(meta) = filename = meta["filename"] track_duration = request.duration(filename) - json_data = json.stringify(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(process.run("curl -X POST -H 'Content-Type: application/json' --data '#{json_data}' #{engine_control}")) + + # TODO Post playlog to engine-api directly. This requires some additional show state handling. + json_data = json() + json_data.add("action", "on_metadata") + json_data.add("meta", meta) + json_data.add("track_duration", track_duration) + playlog = url.encode(json.stringify(json_data)) + + log(level=3, "Posting playlog: #{playlog}") + # headers = [("Content-Type","application/json; charset=utf-8")] + # result = http.post(http_version="1.1", headers=headers, data="#{playlog}", "#{engine_control}") + ignore(process.run("curl -X POST -H 'Content-Type: application/json' --data '#{playlog}' #{engine_control}")) + end #####################################