jellyfin-qbittorrent-monitor: cleanup
This commit is contained in:
@@ -45,4 +45,4 @@
|
||||
CHECK_INTERVAL = "30";
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,9 +67,7 @@ class JellyfinQBittorrentMonitor:
|
||||
def check_jellyfin_sessions(self) -> list[str]:
|
||||
"""Check if anyone is actively streaming from Jellyfin (external networks only)"""
|
||||
try:
|
||||
headers = {}
|
||||
if self.jellyfin_api_key:
|
||||
headers["X-Emby-Token"] = self.jellyfin_api_key
|
||||
headers = {"X-Emby-Token": self.jellyfin_api_key} if self.jellyfin_api_key else {}
|
||||
|
||||
response = requests.get(
|
||||
f"{self.jellyfin_url}/Sessions", headers=headers, timeout=10
|
||||
@@ -83,20 +81,14 @@ class JellyfinQBittorrentMonitor:
|
||||
if (
|
||||
"NowPlayingItem" in session
|
||||
and not session.get("PlayState", {}).get("IsPaused", True)
|
||||
and not self.is_local_ip(session.get("RemoteEndPoint", ""))
|
||||
):
|
||||
# Check if session is from external network
|
||||
remote_endpoint = session.get("RemoteEndPoint", "")
|
||||
if remote_endpoint and self.is_local_ip(remote_endpoint):
|
||||
logger.debug(f"Skipping local session from {remote_endpoint}")
|
||||
continue
|
||||
|
||||
item = session["NowPlayingItem"]
|
||||
# Only count video streams (Movies, Episodes, etc.)
|
||||
item_type = item.get("Type", "").lower()
|
||||
if item_type in ["movie", "episode", "video"]:
|
||||
user = session.get("UserName", "Unknown")
|
||||
client_info = f" (from {remote_endpoint})" if remote_endpoint else ""
|
||||
active_streams.append(f"{user}: {item.get('Name', 'Unknown')}{client_info}")
|
||||
active_streams.append(f"{user}: {item.get('Name', 'Unknown')}")
|
||||
|
||||
return active_streams
|
||||
|
||||
|
||||
Reference in New Issue
Block a user