jellyfin-qbittorrent-monitor: improve testing infra
This commit is contained in:
@@ -21,6 +21,8 @@ class JellyfinQBittorrentMonitor:
|
||||
qbittorrent_url="http://localhost:8080",
|
||||
check_interval=30,
|
||||
jellyfin_api_key=None,
|
||||
streaming_start_delay=10,
|
||||
streaming_stop_delay=60,
|
||||
):
|
||||
self.jellyfin_url = jellyfin_url
|
||||
self.qbittorrent_url = qbittorrent_url
|
||||
@@ -33,8 +35,8 @@ class JellyfinQBittorrentMonitor:
|
||||
self.last_active_streams = []
|
||||
|
||||
# Hysteresis settings to prevent rapid switching
|
||||
self.streaming_start_delay = 10
|
||||
self.streaming_stop_delay = 60
|
||||
self.streaming_start_delay = streaming_start_delay
|
||||
self.streaming_stop_delay = streaming_stop_delay
|
||||
self.last_state_change = 0
|
||||
|
||||
# Local network ranges (RFC 1918 private networks + localhost)
|
||||
@@ -80,7 +82,7 @@ class JellyfinQBittorrentMonitor:
|
||||
for session in sessions:
|
||||
if (
|
||||
"NowPlayingItem" in session
|
||||
and session.get("PlayState", {}).get("IsPaused", True) == False
|
||||
and not session.get("PlayState", {}).get("IsPaused", True)
|
||||
):
|
||||
# Check if session is from external network
|
||||
remote_endpoint = session.get("RemoteEndPoint", "")
|
||||
@@ -249,12 +251,16 @@ if __name__ == "__main__":
|
||||
qbittorrent_url = os.getenv("QBITTORRENT_URL", "http://localhost:8080")
|
||||
check_interval = int(os.getenv("CHECK_INTERVAL", "30"))
|
||||
jellyfin_api_key = os.getenv("JELLYFIN_API_KEY")
|
||||
streaming_start_delay = int(os.getenv("STREAMING_START_DELAY", "10"))
|
||||
streaming_stop_delay = int(os.getenv("STREAMING_STOP_DELAY", "60"))
|
||||
|
||||
monitor = JellyfinQBittorrentMonitor(
|
||||
jellyfin_url=jellyfin_url,
|
||||
qbittorrent_url=qbittorrent_url,
|
||||
check_interval=check_interval,
|
||||
jellyfin_api_key=jellyfin_api_key,
|
||||
streaming_start_delay=streaming_start_delay,
|
||||
streaming_stop_delay=streaming_stop_delay,
|
||||
)
|
||||
|
||||
monitor.run()
|
||||
|
||||
Reference in New Issue
Block a user