jellyfin server connection fix

This commit is contained in:
Broque Thomas 2026-02-27 08:47:50 -08:00
parent e14a317a56
commit c4bf6ff0f3
2 changed files with 18 additions and 2 deletions

View file

@ -1,4 +1,5 @@
import requests import requests
import time
from typing import List, Optional, Dict, Any from typing import List, Optional, Dict, Any
from dataclasses import dataclass from dataclasses import dataclass
from datetime import datetime from datetime import datetime
@ -160,6 +161,17 @@ class JellyfinClient:
"""Set callback function for cache progress updates: callback(message)""" """Set callback function for cache progress updates: callback(message)"""
self._progress_callback = callback self._progress_callback = callback
def reload_config(self):
"""Reset connection state so next ensure_connection() re-reads config.
Called when settings are saved to pick up URL/API key changes."""
self.base_url = None
self.api_key = None
self.user_id = None
self.music_library_id = None
self._connection_attempted = False
self.clear_cache()
logger.info("🔄 Jellyfin client config reset — will reconnect with new settings")
def ensure_connection(self) -> bool: def ensure_connection(self) -> bool:
"""Ensure connection to Jellyfin server with lazy initialization.""" """Ensure connection to Jellyfin server with lazy initialization."""
if self._connection_attempted: if self._connection_attempted:
@ -507,6 +519,8 @@ class JellyfinClient:
if not response: if not response:
consecutive_failures += 1 consecutive_failures += 1
# Wait before retrying — the server may still be processing the timed-out request
time.sleep(5)
if limit > 1000: if limit > 1000:
limit = limit // 2 limit = limit // 2
consecutive_failures = 0 # Reset — give the smaller batch a fair chance consecutive_failures = 0 # Reset — give the smaller batch a fair chance
@ -571,6 +585,8 @@ class JellyfinClient:
if not response: if not response:
consecutive_failures += 1 consecutive_failures += 1
# Wait before retrying — the server may still be processing the timed-out request
time.sleep(5)
if limit > 1000: if limit > 1000:
limit = limit // 2 limit = limit // 2
consecutive_failures = 0 # Reset — give the smaller batch a fair chance consecutive_failures = 0 # Reset — give the smaller batch a fair chance

View file

@ -2530,7 +2530,7 @@ def handle_settings():
spotify_client.reload_config() spotify_client.reload_config()
plex_client.server = None plex_client.server = None
jellyfin_client.server = None jellyfin_client.reload_config()
# Reload orchestrator settings (download source mode, hybrid_primary, etc.) # Reload orchestrator settings (download source mode, hybrid_primary, etc.)
soulseek_client.reload_settings() soulseek_client.reload_settings()
# FIX: Re-instantiate the global tidal_client to pick up new settings # FIX: Re-instantiate the global tidal_client to pick up new settings