From 1aec911e72ebe80ed73cb25b010508f8760d0f7f Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Fri, 12 Sep 2025 14:57:53 -0400 Subject: [PATCH] jellyfin-monitor: only print active streams on change --- services/jellyfin-qbittorrent-monitor.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/services/jellyfin-qbittorrent-monitor.py b/services/jellyfin-qbittorrent-monitor.py index db336e5..9e94e53 100644 --- a/services/jellyfin-qbittorrent-monitor.py +++ b/services/jellyfin-qbittorrent-monitor.py @@ -29,6 +29,7 @@ class JellyfinQBittorrentMonitor: self.throttle_active = False self.running = True self.session = requests.Session() # Use session for cookies + self.last_active_streams = [] # Hysteresis settings to prevent rapid switching self.streaming_start_delay = 10 @@ -205,19 +206,21 @@ class JellyfinQBittorrentMonitor: active_streams = self.check_jellyfin_sessions() streaming_active = len(active_streams) > 0 - # Log current status - if streaming_active: - logger.info( - f"Active streams ({len(active_streams)}): {', '.join(active_streams)}" - ) - elif len(active_streams) == 0 and self.last_streaming_state: - logger.info("No active streaming sessions") + if active_streams != self.last_active_streams: + # Log current status + if streaming_active: + logger.info( + f"Active streams ({len(active_streams)}): {', '.join(active_streams)}" + ) + elif len(active_streams) == 0 and self.last_streaming_state: + logger.info("No active streaming sessions") # Apply hysteresis and change state if needed if self.should_change_state(streaming_active): self.last_streaming_state = streaming_active self.toggle_qbittorrent_limits(streaming_active) + self.last_active_streams = active_streams time.sleep(self.check_interval) except KeyboardInterrupt: