diff --git a/libraries/enum/auraenumerations.py b/libraries/enum/auraenumerations.py index db3c2f5e779746e1a1f212f6f7a69a7a4a7d8b89..c8ab8cbaf5dd6c88ea4b424523661282a1fdaf53 100644 --- a/libraries/enum/auraenumerations.py +++ b/libraries/enum/auraenumerations.py @@ -54,6 +54,7 @@ class RedisChannel(Enum): GNF_REPLY = "get_next_file_reply" IPE_REPLY = "insert_playlist_entry_reply" IP_REPLY = "init_player_reply" + TS_REPLY = "track_service_reply" MPE_REPLY = "move_playlist_entry_reply" PMQ_REPLY = "print_message_queue_reply" RDB_REPLY = "recreate_database_reply" @@ -73,8 +74,9 @@ class ScheduleEntryType(Enum): class FallbackType(Enum): SHOW = "show" # the first played when the show playlist fails + TIMESLOT = "timeslot" # the second played when timeslot fallback fails STATION = "station" # the last played when everything else fails - TIMESLOT = "timeslot" # the second played when show fallback fails + class TimerType(Enum): diff --git a/modules/cli_tool/padavan.py b/modules/cli_tool/padavan.py index 985a3b2cc98dc2cc2f40588f1f62487cfa41d4cf..9eec25b417f49cbcafcbbd44f9cc98e5e89d4c70 100644 --- a/modules/cli_tool/padavan.py +++ b/modules/cli_tool/padavan.py @@ -91,6 +91,9 @@ class Padavan: elif self.args.init_player: self.init_player() + elif self.args.adapt_trackservice_title: + self.adapt_trackservice_title(self.args.adapt_trackservice_title) + elif self.args.recreatedb: self.recreatedb() @@ -203,9 +206,23 @@ class Padavan: self.stringreply += "\nConnection to redis: " + TerminalColors.RED.value + " " + str(connection_status["redis"]) + TerminalColors.ENDC.value # ------------------------------------------------------------------------------------------ # + + def init_player(self): + """ + Initializes the player on Liquidsaop startup. + """ self.stringreply = self.send_and_wait_redis("aura", "init_player", RedisChannel.IP_REPLY) + + + def adapt_trackservice_title(self, info): + """ + Updates the tracks-service with the info on currently played fallback track. + """ + + self.stringreply = self.send_and_wait_redis("aura", "adapt_trackservice_title " + info, RedisChannel.GNF_REPLY) + # ------------------------------------------------------------------------------------------ # def recreatedb(self): print("YOU WILL GET PROBLEMS DUE TO DATABASE BLOCKING IF aura.py IS RUNNING! NO CHECKS IMPLEMENTED SO FAR!") diff --git a/modules/communication/redis/adapter.py b/modules/communication/redis/adapter.py index f095dced939bd1a272a8de3e0ea12c9bc6f122e3..c9a69378e431265a0feb96e24d3fb23bf430c684 100644 --- a/modules/communication/redis/adapter.py +++ b/modules/communication/redis/adapter.py @@ -174,6 +174,15 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger): #playlist = playlist[0:len(playlist)-8] self.execute(RedisChannel.GNF_REPLY.value, self.scheduler.get_next_file_for, playlist) + elif item["data"].find("adapt_trackservice_title") >= 0: + artist = item["data"].split("|+|+|")[1] + title = item["data"].split("|+|+|")[2] + if not artist: + artist = "n/a" + if not title: + title = "n/a" + self.execute(RedisChannel.TS_REPLY.value, self.scheduler.adapt_trackservice_title, artist, title) + elif item["data"] == "recreate_db": self.execute(RedisChannel.RDB_REPLY.value, self.scheduler.recreate_database) @@ -184,9 +193,12 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger): raise RedisConnectionException("ServerRedisAdapter Cannot understand command: " + item["data"]) # ------------------------------------------------------------------------------------------ # - def execute(self, channel, f, param=None): - if param: - reply = f(param) + def execute(self, channel, f, param1=None, param2=None): + if param1: + if param2: + reply = f(param1, param2) + else: + reply = f(param1) else: reply = f() diff --git a/modules/communication/redis/messenger.py b/modules/communication/redis/messenger.py index 793cccae367b970194d84d85389acb79c7954ffc..02847c439a3dcc27375683291da7e6cc40ff8610 100644 --- a/modules/communication/redis/messenger.py +++ b/modules/communication/redis/messenger.py @@ -298,6 +298,15 @@ class RedisMessenger(): return next.decode('utf-8') + # ------------------------------------------------------------------------------------------ # + def adapt_trackservice_title(self, info): + result = self.rstore.db.get('adapt_trackservice_title') + + if result is None: + result = b"" + + return result.decode('utf-8') + # ------------------------------------------------------------------------------------------ # def set_next_file_for(self, playlisttype, file): self.rstore.db.set("next_" + playlisttype + "file", file) diff --git a/modules/scheduling/scheduler.py b/modules/scheduling/scheduler.py index 4487272b0976a66fc9092ecbad5e90d9b99b1d8d..a3bd55d42811392f92e6219241fbbca68fc26ecb 100644 --- a/modules/scheduling/scheduler.py +++ b/modules/scheduling/scheduler.py @@ -299,6 +299,20 @@ class AuraScheduler(ExceptionLogger, threading.Thread): return file + def adapt_trackservice_title(self, artist, title): + """ + Updates the track-service entry with the info from a fallback track/playlist. + """ + scheduled_entry = self.get_active_entry() + + # TODO UPDATE LOGIC + + msg = "Track Service active track '%s' updated with fallback source '%s - %s'!" % (scheduled_entry, artist, title) + self.logger.info(msg) + return msg + + + # # PRIVATE METHODS