Fix: account for playlists with less than 50 images/items
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Fri, 25 Oct 2024 12:42:39 +0000 (14:42 +0200)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Fri, 25 Oct 2024 12:42:39 +0000 (14:42 +0200)
music_assistant/server/controllers/metadata.py

index 4671ff39573adcfdcc2484c05901055928b4ca45..73bb44c4ae7f6fc96071ecf9b29aecfe57736aff 100644 (file)
@@ -403,7 +403,10 @@ class MetaDataController(CoreController):
             # require at least some images otherwise this does not make a lot of sense
             return None
         # limit to 50 images to prevent we're going OOM
-        images = random.sample(images, 50)
+        if len(images) > 50:
+            images = random.sample(images, 50)
+        else:
+            random.shuffle(images)
         try:
             # create collage thumb from playlist tracks
             # if playlist has no default image (e.g. a local playlist)