From ee9f3b7386343f8def381c3c8ab944c6e32d6cdf Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Tue, 24 Mar 2026 12:02:48 -0700 Subject: [PATCH] Fix $albumtype template not working for singles in album context search The album-aware search (_detect_album_info_album_context) was forcing is_album=True for every track found in any release, including singles. This routed singles through the album_path template instead of single_path, ignoring the user's $albumtype folder structure. Now applies the same classification logic as _detect_album_info_web: checks album_type, total_tracks, and name comparisons to correctly distinguish albums from singles/EPs. Works for all metadata sources (Spotify, iTunes, Deezer) since all album objects have album_type. --- web_server.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/web_server.py b/web_server.py index 51fe7106..c01effba 100644 --- a/web_server.py +++ b/web_server.py @@ -14035,11 +14035,20 @@ def _search_track_in_album_context_web(context: dict, spotify_artist: dict) -> d if similarity > threshold: print(f"✅ FOUND: '{track_name}' (track #{track_number}) matches '{clean_track}' (similarity: {similarity:.2f})") - print(f"🎯 Forcing album classification for track in '{album.name}'") - - # Return album info - force album classification! + + # Classify as album vs single using same logic as _detect_album_info_web + ctx_album_type = getattr(album, 'album_type', 'album') or 'album' + ctx_total_tracks = getattr(album, 'total_tracks', 1) or 1 + ctx_is_album = ( + ctx_album_type == 'album' and + ctx_total_tracks > 1 and + matching_engine.normalize_string(album.name) != matching_engine.normalize_string(clean_track) and + matching_engine.normalize_string(album.name) != matching_engine.normalize_string(artist_name) + ) + print(f"📊 Album context classification: is_album={ctx_is_album} (type={ctx_album_type}, tracks={ctx_total_tracks})") + return { - 'is_album': True, # Always true - we found it in an album! + 'is_album': ctx_is_album, 'album_name': album.name, 'track_number': track_number, 'clean_track_name': clean_track, # Use the ORIGINAL download title, not the database match