From 9bf1948097964dc2643ec782f9fdb760eef585a6 Mon Sep 17 00:00:00 2001 From: Broque Thomas Date: Mon, 5 Jan 2026 21:27:54 -0800 Subject: [PATCH] Add priority query for Artist + Album + Title in matching Introduces a new priority 0 query that combines artist, album, and title for improved matching, especially for YouTube and hybrid download modes. This helps better match tracks where the album is significant, such as soundtracks, and only applies when the album is not a generic label like 'single' or 'greatest hits'. --- core/matching_engine.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/core/matching_engine.py b/core/matching_engine.py index 38c0c1d0..c5ce06e0 100644 --- a/core/matching_engine.py +++ b/core/matching_engine.py @@ -4,9 +4,11 @@ from dataclasses import dataclass from difflib import SequenceMatcher from unidecode import unidecode from utils.logging_config import get_logger +from config.settings import config_manager + from core.spotify_client import Track as SpotifyTrack from core.plex_client import PlexTrackInfo -from core.soulseek_client import TrackResult +from core.soulseek_client import TrackResult, AlbumResult logger = get_logger("matching_engine") @@ -409,6 +411,17 @@ class MusicMatchingEngine: if album_name: break + # PRIORITY 0: Try exact Artist + Album + Title (Best for OSTs) + # Often YouTube videos are titled "Artist - Album - Title" or similar + # Only include if mode is youtube or hybrid (safe for Soulseek default) + download_mode = config_manager.get('download_source.mode', 'soulseek') + if download_mode in ['youtube', 'hybrid'] and album_name and album_name.lower() not in ['single', 'ep', 'greatest hits']: + album_clean = self.clean_album_name(album_name) + if album_clean: + # Standard query: Artist Album Title + queries.append(f"{artist} {album_clean} {self.clean_title(original_title)}".strip()) + logger.debug(f"PRIORITY 0: Artist + Album + Title query: '{artist} {album_clean} {self.clean_title(original_title)}'") + # PRIORITY 1: Try removing potential album from title FIRST cleaned_title, album_detected = self.detect_album_in_title(original_title, album_name) if album_detected and cleaned_title != original_title: