diff --git a/modules/core/control.py b/modules/core/control.py index df265cfeb60e11b3268f014e59e93c1d9517a59d..e4d812fe7c131cf602b9e25c3911b82d13aa331d 100644 --- a/modules/core/control.py +++ b/modules/core/control.py @@ -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}'")) diff --git a/modules/liquidsoap/engine.liq b/modules/liquidsoap/engine.liq index 76d9e665e67838b576d50e1e8c3081a9600d0066..70092481d1f7583d175471b1082403c234f76a5e 100644 --- a/modules/liquidsoap/engine.liq +++ b/modules/liquidsoap/engine.liq @@ -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")) diff --git a/modules/plugins/trackservice.py b/modules/plugins/trackservice.py index 89581026b4f72610a358714c0af3bf4accb887f2..30aeafa6f9bcb8d057d17fbd65669c7866b6e9c3 100644 --- a/modules/plugins/trackservice.py +++ b/modules/plugins/trackservice.py @@ -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