added shuffle option

This commit is contained in:
aj 2019-05-15 14:31:16 +01:00
parent ddc8c0918b
commit 81c2c290dd

View File

@ -37,6 +37,13 @@ if __name__ == '__main__':
else: else:
log.log("requested playlist {} not found".format(part)) log.log("requested playlist {} not found".format(part))
if 'shuffle' in tomake:
if tomake['shuffle'] is True:
import random
random.shuffle(tracks)
else:
tracks.sort(key=lambda x: x['track']['album']['release_date'], reverse=True)
else:
tracks.sort(key=lambda x: x['track']['album']['release_date'], reverse=True) tracks.sort(key=lambda x: x['track']['album']['release_date'], reverse=True)
net.replacePlaylistTracks(tomake['id'], [i['track']['uri'] for i in tracks]) net.replacePlaylistTracks(tomake['id'], [i['track']['uri'] for i in tracks])