Skip to content
Snippets Groups Projects
Commit a67ba8b1 authored by David Trattnig's avatar David Trattnig
Browse files

Refact: Use new JSON builder

parent 4539dbfa
No related branches found
No related tags found
1 merge request!3Liquidsoap 2 migration
......@@ -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
#####################################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment