From 4a436d6044cdbe172132a06ae6063dff31ce2298 Mon Sep 17 00:00:00 2001 From: NoLogicAlan Date: Sun, 21 Jun 2026 15:40:47 +0300 Subject: [PATCH] fix(worker): parse "Artist - Title" separator in search scoring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/worker.mjs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/worker.mjs b/src/worker.mjs index 4a61336..d5a0d4b 100644 --- a/src/worker.mjs +++ b/src/worker.mjs @@ -225,8 +225,16 @@ class YTUtils extends EventEmitter { } _buildRequestContext(query, trackMeta = null) { - const requestedTitle = trackMeta?.name ?? trackMeta?.title ?? query; - const requestedArtist = trackMeta?.artist ?? ""; + let requestedTitle = trackMeta?.name ?? trackMeta?.title ?? query; + let requestedArtist = trackMeta?.artist ?? ""; + + if (!trackMeta) { + const dashMatch = String(query).match(/^(.+?)\s+[-–—]\s+(.+)$/); + if (dashMatch) { + requestedArtist = dashMatch[1].trim(); + requestedTitle = dashMatch[2].trim(); + } + } return { normalizedTitle: normalizeMatchText(requestedTitle),