fix(backend): generalize release-suffix stripping from search title
Handles all Spotify trailing suffixes: Single, EP, Remaster, Deluxe Edition, Bonus Tracks, B-Sides, bare years (2024), Official Music Single, etc. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
bff652a415
commit
5f257bf451
1 file changed
+5
-3
@@ -110,9 +110,11 @@ async function downloadTrack({ jobId, artist, rawArtist, albumArtist, title, alb
|
|||||||
|
|
||||||
const escRe = s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
const escRe = s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||||
|
|
||||||
// Strip release-type suffixes Spotify sometimes appends to track/album names
|
// Strip release-type suffixes Spotify appends to track names (e.g. "recognize - Single" → "recognize").
|
||||||
// e.g. "recognize - Single" → "recognize", "Blue Moon - EP" → "Blue Moon"
|
// Only strip trailing "- word(s)" when those words are release-type qualifiers or bare years, not
|
||||||
const searchTitle = title.replace(/\s*[-–]\s*(single|ep|album|remaster(?:ed)?|deluxe(?:\s+edition)?|bonus\s+track)s?\s*$/i, '').trim() || title;
|
// real sub-titles (which tend to be longer phrases or start with "feat"/"ft").
|
||||||
|
const RELEASE_SUFFIX_RE = /\s*[-–]\s*(?:(?:official\s+)?(?:music\s+)?(?:single|ep|lp|album|ost|soundtrack|remaster(?:ed)?|deluxe(?:\s+edition)?|bonus\s+tracks?|b-?sides?|version|edit)\b.*|(?:20|19)\d{2})\s*$/i;
|
||||||
|
const searchTitle = title.replace(RELEASE_SUFFIX_RE, '').trim() || title;
|
||||||
|
|
||||||
const variantFilter = buildVariantFilter(searchTitle);
|
const variantFilter = buildVariantFilter(searchTitle);
|
||||||
const titleKws = buildTitleKeywords(searchTitle);
|
const titleKws = buildTitleKeywords(searchTitle);
|
||||||
|
|||||||
Reference in new issue
Block a user