updated artist live album check to use server specific data
This commit is contained in:
parent
0c90f4f327
commit
5b6ea29522
4 changed files with 42 additions and 13 deletions
|
|
@ -1137,7 +1137,7 @@ class MusicDatabase:
|
||||||
tracks.append(track)
|
tracks.append(track)
|
||||||
return tracks
|
return tracks
|
||||||
|
|
||||||
def search_albums(self, title: str = "", artist: str = "", limit: int = 50) -> List[DatabaseAlbum]:
|
def search_albums(self, title: str = "", artist: str = "", limit: int = 50, server_source: Optional[str] = None) -> List[DatabaseAlbum]:
|
||||||
"""Search albums by title and/or artist name with fuzzy matching"""
|
"""Search albums by title and/or artist name with fuzzy matching"""
|
||||||
try:
|
try:
|
||||||
conn = self._get_connection()
|
conn = self._get_connection()
|
||||||
|
|
@ -1155,6 +1155,10 @@ class MusicDatabase:
|
||||||
where_conditions.append("artists.name LIKE ?")
|
where_conditions.append("artists.name LIKE ?")
|
||||||
params.append(f"%{artist}%")
|
params.append(f"%{artist}%")
|
||||||
|
|
||||||
|
if server_source:
|
||||||
|
where_conditions.append("albums.server_source = ?")
|
||||||
|
params.append(server_source)
|
||||||
|
|
||||||
if not where_conditions:
|
if not where_conditions:
|
||||||
# If no search criteria, return empty list
|
# If no search criteria, return empty list
|
||||||
return []
|
return []
|
||||||
|
|
@ -1389,7 +1393,7 @@ class MusicDatabase:
|
||||||
logger.error(f"Error checking album completeness for album_id {album_id}: {e}")
|
logger.error(f"Error checking album completeness for album_id {album_id}: {e}")
|
||||||
return 0, 0, False
|
return 0, 0, False
|
||||||
|
|
||||||
def check_album_exists_with_completeness(self, title: str, artist: str, expected_track_count: Optional[int] = None, confidence_threshold: float = 0.8) -> Tuple[Optional[DatabaseAlbum], float, int, int, bool]:
|
def check_album_exists_with_completeness(self, title: str, artist: str, expected_track_count: Optional[int] = None, confidence_threshold: float = 0.8, server_source: Optional[str] = None) -> Tuple[Optional[DatabaseAlbum], float, int, int, bool]:
|
||||||
"""
|
"""
|
||||||
Check if an album exists in the database with completeness information.
|
Check if an album exists in the database with completeness information.
|
||||||
Enhanced to handle edition matching (standard <-> deluxe variants).
|
Enhanced to handle edition matching (standard <-> deluxe variants).
|
||||||
|
|
@ -1397,7 +1401,7 @@ class MusicDatabase:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# Try enhanced edition-aware matching first with expected track count for Smart Edition Matching
|
# Try enhanced edition-aware matching first with expected track count for Smart Edition Matching
|
||||||
album, confidence = self.check_album_exists_with_editions(title, artist, confidence_threshold, expected_track_count)
|
album, confidence = self.check_album_exists_with_editions(title, artist, confidence_threshold, expected_track_count, server_source)
|
||||||
|
|
||||||
if not album:
|
if not album:
|
||||||
return None, 0.0, 0, 0, False
|
return None, 0.0, 0, 0, False
|
||||||
|
|
@ -1411,7 +1415,7 @@ class MusicDatabase:
|
||||||
logger.error(f"Error checking album existence with completeness for '{title}' by '{artist}': {e}")
|
logger.error(f"Error checking album existence with completeness for '{title}' by '{artist}': {e}")
|
||||||
return None, 0.0, 0, 0, False
|
return None, 0.0, 0, 0, False
|
||||||
|
|
||||||
def check_album_exists_with_editions(self, title: str, artist: str, confidence_threshold: float = 0.8, expected_track_count: Optional[int] = None) -> Tuple[Optional[DatabaseAlbum], float]:
|
def check_album_exists_with_editions(self, title: str, artist: str, confidence_threshold: float = 0.8, expected_track_count: Optional[int] = None, server_source: Optional[str] = None) -> Tuple[Optional[DatabaseAlbum], float]:
|
||||||
"""
|
"""
|
||||||
Enhanced album existence check that handles edition variants.
|
Enhanced album existence check that handles edition variants.
|
||||||
Matches standard albums with deluxe/platinum/special editions and vice versa.
|
Matches standard albums with deluxe/platinum/special editions and vice versa.
|
||||||
|
|
@ -1429,7 +1433,7 @@ class MusicDatabase:
|
||||||
|
|
||||||
for variation in title_variations:
|
for variation in title_variations:
|
||||||
# Search for this variation
|
# Search for this variation
|
||||||
albums = self.search_albums(title=variation, artist=artist, limit=10)
|
albums = self.search_albums(title=variation, artist=artist, limit=10, server_source=server_source)
|
||||||
|
|
||||||
if albums:
|
if albums:
|
||||||
logger.debug(f"📀 Found {len(albums)} albums for variation '{variation}'")
|
logger.debug(f"📀 Found {len(albums)} albums for variation '{variation}'")
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -711,6 +711,15 @@ class DatabaseLibraryWorker(QThread):
|
||||||
# Get database instance
|
# Get database instance
|
||||||
db = get_database()
|
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:
|
if self._stop_requested:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -761,7 +770,7 @@ class DatabaseLibraryWorker(QThread):
|
||||||
# Search database for this combination with completeness info
|
# Search database for this combination with completeness info
|
||||||
print(f" 🔍 Searching database: album='{album_name}', artist='{artist_clean}'")
|
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(
|
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:
|
if db_album and confidence > best_confidence:
|
||||||
|
|
@ -780,7 +789,7 @@ class DatabaseLibraryWorker(QThread):
|
||||||
if not db_album and artist and artist != artist_clean:
|
if not db_album and artist and artist != artist_clean:
|
||||||
print(f" 🔄 Backup search with original artist: album='{album_name}', artist='{artist}'")
|
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(
|
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:
|
if db_album_backup and confidence_backup > best_confidence:
|
||||||
|
|
@ -797,7 +806,7 @@ class DatabaseLibraryWorker(QThread):
|
||||||
artist_no_comma = ' '.join(artist_no_comma.split())
|
artist_no_comma = ' '.join(artist_no_comma.split())
|
||||||
print(f" 🔄 Comma-removal fallback: album='{album_name}', artist='{artist_no_comma}'")
|
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(
|
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:
|
if db_album_comma and confidence_comma > best_confidence:
|
||||||
|
|
@ -4099,10 +4108,18 @@ class ArtistsPage(QWidget):
|
||||||
self.singles_eps_worker.start()
|
self.singles_eps_worker.start()
|
||||||
|
|
||||||
def start_plex_library_check(self, albums):
|
def start_plex_library_check(self, albums):
|
||||||
"""Start Plex library check in background"""
|
"""Start database library check in background"""
|
||||||
# Show toast for Plex check start
|
# 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:
|
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
|
# Stop any existing Plex worker
|
||||||
if self.plex_library_worker:
|
if self.plex_library_worker:
|
||||||
|
|
@ -4203,12 +4220,20 @@ class ArtistsPage(QWidget):
|
||||||
"""Handle Plex library check failure"""
|
"""Handle Plex library check failure"""
|
||||||
print(f"Plex library check failed: {error}")
|
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
|
# Show error toast
|
||||||
if hasattr(self, 'toast_manager') and self.toast_manager:
|
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:
|
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
|
# Display albums without ownership info
|
||||||
self.display_albums(self.current_albums, set())
|
self.display_albums(self.current_albums, set())
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue