allowing --allPlaylists to function properly with remove

This commit is contained in:
Blacktwin 2019-01-04 13:21:34 -05:00
parent c1865f77de
commit bcec98f189

View File

@ -507,7 +507,7 @@ def delete_playlist(playlist_dict, jbop):
user = playlist_dict['user']
pop_movie = playlist_dict['pop_movie']
pop_tv = playlist_dict['pop_tv']
playlist_names = playlist_dict['playlist_name']
user_playlists = playlist_dict['user_playlists']
try:
# todo-me this needs improvement
@ -537,7 +537,7 @@ def delete_playlist(playlist_dict, jbop):
playlist.delete()
print("...Deleted Playlist: {playlist.title} for '{user}'."
.format(playlist=playlist, user=user))
elif playlist.title in playlist_names:
elif playlist.title in user_playlists:
playlist.delete()
print("...Deleted Playlist: {playlist.title} for '{user}'."
.format(playlist=playlist, user=user))
@ -625,34 +625,29 @@ if __name__ == "__main__":
# Defining libraries
libraries = exclusions(opts.allLibraries, opts.libraries, sections_dict)
# Defining playlist
if opts.allPlaylists and not opts.playlists:
playlists = playlist_lst
elif not opts.allPlaylists and opts.playlists:
playlists = opts.playlists
elif opts.allPlaylists and opts.playlists:
# If allPlaylists is used then any playlists listed will be excluded
for playlist in opts.playlists:
playlist_lst.remove(playlist)
playlists = playlist_lst
# Defining server playlist
server_playlists = exclusions(opts.allPlaylists, opts.playlists, playlist_lst)
playlist_dict['playlist_name'] = playlists
# Create user server objects
if users:
for user in users:
if opts.action == 'share' and playlists:
if opts.action == 'share' and server_playlists:
print("Sharing playlist(s)...")
share_playlists(playlists, users)
share_playlists(server_playlists, users)
user_acct = account.user(user)
user_server = PlexServer(PLEX_URL, user_acct.get_token(plex.machineIdentifier))
plex_servers.append({
'server': PlexServer(PLEX_URL, user_acct.get_token(plex.machineIdentifier)),
'user': user})
'server': user_server,
'user': user,
'user_playlists': [pl.title for pl in user_server.playlists()]})
if opts.self:
plex_servers.append({'server': plex,
'user': 'admin'})
'user': 'admin',
'user_playlists': server_playlists})
else:
plex_servers.append({'server': plex,
'user': 'admin'})
'user': 'admin',
'user_playlists': server_playlists})
# Remove or build playlists
if opts.action == 'remove':
@ -660,6 +655,7 @@ if __name__ == "__main__":
for x in plex_servers:
playlist_dict['server'] = x['server']
playlist_dict['user'] = x['user']
playlist_dict['user_playlists'] = x['user_playlists']
delete_playlist(playlist_dict, opts.jbop)
else: