Skip slskd connection check when Soulseek is not an active source
The dashboard status poll and hybrid connection check were pinging slskd every 2 minutes regardless of download source, flooding logs with connection errors when slskd wasn't running. Now only checks slskd when the download mode is 'soulseek' or when 'soulseek' is in the hybrid order. Hybrid mode also only checks sources in the configured priority order instead of all six.
This commit is contained in:
parent
0bc6abd683
commit
f4407490c1
2 changed files with 34 additions and 14 deletions
|
|
@ -133,16 +133,26 @@ class DownloadOrchestrator:
|
|||
elif self.mode == 'deezer_dl':
|
||||
return await self.deezer_dl.check_connection()
|
||||
elif self.mode == 'hybrid':
|
||||
soulseek_ok = await self.soulseek.check_connection()
|
||||
youtube_ok = await self.youtube.check_connection()
|
||||
tidal_ok = await self.tidal.check_connection()
|
||||
qobuz_ok = await self.qobuz.check_connection()
|
||||
hifi_ok = await self.hifi.check_connection()
|
||||
deezer_ok = await self.deezer_dl.check_connection()
|
||||
# Only check sources that are in the configured hybrid order
|
||||
clients = {
|
||||
'soulseek': self.soulseek, 'youtube': self.youtube,
|
||||
'tidal': self.tidal, 'qobuz': self.qobuz,
|
||||
'hifi': self.hifi, 'deezer_dl': self.deezer_dl,
|
||||
}
|
||||
sources_to_check = self.hybrid_order if self.hybrid_order else list(clients.keys())
|
||||
results = {}
|
||||
for source in sources_to_check:
|
||||
client = clients.get(source)
|
||||
if client:
|
||||
try:
|
||||
results[source] = await client.check_connection()
|
||||
except Exception:
|
||||
results[source] = False
|
||||
|
||||
logger.info(f" Soulseek: {'✅' if soulseek_ok else '❌'} | YouTube: {'✅' if youtube_ok else '❌'} | Tidal: {'✅' if tidal_ok else '❌'} | Qobuz: {'✅' if qobuz_ok else '❌'} | HiFi: {'✅' if hifi_ok else '❌'} | Deezer: {'✅' if deezer_ok else '❌'}")
|
||||
status_parts = [f"{s}: {'✅' if ok else '❌'}" for s, ok in results.items()]
|
||||
logger.info(f" {' | '.join(status_parts)}")
|
||||
|
||||
return soulseek_ok or youtube_ok or tidal_ok or qobuz_ok or hifi_ok or deezer_ok
|
||||
return any(results.values())
|
||||
|
||||
return False
|
||||
|
||||
|
|
|
|||
|
|
@ -4094,14 +4094,24 @@ def get_status():
|
|||
_status_cache_timestamps['media_server'] = current_time
|
||||
# else: use cached value
|
||||
|
||||
# Test Soulseek - with caching like other services
|
||||
# Test Soulseek - only if it's the active source or in the hybrid order
|
||||
if current_time - _status_cache_timestamps['soulseek'] > STATUS_CACHE_TTL:
|
||||
soulseek_start = time.time()
|
||||
try:
|
||||
soulseek_status = run_async(soulseek_client.check_connection()) if soulseek_client else False
|
||||
except Exception:
|
||||
download_mode = config_manager.get('download_source.mode', 'hybrid')
|
||||
hybrid_order = config_manager.get('download_source.hybrid_order', ['hifi', 'youtube', 'soulseek'])
|
||||
soulseek_relevant = (download_mode == 'soulseek' or
|
||||
(download_mode == 'hybrid' and 'soulseek' in hybrid_order))
|
||||
|
||||
if soulseek_relevant and soulseek_client:
|
||||
soulseek_start = time.time()
|
||||
try:
|
||||
soulseek_status = run_async(soulseek_client.check_connection())
|
||||
except Exception:
|
||||
soulseek_status = False
|
||||
soulseek_response_time = (time.time() - soulseek_start) * 1000
|
||||
else:
|
||||
soulseek_status = False
|
||||
soulseek_response_time = (time.time() - soulseek_start) * 1000
|
||||
soulseek_response_time = 0
|
||||
|
||||
_status_cache['soulseek'] = {
|
||||
'connected': soulseek_status,
|
||||
'response_time': round(soulseek_response_time, 1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue