diff --git a/src/player.js b/src/player.js index b8c5ec6..74f5e0d 100644 --- a/src/player.js +++ b/src/player.js @@ -618,8 +618,21 @@ export async function toggleRadioMode() { export async function fillRadioQueue() { if(!S.radioMode) return; try { - const r = await api('getRandomSongs', '&size=20'); - const newSongs = r.randomSongs?.song || []; + const seed = S.queue[S.qIdx]; + let newSongs = []; + if (seed?.id) { + const r = await api('getSimilarSongs2', `&id=${seed.id}&count=20`); + newSongs = r.similarSongs2?.song || []; + } + // Fall back to random if similar songs unavailable (no Last.fm config, unknown track, etc.) + if (!newSongs.length) { + const r = await api('getRandomSongs', '&size=20'); + newSongs = r.randomSongs?.song || []; + } + // Deduplicate against songs already queued + const existingIds = new Set(S.queue.map(s => s.id)); + newSongs = newSongs.filter(s => !existingIds.has(s.id)); + if (!newSongs.length) return; const prevLen = S.queue.length; S.queue.push(...newSongs); renderQueue();