add recently played playlist

This commit is contained in:
cwilvx
2024-05-23 12:42:36 +03:00
parent 30768dd5d6
commit bbcacf81bd
10 changed files with 142 additions and 62 deletions
+10 -2
View File
@@ -129,10 +129,18 @@ class TrackStore:
"""
Returns a list of tracks by their hashes.
"""
hash_set = set(trackhashes)
set_len = len(hash_set)
trackhashes = " ".join(trackhashes)
tracks = [track for track in cls.tracks if track.trackhash in trackhashes]
tracks = []
for track in cls.tracks:
if track.trackhash in hash_set:
tracks.append(track)
if len(tracks) == set_len:
break
# sort the tracks in the order of the given trackhashes
tracks.sort(key=lambda t: trackhashes.index(t.trackhash))
return tracks