Commit 4390fe07 authored by David Trattnig's avatar David Trattnig
Browse files

Add track duration for on_meta. #43 #44

parent ba169c5a
......@@ -160,6 +160,8 @@ class SocketControlInterface:
"""
if "action" in data:
if data["action"] == SocketControlInterface.ACTION_ON_METADATA:
meta_data = data["data"]
meta_data["duration"] = data["track_duration"]
logger.debug(SU.yellow(f"[ECI] Executing action: "+SocketControlInterface.ACTION_ON_METADATA))
self.engine.event_dispatcher.on_metadata(data["data"])
logger.info(SU.yellow(f"[ECI] Successfully issued event '{SocketControlInterface.ACTION_ON_METADATA}'"))
......
......@@ -35,8 +35,10 @@ inputs = ref []
# Called when some new metadata info is available
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} }'
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://localhost:1337"))
......
......@@ -108,12 +108,18 @@ class TrackServiceHandler():
data["track_start"] = meta.get("on_air")
data["track_artist"] = meta.get("artist")
data["track_album"] = meta.get("album")
data["track_title"] = meta.get("title")
data["track_duration"] = 0
data["track_title"] = meta.get("title")
data["track_type"] = ResourceClass.FILE.numeric
#lqs_source = meta["source"]
if "duration" in meta:
duration = float(meta.get("duration"))
data["track_duration"] = int(duration)
else:
data["track_duration"] = 0
entry = self.playlog.resolve_entry(meta["filename"])
if entry:
# This is a playlog according to the scheduled playlist (normal or fallback)
data["track_num"] = entry.entry_num
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment