From 8040484a2c6077c567ddfdc1898d0fc69f8d7edf Mon Sep 17 00:00:00 2001 From: Lucas Santana Date: Fri, 17 Apr 2026 13:21:07 -0300 Subject: [PATCH] =?UTF-8?q?feat(autoplay):=20spotify-taste-blend=20?= =?UTF-8?q?=E2=80=94=20candidate=20scoring=20with=20user=20taste=20boost?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../music/autoplay/spotifyRecommender.ts | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/bot/src/utils/music/autoplay/spotifyRecommender.ts b/packages/bot/src/utils/music/autoplay/spotifyRecommender.ts index 91b058af2..49dadec88 100644 --- a/packages/bot/src/utils/music/autoplay/spotifyRecommender.ts +++ b/packages/bot/src/utils/music/autoplay/spotifyRecommender.ts @@ -11,6 +11,7 @@ import { getSpotifyRecommendations, type SpotifyAudioFeatures, } from '../../../spotify/spotifyApi' +import { getUserSpotifySeeds } from '../../../spotify/spotifyUserSeeds' import { cleanTitle, cleanAuthor, @@ -63,6 +64,10 @@ export async function collectSpotifyRecommendationCandidates( ).catch(() => null) if (!token) return + const userSpotifySeeds = await Promise.resolve( + getUserSpotifySeeds(requestedBy.id), + ).catch(() => null) + const seedIds = seedTracks .map(extractSpotifyTrackId) .filter((id): id is string => id !== null) @@ -140,9 +145,20 @@ export async function collectSpotifyRecommendationCandidates( sessionMood, ) if (rec.score === -Infinity) continue + let score = rec.score + 0.3 + let reason = rec.reason ? `${rec.reason} • spotify rec` : 'spotify rec' + + if (userSpotifySeeds !== null) { + const trackArtistLower = track.author.toLowerCase() + if (userSpotifySeeds.artistNames.has(trackArtistLower)) { + score += 0.08 + reason += ' • spotify taste' + } + } + upsertScoredCandidate(candidates, track, { - score: rec.score + 0.3, - reason: rec.reason ? `${rec.reason} • spotify rec` : 'spotify rec', + score, + reason, }) } }