jellyfin-monitor: only print active streams on change

This commit is contained in:
Simon Gardling 2025-09-12 14:57:53 -04:00
parent 9d8b8ad33f
commit 1aec911e72
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D

View File

@ -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: