#141 fix for remove action

This commit is contained in:
Blacktwin 2019-02-09 01:14:21 -05:00
parent 4c014cfc24
commit d2b37837d8

View File

@ -486,10 +486,19 @@ def delete_playlist(playlist_dict, title):
try: try:
# todo-me this needs improvement # todo-me this needs improvement
for playlist in server.playlists(): for playlist in server.playlists():
if playlist.title == title: if isinstance(title, str):
playlist.delete() # If str then updating playlist
print("...Deleted Playlist: {playlist.title} for '{user}'." if playlist.title == title:
.format(playlist=playlist, user=user)) playlist.delete()
print("...Deleted Playlist: {playlist.title} for '{user}'."
.format(playlist=playlist, user=user))
if isinstance(title, list):
# If list then removing selected playlists
if playlist.title in title:
playlist.delete()
print("...Deleted Playlist: {playlist.title} for '{user}'."
.format(playlist=playlist, user=user))
except: except:
# print("Playlist not found on '{user}' account".format(user=user)) # print("Playlist not found on '{user}' account".format(user=user))
pass pass
@ -638,17 +647,14 @@ if __name__ == "__main__":
if libraries: if libraries:
title = create_title(opts.jbop, libraries, opts.days, filters, search, opts.limit) title = create_title(opts.jbop, libraries, opts.days, filters, search, opts.limit)
keys_list = build_playlist(opts.jbop, libraries, opts.days, opts.top, filters, search, opts.limit) keys_list = build_playlist(opts.jbop, libraries, opts.days, opts.top, filters, search, opts.limit)
else:
# Remove or build playlists # Remove or build playlists
if opts.action == 'remove': if opts.action == 'remove':
print("Deleting the playlist(s)...") print("Deleting the playlist(s)...")
for data in playlist_dict['data']: for data in playlist_dict['data']:
delete_playlist(data, title) titles = data['user_selected']
else: delete_playlist(data, titles)
print('This function requires libraries to be listed.')
exit()
# Check if limit exist and if it's greater than the pulled list of rating keys # Check if limit exist and if it's greater than the pulled list of rating keys
if opts.limit and len(keys_list) > int(opts.limit): if opts.limit and len(keys_list) > int(opts.limit):