Browse Source

Fix IndexError due to closest song

Phyks (Lucas Verney) 5 years ago
parent
commit
eb420eb7a8
1 changed files with 6 additions and 3 deletions
  1. 6
    3
      mpd/client.py

+ 6
- 3
mpd/client.py View File

@@ -168,9 +168,12 @@ def main(queue_length):
168 168
                             if ("file: %s" % (row["filename"],)) not in client.playlist()]
169 169
         cached_distances_songs = [i["filename"] for i in cached_distances]
170 170
         # Keep track of closest song
171
-        closest_song = (cached_distances[0],
172
-                        cached_distances[0]["distance"],
173
-                        cached_distances[1]["similarity"])
171
+        if cached_distances:
172
+            closest_song = (cached_distances[0],
173
+                            cached_distances[0]["distance"],
174
+                            cached_distances[1]["similarity"])
175
+        else:
176
+            closest_song = None
174 177
 
175 178
         # Get the songs close enough
176 179
         cached_distances_close_enough = [