Added unduplicator
This commit is contained in:
parent
1c38a7a37e
commit
3aca24f69f
|
@ -8,6 +8,17 @@ from random import shuffle
|
|||
from time import strftime
|
||||
|
||||
|
||||
def unduplicate_list (tracks):
|
||||
known = []
|
||||
cur = 0
|
||||
while cur < len (tracks):
|
||||
if tracks [cur] in known:
|
||||
del tracks [cur]
|
||||
continue
|
||||
known.append (tracks [cur])
|
||||
cur += 1
|
||||
|
||||
|
||||
def get_or_post (token, url, data = None):
|
||||
d = None
|
||||
if type (data) == bytes:
|
||||
|
@ -60,9 +71,16 @@ def create_playlist (token, name, description, tracks):
|
|||
|
||||
def playlist_shuffle (token, playlist):
|
||||
tracks = read_playlist (token, playlist)
|
||||
unduplicate_list (tracks)
|
||||
shuffle (tracks)
|
||||
create_playlist (token, list_playlists (token) [playlist] + ' - Shuffled ' + strftime ('%Y-%m-%d %H:%M:%S'), 'Shuffled playlist', tracks)
|
||||
|
||||
|
||||
def playlist_unduplicate (token, playlist):
|
||||
tracks = read_playlist (token, playlist)
|
||||
unduplicate_list (tracks)
|
||||
create_playlist (token, list_playlists (token) [playlist] + ' - Undiplicates', 'Non duplicated playlist', tracks)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise (NotImplementedError ('no CLI interface yet'))
|
Loading…
Reference in New Issue