feat: recommend from Deezer and YouTube Music radios
CI / chart (push) Successful in 2s
CI / test (push) Successful in 1m57s
CI / chart-push (push) Successful in 5s
CI / image (push) Successful in 3m39s

- Deezer: /artist/{id}/radio for collection artists, affinity 2.0
- YouTube Music: RDAMVM watch playlist via yt-dlp, affinity 2.0
- seed radios from the 2 newest songs of the mood's own catalog
- dedupe candidates by recording, not only by external id
- clean raw YouTube titles and Topic suffixes when indexing
- tests, smoke marker for the RDAMVM path, docs
This commit is contained in:
TapTap committed 2026-11-17 15:22:05 +00:00
1 parent 62bcefad20
commit 26c41cc7d9
12 files changed
+296 -44

No files matched your search

@@ -81,6 +81,11 @@ class DeezerSearch(
artistTopTracks(id, SEED_TOP_LIMIT).forEach {
add(found, it, SEED_TOP_AFFINITY)
}
// Deezer's own radio is the recommendation engine at its strongest:
// a Daft Punk radio mixes Daft Punk with MGMT, Caribou, Jamiroquai.
artistRadio(id, SEED_RADIO_LIMIT).forEach {
add(found, it, RADIO_AFFINITY)
}
}
val related = LinkedHashSet<Long>()
@@ -176,6 +181,11 @@ class DeezerSearch(
.filter { it > 0 }
}.getOrDefault(emptyList())
private fun artistRadio(id: Long, limit: Int): List<TrackCandidate> = runCatching {
val body = get("$apiBase/artist/$id/radio?limit=$limit&output=json")
json.decodeFromString<DeezerTracksResponse>(body).data.mapNotNull { it.toCandidate() }
}.getOrDefault(emptyList())
private fun artistTopTracks(id: Long, limit: Int): List<TrackCandidate> = runCatching {
val body = get("$apiBase/artist/$id/top?limit=$limit&output=json")
json.decodeFromString<DeezerTracksResponse>(body).data.mapNotNull { it.toCandidate() }
@@ -270,6 +280,7 @@ class DeezerSearch(
const val MAX_RELATED_ARTISTS = 6
const val MAX_SEED_ALBUMS = 2
const val SEED_TOP_LIMIT = 25
const val SEED_RADIO_LIMIT = 40
const val RELATED_TOP_LIMIT = 10
const val ALBUM_TRACK_LIMIT = 40
const val ARTIST_LOOKUP_LIMIT = 5
@@ -277,6 +288,8 @@ class DeezerSearch(
/** A hit by an artist already in the mood; the scorer adds the rest. */
const val SEED_TOP_AFFINITY = 0.5
/** A track Deezer itself puts in that artist's radio. */
const val RADIO_AFFINITY = 2.0
/** A hit by an artist Deezer considers similar to the collection. */
const val RELATED_AFFINITY = 1.5
/** Another track from an album already in the mood. */