From 17c08bb51acefad554a580a2cb5619f319664a08 Mon Sep 17 00:00:00 2001 From: Kuba <132459354+KubaPro010@users.noreply.github.com> Date: Thu, 23 Oct 2025 19:43:18 +0200 Subject: [PATCH] get rid of quiet reloads --- modules/__init__.py | 6 +++--- modules/advisor.py | 13 ++++++------- radioPlayer.py | 5 +---- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/modules/__init__.py b/modules/__init__.py index b5b5974..b8fa594 100644 --- a/modules/__init__.py +++ b/modules/__init__.py @@ -37,11 +37,11 @@ class PlaylistAdvisor: Arguments are the arguments passed to the program on startup """ return "/path/to/playlist.txt" - def new_playlist(self) -> int: + def new_playlist(self) -> bool: """ - Whether to play a new playlist, if this is 1, then the player will refresh, if this is two then the player will refresh quietly + Whether to play a new playlist, if this is True, then the player will refresh and fetch a new playlist, calling advise """ - return 0 + return False def imc(self, imc: 'InterModuleCommunication'): """ Receive an IMC object diff --git a/modules/advisor.py b/modules/advisor.py index 3098910..6a62f4d 100644 --- a/modules/advisor.py +++ b/modules/advisor.py @@ -98,16 +98,15 @@ class Module(PlaylistAdvisor): self.last_mod_time = Time.get_playlist_modification_time(night_playlist) self.last_playlist = night_playlist return night_playlist - def new_playlist(self) -> int: - if self.custom_playlist: return 0 - if not self.last_playlist: return 1 - time_change = check_if_playlist_modifed(self.last_playlist) - if time_change: return 2 + def new_playlist(self) -> bool: + if self.custom_playlist: return False + if not self.last_playlist: return True + if check_if_playlist_modifed(self.last_playlist): return True mod_time = Time.get_playlist_modification_time(self.last_playlist) if mod_time > self.last_mod_time: logger.info("Playlist changed on disc, reloading...") - return 1 - return 0 + return True + return False def imc(self, imc: InterModuleCommunication): self.class_imc = imc imc.register(self, "advisor") diff --git a/radioPlayer.py b/radioPlayer.py index 33d1fcc..d86cbf7 100644 --- a/radioPlayer.py +++ b/radioPlayer.py @@ -217,13 +217,10 @@ def play_playlist(playlist_path): refresh = playlist_advisor.new_playlist() - if refresh == 1: + if refresh == True: logger.info("Reloading now...") return_pending = True continue - elif refresh == 2: - return_pending = True - if not procman.anything_playing(): continue for module in simple_modules: module.on_new_track(song_i, track_path, to_fade_in, to_fade_out, official)