Skip to content

Commit

Permalink
Fix radio for playlists < 5 items. (music-assistant#1401)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinSchenkel authored Jun 23, 2024
1 parent 2f9df0f commit 8dce289
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion music_assistant/server/controllers/media/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,10 @@ async def _get_provider_dynamic_tracks(
# to account for playlists with mixed content we grab suggestions from a few
# random playlist tracks to prevent getting too many tracks of one of the
# source playlist's genres.
sample_size = min(len(playlist_tracks), 5)
while len(final_items) < limit:
# grab 5 random tracks from the playlist
base_tracks = random.sample(playlist_tracks, 5)
base_tracks = random.sample(playlist_tracks, sample_size)
# add the source/base playlist tracks to the final list...
final_items.extend(base_tracks)
# get 5 suggestions for one of the base tracks
Expand Down

0 comments on commit 8dce289

Please sign in to comment.