feat: autoplay con artistas similares, pre-fill anticipado, cola prio…#38
Merged
Conversation
…ritaria y dedup robusto - get_similar_artists_tracks: busca artistas co-escuchados via search?type=artist - Autoplay siempre mezcla mismo artista + artistas similares (sin filtro < MAX) - Pre-fill anticipado cuando quedan ≤2 canciones en cola - Seeding limpio al hacer /stop (evita contaminación entre géneros) - Eliminado search_youtube_by_genre (genres vacíos con Client Credentials) - Dedup por URL + autor|título + filtro primary_artist - original_uri seteado en autoplay para historial completo - Cola prioritaria: tracks de usuario insertados tras otros tracks del usuario
There was a problem hiding this comment.
Pull request overview
This PR refactors autoplay seeding/dedup logic and enhances queue management so user-requested tracks are prioritized while autoplay pulls from the seed artist and similar artists (Spotify-first, YouTube fallback).
Changes:
- Added new Spotify resolver helpers for artist top-tracks and “similar artists” discovery, plus expanded recommendation logic.
- Implemented autoplay diversity/state tracking (seed/artist/url/title histories), early pre-fill when the queue is low, and cleaner state reset on stop.
- Changed enqueue behavior to insert user tracks after existing user tracks (ahead of autoplay tracks) and added basic cache trimming.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
utils/spotify_resolver.py |
Updates Spotify recommendation strategy and adds new helper APIs for top-tracks and similar-artist track discovery. |
cogs/music.py |
Reworks autoplay candidate generation, adds histories + early prefill, prioritizes user queue insertion, and trims caches. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+461
to
+465
| seed_artist_name = artists_data[0]["name"] | ||
| seed_url = data.get("external_urls", {}).get("spotify", "") or "" | ||
| exclude = exclude_artists or set() | ||
| exclude.add(seed_artist_name) | ||
|
|
Comment on lines
+1556
to
1560
| Uses YouTube search with artist name for related music discovery. | ||
| Rotates search queries to get different recommendations each time. | ||
| Adds 1 to AUTOPLAY_MAX_TRACKS tracks. | ||
| Returns the number of tracks added. | ||
| """ |
Comment on lines
+1289
to
+1290
| for i, track in enumerate(tracks): | ||
| player.queue.insert(user_count + i, track) |
Comment on lines
+1531
to
+1532
| for i, track in enumerate(tracks): | ||
| player.queue.insert(user_count + i, track) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…ritaria y dedup robusto