fix(worker): parse "Artist - Title" separator in search scoring

When a user types "Everything Yes - Too Late", the scoring system was
treating the entire string as the title and leaving the artist empty.
This meant the +20 artist-match bonus was never applied, and the -6
title-mismatch penalty hit the correct song (whose title is just "Too
Late", not "Everything Yes - Too Late").

_buildRequestContext now detects the " - " / " – " / " — " separator
in the query when no explicit trackMeta is provided, and splits into
artist + title for scoring. This makes "Artist - Title" queries match
the correct track instead of falling back to fuzzy title-only matching.
This commit is contained in:
NoLogicAlan committed 2026-06-21 15:40:47 +03:00
1 parent 49447dc37b
commit 4a436d6044
1 file changed
+10 -2
+10 -2
View File
@@ -225,8 +225,16 @@ class YTUtils extends EventEmitter {
} }
_buildRequestContext(query, trackMeta = null) { _buildRequestContext(query, trackMeta = null) {
const requestedTitle = trackMeta?.name ?? trackMeta?.title ?? query; let requestedTitle = trackMeta?.name ?? trackMeta?.title ?? query;
const requestedArtist = trackMeta?.artist ?? ""; let requestedArtist = trackMeta?.artist ?? "";
if (!trackMeta) {
const dashMatch = String(query).match(/^(.+?)\s+[-–—]\s+(.+)$/);
if (dashMatch) {
requestedArtist = dashMatch[1].trim();
requestedTitle = dashMatch[2].trim();
}
}
return { return {
normalizedTitle: normalizeMatchText(requestedTitle), normalizedTitle: normalizeMatchText(requestedTitle),