From 5a8d0cb2797fe98ae9d502caf5f707ececc0dfa8 Mon Sep 17 00:00:00 2001 From: TheMythPT Date: Sat, 26 Jan 2019 01:54:11 +0100 Subject: [PATCH 1/2] Update plugin.py Changed the plugin to work with Icecast 2.4.x (tested with Icecast 2.4.4). 1) Line 107 - Removed the `[0]` due to JSON output changes. 2) Line 117 and 141 replaced inexistent `artist` key in the actual JSON format by `server_name` key (the actual DJ). --- SpiffyRadio/plugin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SpiffyRadio/plugin.py b/SpiffyRadio/plugin.py index 2325eec..f2e5d1e 100644 --- a/SpiffyRadio/plugin.py +++ b/SpiffyRadio/plugin.py @@ -104,7 +104,7 @@ def get_current_track_info(self): if response is not None and "icestats" in response: try: - current_track = response["icestats"]["source"][0] + current_track = response["icestats"]["source"] """ This horrible API returns an object if there is only one track @@ -114,7 +114,7 @@ def get_current_track_info(self): # current_track = response["icestats"]["source"] if self.last_track is not None: - artistChanged = current_track["artist"] != self.last_track["artist"] + artistChanged = current_track["server_name"] != self.last_track["server_name"] trackChanged = current_track["title"] != self.last_track["title"] self.track_has_changed = artistChanged and trackChanged @@ -138,7 +138,7 @@ def get_current_track_info(self): def get_now_playing_template(self, current_track): template = self.registryValue("nowPlayingTemplate") - template = template.replace("$artist", current_track["artist"]) + template = template.replace("$artist", current_track["server_name"]) template = template.replace("$title", current_track["title"]) template = template.replace("$listeners", str(current_track["listeners"])) template = template.replace("$listenurl", current_track["listenurl"]) From f459e9db057a1a1b4b14fd4b06768efe012bf2bd Mon Sep 17 00:00:00 2001 From: TheMythPT Date: Sat, 26 Jan 2019 02:57:11 +0100 Subject: [PATCH 2/2] Update plugin.py We should rely only on track name for track changes announcement since we have no `artist` key and `server_name` can be streaming for hours --- SpiffyRadio/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SpiffyRadio/plugin.py b/SpiffyRadio/plugin.py index f2e5d1e..de91910 100644 --- a/SpiffyRadio/plugin.py +++ b/SpiffyRadio/plugin.py @@ -78,7 +78,7 @@ def announce_to_channels(self): for channel in channels: self.irc.sendMsg(ircmsgs.privmsg(channel, message)) else: - track_info = (self.last_track["artist"], self.last_track["title"]) + track_info = (self.last_track["title"]) self.log.info("SpiffyRadio: track has not changed - still playing \"%s - %s\". Not announcing." % track_info) except Exception as e: @@ -117,7 +117,7 @@ def get_current_track_info(self): artistChanged = current_track["server_name"] != self.last_track["server_name"] trackChanged = current_track["title"] != self.last_track["title"] - self.track_has_changed = artistChanged and trackChanged + self.track_has_changed = trackChanged self.last_track = current_track return current_track