Skip to content

fix(autoplay): reject long tracks, boost Spotify, strip tribute/duration noise - #594

Merged
LucasSantana-Dev merged 1 commit into
mainfrom
fix/autoplay-quality-v2
Apr 13, 2026
Merged

LucasSantana-Dev merged 1 commit into
mainfrom
fix/autoplay-quality-v2

Conversation

@LucasSantana-Dev

@LucasSantana-Dev LucasSantana-Dev commented Apr 13, 2026 •

Copy link
Copy Markdown
Owner

What

Three root causes behind the issues visible in the screenshot (7-hour video queued, duplicates of now-playing, all tracks from YouTube):

1. Hard-reject tracks > 15 minutes

calculateRecommendationScore previously gave tracks over 7 min a -0.2 penalty — a 7-hour looped YouTube upload still scored high enough to win. Now anything above 15 min returns -Infinity and is dropped at scoring time, covering all candidate paths (seed search, Last.fm, broad fallback).

2. Spotify boost +0.15 → +0.4

The old boost was too weak — when Spotify search returned results they were barely beating YouTube candidates. With +0.4, a Spotify result wins decisively unless the track has a blocking reason (disliked, blocked artist, etc.).

3. Low-quality upload penalty -0.4

Tracks whose resolved title still contains legendado / traduzido / tradução / legendas penalised by -0.4. Eliminates YouTube fan-upload junk even when Spotify fallback fires.

4. New noise patterns (dedup key improvement)

  • (Tributo ao Batman) / [Tributo a Led Zeppelin] stripped → core key now matches the clean title
  • (Homenagem a X) stripped
  • (HH:MM:SS) duration annotations stripped (e.g. (07:05:14) from looped uploads)
  • legendas added to bareTitleNoise

These ensure purgeDuplicatesOfCurrentTrack and isDuplicateCandidate correctly match tribute/fan-annotated versions of the now-playing track.

Tests

12 new tests — 2188 total, all green.

Summary by CodeRabbit

  • New Features

    • Implemented track duration filtering to exclude songs exceeding 15 minutes from queue recommendations.
    • Enhanced Spotify source prioritization in music selection.
    • Added low-quality upload detection for tracks with dubbing and subtitle markers.
    • Improved title cleaning to remove tribute annotations and duration notations.
  • Tests

    • Added comprehensive test coverage for duration filtering and quality detection mechanisms.

- hard-reject candidates with durationMS > 15 min (7-hour looped videos no longer slip through)
- spotify score boost 0.15 -> 0.4 so spotify decisively beats youtube fallbacks
- low-quality penalty -0.4 for legendado/traduzido/traducao in resolved title
- noise patterns: strip (Tributo ao X), (Homenagem...), HH:MM:SS duration annotations
- noiseTerms.json: add legendas to bareTitleNoise
- 12 new tests (2188 total, all green)
@vercel

vercel Bot commented Apr 13, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lucky Ready Ready Preview, Comment Apr 13, 2026 10:14pm

@coderabbitai

coderabbitai Bot commented Apr 13, 2026 •

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR enhances the bot's music queue processing by expanding noise term handling with "legendas", implementing track duration rejection (>15 minutes), penalizing low-quality uploads matching subtitle/translation patterns, increasing Spotify source preference scoring, and adding title cleaning for tribute and duration annotations.

Changes

Cohort / File(s) Summary
Noise Terms Configuration
packages/bot/src/utils/music/noiseTerms.json
Added "legendas" to the bareTitleNoise array to expand noise tokens applied during bare title processing.
Queue Manipulation Logic & Scoring
packages/bot/src/utils/music/queueManipulation.ts
Implemented duration rejection (tracks >15 min return score -Infinity), added low-quality upload penalty (0.4 reduction) for titles matching subtitle/legend/tribute patterns, increased Spotify source boost from 0.15 to 0.4, and adjusted formatting in candidate extraction and seed query building.
Queue Manipulation Tests
packages/bot/src/utils/music/queueManipulation.spec.ts
Added test cases verifying duration rejection and low-quality upload penalty logic; reformatted Spotify mock structures and adjusted string expectations without changing assertion behavior.
Search Query Cleaning Logic
packages/bot/src/utils/music/searchQueryCleaner.ts
Added regex patterns to NOISE_PATTERNS for stripping tribute/homage parentheticals and duration-like annotations (HH:MM:SS format) from titles during cleanTitle processing.
Search Query Cleaning Tests
packages/bot/src/utils/music/searchQueryCleaner.spec.ts
Added new test suite validating cleanTitle behavior for tribute tags, homage annotations, and duration-marker stripping while preserving MM:SS-like patterns.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

bot, size/m

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the three main changes: rejecting long tracks, boosting Spotify preference, and stripping tribute/duration noise from titles.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/autoplay-quality-v2

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit 65cb5b9 into main Apr 13, 2026
11 of 12 checks passed
LucasSantana-Dev added a commit that referenced this pull request May 13, 2026
…#594)

- hard-reject candidates with durationMS > 15 min (7-hour looped videos no longer slip through)
- spotify score boost 0.15 -> 0.4 so spotify decisively beats youtube fallbacks
- low-quality penalty -0.4 for legendado/traduzido/traducao in resolved title
- noise patterns: strip (Tributo ao X), (Homenagem...), HH:MM:SS duration annotations
- noiseTerms.json: add legendas to bareTitleNoise
- 12 new tests (2188 total, all green)
@LucasSantana-Dev
LucasSantana-Dev deleted the fix/autoplay-quality-v2 branch May 23, 2026 02:21

This branch was successfully deployed

1 active deployment
Preview — ba4d77c6 Deployed Apr 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant