Repository navigation
fix(bot): eliminate same-song repetition in autoplay - #575
Conversation
…eed dedup and expanded version suffix patterns - Expand HYPHENATED_VERSION_SUFFIXES to strip 'Live Version', 'Remastered Version', 'Deluxe Edition', etc. - Normalize seed titles via cleanTitle() before Last.fm deduplication so 'Song - Remastered' and 'Song' collapse to one seed - Use cleanSearchQuery() for all seed-based Last.fm search queries to strip version noise before searching - Pass cleaned title to getSimilarTracks() so Last.fm finds the canonical track, not a decorated version
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThese changes improve track deduplication and Last.fm search accuracy by applying consistent title normalization across the music utility pipeline. The Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/bot/src/utils/music/queueManipulation.ts (1)
754-754: Normalize artist forgetSimilarTrackstoo, for full symmetry.Line 754 cleans only title. Using
cleanAuthor(seed.artist)here keeps Last.fm similar-track seeding consistent with the cleaned-query path.Proposed patch
- const similar = await getSimilarTracks(seed.artist, cleanTitle(seed.title)) + const similar = await getSimilarTracks( + cleanAuthor(seed.artist), + cleanTitle(seed.title), + )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/bot/src/utils/music/queueManipulation.ts` at line 754, Call cleanAuthor on the seed artist before passing it to getSimilarTracks to mirror the title normalization path; replace the direct use of seed.artist in the getSimilarTracks call with cleanAuthor(seed.artist) so getSimilarTracks(seedArtist, cleanTitle(seed.title)) uses normalized artist and title (refer to getSimilarTracks, cleanAuthor, cleanTitle, and seed.artist).packages/bot/src/utils/music/autoplay/lastFmSeeds.ts (1)
8-8: Consider normalizing artist in dedupe keys as well.Line 32–33 now normalizes title (great), but artist is still only lowercased. Trimming/cleaning artist too will make dedup keys more stable.
Proposed patch
-import { cleanTitle } from '../searchQueryCleaner' +import { cleanAuthor, cleanTitle } from '../searchQueryCleaner' ... - const normalizedTitle = cleanTitle(t.title).toLowerCase().trim() - const key = `${t.artist.toLowerCase()}|${normalizedTitle}` + const normalizedArtist = cleanAuthor(t.artist).toLowerCase().trim() + const normalizedTitle = cleanTitle(t.title).toLowerCase().trim() + const key = `${normalizedArtist}|${normalizedTitle}`Also applies to: 32-33
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/bot/src/utils/music/autoplay/lastFmSeeds.ts` at line 8, The dedupe key generation in lastFmSeeds.ts currently only lowercases the artist while calling cleanTitle on the title; update the artist normalization to match by trimming and cleaning it (e.g., replace artist.toLowerCase() with cleanTitle(artist) or trim+clean equivalent) wherever the dedupe key is constructed (the function that builds the dedupe key in this file), so artist values are normalized the same way as titles.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/bot/src/utils/music/autoplay/lastFmSeeds.ts`:
- Line 8: The dedupe key generation in lastFmSeeds.ts currently only lowercases
the artist while calling cleanTitle on the title; update the artist
normalization to match by trimming and cleaning it (e.g., replace
artist.toLowerCase() with cleanTitle(artist) or trim+clean equivalent) wherever
the dedupe key is constructed (the function that builds the dedupe key in this
file), so artist values are normalized the same way as titles.
In `@packages/bot/src/utils/music/queueManipulation.ts`:
- Line 754: Call cleanAuthor on the seed artist before passing it to
getSimilarTracks to mirror the title normalization path; replace the direct use
of seed.artist in the getSimilarTracks call with cleanAuthor(seed.artist) so
getSimilarTracks(seedArtist, cleanTitle(seed.title)) uses normalized artist and
title (refer to getSimilarTracks, cleanAuthor, cleanTitle, and seed.artist).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b9a7ba2a-7e78-4aab-bb1c-776c08bb2c9a
📒 Files selected for processing (3)
packages/bot/src/utils/music/autoplay/lastFmSeeds.tspackages/bot/src/utils/music/queueManipulation.tspackages/bot/src/utils/music/searchQueryCleaner.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: SonarCloud Scan
- GitHub Check: Quality Gates
🔇 Additional comments (2)
packages/bot/src/utils/music/searchQueryCleaner.ts (1)
87-93: Expanded hyphen-suffix normalization is on point.Line 87–93 strengthens canonicalization for remaster/live/deluxe/explicit variants and aligns with the duplicate-prevention path in
cleanTitle.packages/bot/src/utils/music/queueManipulation.ts (1)
728-729: Good consistency win: cleaned queries are now used in Last.fm-driven searches.Line 728, Line 756, and Line 872 now funnel through
cleanSearchQuery, which should materially reduce variant-title leakage into candidate generation.Also applies to: 756-757, 872-873
|
…eed dedup and expanded version suffix patterns (#575) - Expand HYPHENATED_VERSION_SUFFIXES to strip 'Live Version', 'Remastered Version', 'Deluxe Edition', etc. - Normalize seed titles via cleanTitle() before Last.fm deduplication so 'Song - Remastered' and 'Song' collapse to one seed - Use cleanSearchQuery() for all seed-based Last.fm search queries to strip version noise before searching - Pass cleaned title to getSimilarTracks() so Last.fm finds the canonical track, not a decorated version



Problem
Autoplay was repeatedly queuing different versions of the same song (e.g. "Song - Remastered", "Song - Live Version", "Song - Deluxe Edition") because:
HYPHENATED_VERSION_SUFFIXESwas incomplete — patterns like"Live Version","Remastered Version","Deluxe Edition"didn't match, socleanTitle()left the suffix in place and two versions normalized to different keys"Song"and"Song - Remastered"as top tracks, both passed dedup and generated separate searches"Song - Remastered Artist"as a search query produces different YouTube results than"Song Artist", allowing version variants to slip through the candidates mapChanges
searchQueryCleaner.ts: ExpandHYPHENATED_VERSION_SUFFIXESto handle"Live Version","Remastered Version","Deluxe Edition","Explicit Version","Instrumental Version", etc.lastFmSeeds.ts: UsecleanTitle()when building the dedup key so"Song - Remastered"and"Song"collapse to one seed entryqueueManipulation.ts: UsecleanSearchQuery()for all seed-based Last.fm searches (direct search + getSimilarTracks) to strip version noise before queryingResult
Different versions of the same song now normalize to the same key at every stage of the pipeline — seed dedup, search query, candidates map, and history exclusion — so they can't both make it into the queue.
Summary by CodeRabbit