Repository navigation
fix: hard-reject ambient/noise and EDM-mix tracks in autoplay #615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b0902f0
2e6124d
3738e38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1745,6 +1745,12 @@ function getTrackKey(track: Track): string { | |
|
|
||
| const FUZZY_TITLE_THRESHOLD = 0.82 | ||
|
|
||
| const AMBIENT_NOISE_RE = | ||
| /\b(?:rain sounds?|rain for sleep|ocean waves?|waves? sounds?|nature sounds?|forest sounds?|thunder sounds?|white noise|brown noise|pink noise|asmr|sleep sounds?|sleep music|relaxing rain|ambient sounds?|binaural beats?|solfeggio|healing frequ|528 ?hz|432 ?hz|963 ?hz|chakra healing|spa music|massage music|yoga music|deep sleep|baby sleep|guided meditation|meditation music)\b/i // NOSONAR S5852 — trusted track title from internal API, not user input | ||
|
|
||
| const EDM_MIX_RE = | ||
| /\b(?:dj set|festival set|\d+ ?(?:hour|hr) mix|extended mix|club mix|nightclub mix|edm mix|trance mix)\b/i // NOSONAR S5852 — trusted track title from internal API, not user input | ||
|
|
||
|
Comment on lines
+1748
to
+1753
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regex currently misses common blocked-title variants. Line [1749] uses Proposed fix-const AMBIENT_NOISE_RE =
- /\b(?:rain\s{0,3}sounds?|rain\s{0,3}for\s{0,3}sleep|ocean\s{0,3}waves?|waves?\s{0,3}sounds?|nature\s{0,3}sounds?|forest\s{0,3}sounds?|thunder\s{0,3}sounds?|white\s{0,3}noise|brown\s{0,3}noise|pink\s{0,3}noise|asmr|sleep\s{0,3}sounds?|sleep\s{0,3}music|relaxing\s{0,3}rain|ambient\s{0,3}sounds?|binaural\s{0,3}beats?|solfeggio|healing\s{0,3}frequ?e?n?c?|528\s?hz|432\s?hz|963\s?hz|chakra\s{0,3}healing|spa\s{0,3}music|massage\s{0,3}music|yoga\s{0,3}music|deep\s{0,3}sleep|baby\s{0,3}sleep|guided\s{0,3}meditation|meditation\s{0,3}music)\b/i
+const AMBIENT_NOISE_RE =
+ /\b(?:rain\s{0,3}sounds?|rain\s{0,3}for\s{0,3}sleep|ocean\s{0,3}waves?|waves?\s{0,3}sounds?|nature\s{0,3}sounds?|forest\s{0,3}sounds?|thunder\s{0,3}sounds?|white\s{0,3}noise|brown\s{0,3}noise|pink\s{0,3}noise|asmr|sleep\s{0,3}sounds?|sleep\s{0,3}music|relaxing\s{0,3}rain|ambient\s{0,3}sounds?|binaural\s{0,3}beats?|solfeggio|healing\s{0,3}frequenc(?:y|ies)|528\s?hz|432\s?hz|963\s?hz|chakra\s{0,3}healing|spa\s{0,3}music|massage\s{0,3}music|yoga\s{0,3}music|deep\s{0,3}sleep|baby\s{0,3}sleep|guided\s{0,3}meditation|meditation\s{0,3}music)\b/i
- const candidateTitle = candidate.title ?? ''
+ const candidateTitle = (candidate.title ?? '').replace(/[-_/]+/g, ' ')Also applies to: 1818-1824 🤖 Prompt for AI Agents |
||
| function isDuplicateCandidate( | ||
| track: Track, | ||
| excludedUrls: Set<string>, | ||
|
|
@@ -1809,6 +1815,14 @@ function calculateRecommendationScore( | |
| return { score: -Infinity, reason: 'track too long' } | ||
| } | ||
|
|
||
| const candidateTitle = candidate.title ?? '' | ||
| if (AMBIENT_NOISE_RE.test(candidateTitle)) { | ||
| return { score: -Infinity, reason: 'ambient/noise content' } | ||
| } | ||
| if (EDM_MIX_RE.test(candidateTitle)) { | ||
| return { score: -Infinity, reason: 'dj mix / edm set' } | ||
| } | ||
|
|
||
| let score = 1 | ||
| const reasons: string[] = [] | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make these new rejection tests independent of duration filters.
Line [3351] and Line [3391] use 1-hour candidates, which are already excluded by existing duration caps before title regex checks run. These tests can pass even if the new ambient/EDM guards are removed.
Proposed test fix
Also applies to: 3366-3404
🤖 Prompt for AI Agents