|
|
|
|
@ -711,6 +711,15 @@ class DatabaseLibraryWorker(QThread):
|
|
|
|
|
# Get database instance
|
|
|
|
|
db = get_database()
|
|
|
|
|
|
|
|
|
|
# Get active server for filtering
|
|
|
|
|
try:
|
|
|
|
|
from config.settings import config_manager
|
|
|
|
|
active_server = config_manager.get_active_media_server()
|
|
|
|
|
print(f"🔍 Checking albums against {active_server.upper()} library only")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print(f"⚠️ Could not get active server, defaulting to 'plex': {e}")
|
|
|
|
|
active_server = 'plex'
|
|
|
|
|
|
|
|
|
|
if self._stop_requested:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
@ -761,7 +770,7 @@ class DatabaseLibraryWorker(QThread):
|
|
|
|
|
# Search database for this combination with completeness info
|
|
|
|
|
print(f" 🔍 Searching database: album='{album_name}', artist='{artist_clean}'")
|
|
|
|
|
db_album, confidence, owned_tracks, expected_tracks, is_complete = db.check_album_exists_with_completeness(
|
|
|
|
|
album_name, artist_clean, expected_track_count, confidence_threshold=0.7
|
|
|
|
|
album_name, artist_clean, expected_track_count, confidence_threshold=0.7, server_source=active_server
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if db_album and confidence > best_confidence:
|
|
|
|
|
@ -780,7 +789,7 @@ class DatabaseLibraryWorker(QThread):
|
|
|
|
|
if not db_album and artist and artist != artist_clean:
|
|
|
|
|
print(f" 🔄 Backup search with original artist: album='{album_name}', artist='{artist}'")
|
|
|
|
|
db_album_backup, confidence_backup, owned_backup, expected_backup, complete_backup = db.check_album_exists_with_completeness(
|
|
|
|
|
album_name, artist, expected_track_count, confidence_threshold=0.7
|
|
|
|
|
album_name, artist, expected_track_count, confidence_threshold=0.7, server_source=active_server
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if db_album_backup and confidence_backup > best_confidence:
|
|
|
|
|
@ -797,7 +806,7 @@ class DatabaseLibraryWorker(QThread):
|
|
|
|
|
artist_no_comma = ' '.join(artist_no_comma.split())
|
|
|
|
|
print(f" 🔄 Comma-removal fallback: album='{album_name}', artist='{artist_no_comma}'")
|
|
|
|
|
db_album_comma, confidence_comma, owned_comma, expected_comma, complete_comma = db.check_album_exists_with_completeness(
|
|
|
|
|
album_name, artist_no_comma, expected_track_count, confidence_threshold=0.7
|
|
|
|
|
album_name, artist_no_comma, expected_track_count, confidence_threshold=0.7, server_source=active_server
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if db_album_comma and confidence_comma > best_confidence:
|
|
|
|
|
@ -4099,10 +4108,18 @@ class ArtistsPage(QWidget):
|
|
|
|
|
self.singles_eps_worker.start()
|
|
|
|
|
|
|
|
|
|
def start_plex_library_check(self, albums):
|
|
|
|
|
"""Start Plex library check in background"""
|
|
|
|
|
# Show toast for Plex check start
|
|
|
|
|
"""Start database library check in background"""
|
|
|
|
|
# Get active server for dynamic toast message
|
|
|
|
|
try:
|
|
|
|
|
from config.settings import config_manager
|
|
|
|
|
active_server = config_manager.get_active_media_server()
|
|
|
|
|
server_name = "Jellyfin" if active_server == "jellyfin" else "Plex"
|
|
|
|
|
except:
|
|
|
|
|
server_name = "Plex" # Fallback
|
|
|
|
|
|
|
|
|
|
# Show toast for library check start
|
|
|
|
|
if hasattr(self, 'toast_manager') and self.toast_manager:
|
|
|
|
|
self.toast_manager.info("Checking your Plex library for owned albums...")
|
|
|
|
|
self.toast_manager.info(f"Checking your {server_name} library for owned albums...")
|
|
|
|
|
|
|
|
|
|
# Stop any existing Plex worker
|
|
|
|
|
if self.plex_library_worker:
|
|
|
|
|
@ -4203,12 +4220,20 @@ class ArtistsPage(QWidget):
|
|
|
|
|
"""Handle Plex library check failure"""
|
|
|
|
|
print(f"Plex library check failed: {error}")
|
|
|
|
|
|
|
|
|
|
# Get active server for dynamic error message
|
|
|
|
|
try:
|
|
|
|
|
from config.settings import config_manager
|
|
|
|
|
active_server = config_manager.get_active_media_server()
|
|
|
|
|
server_name = "Jellyfin" if active_server == "jellyfin" else "Plex"
|
|
|
|
|
except:
|
|
|
|
|
server_name = "Plex" # Fallback
|
|
|
|
|
|
|
|
|
|
# Show error toast
|
|
|
|
|
if hasattr(self, 'toast_manager') and self.toast_manager:
|
|
|
|
|
self.toast_manager.error("Plex connection failed - cannot check owned albums")
|
|
|
|
|
self.toast_manager.error(f"{server_name} connection failed - cannot check owned albums")
|
|
|
|
|
|
|
|
|
|
if self.current_albums:
|
|
|
|
|
self.albums_status.setText(f"Found {len(self.current_albums)} albums • Plex check failed")
|
|
|
|
|
self.albums_status.setText(f"Found {len(self.current_albums)} albums • {server_name} check failed")
|
|
|
|
|
# Display albums without ownership info
|
|
|
|
|
self.display_albums(self.current_albums, set())
|
|
|
|
|
|
|
|
|
|
|