#133 --self did not have all of self's playlists

clean up variable
clean up self or no self selection
This commit is contained in:
Blacktwin 2019-01-05 20:22:32 -05:00
parent 3d632aa65e
commit ca19d3d6b4

View File

@ -522,7 +522,7 @@ def delete_playlist(playlist_dict, jbop):
user = playlist_dict['user'] user = playlist_dict['user']
pop_movie = playlist_dict['pop_movie'] pop_movie = playlist_dict['pop_movie']
pop_tv = playlist_dict['pop_tv'] pop_tv = playlist_dict['pop_tv']
user_playlists = playlist_dict['user_playlists'] user_selected = playlist_dict['user_selected']
try: try:
# todo-me this needs improvement # todo-me this needs improvement
@ -552,7 +552,7 @@ def delete_playlist(playlist_dict, jbop):
playlist.delete() playlist.delete()
print("...Deleted Playlist: {playlist.title} for '{user}'." print("...Deleted Playlist: {playlist.title} for '{user}'."
.format(playlist=playlist, user=user)) .format(playlist=playlist, user=user))
elif playlist.title in user_playlists: elif playlist.title in user_selected:
playlist.delete() playlist.delete()
print("...Deleted Playlist: {playlist.title} for '{user}'." print("...Deleted Playlist: {playlist.title} for '{user}'."
.format(playlist=playlist, user=user)) .format(playlist=playlist, user=user))
@ -637,32 +637,30 @@ if __name__ == "__main__":
# Defining libraries # Defining libraries
libraries = exclusions(opts.allLibraries, opts.libraries, sections_dict) libraries = exclusions(opts.allLibraries, opts.libraries, sections_dict)
# Defining server playlist # Defining selected playlists
server_playlists = exclusions(opts.allPlaylists, opts.playlists, playlist_lst) selected_playlists = exclusions(opts.allPlaylists, opts.playlists, playlist_lst)
# Create user server objects # Create user server objects
if users: if users:
for user in users: for user in users:
if opts.action == 'share' and server_playlists: if opts.action == 'share' and selected_playlists:
print("Sharing playlist(s)...") print("Sharing playlist(s)...")
share_playlists(server_playlists, users) share_playlists(selected_playlists, users)
user_acct = account.user(user) user_acct = account.user(user)
user_server = PlexServer(PLEX_URL, user_acct.get_token(plex.machineIdentifier)) user_server = PlexServer(PLEX_URL, user_acct.get_token(plex.machineIdentifier))
all_playlists = [pl.title for pl in user_server.playlists()] all_playlists = [pl.title for pl in user_server.playlists()]
user_playlists = exclusions(opts.allPlaylists, opts.playlists, all_playlists) user_selected = exclusions(opts.allPlaylists, opts.playlists, all_playlists)
plex_servers.append({ plex_servers.append({
'server': user_server, 'server': user_server,
'user': user, 'user': user,
'user_playlists': user_playlists, 'user_selected': user_selected,
'all_playlists': all_playlists}) 'all_playlists': all_playlists})
if opts.self:
if opts.self or not users:
plex_servers.append({'server': plex, plex_servers.append({'server': plex,
'user': 'admin', 'user': 'admin',
'user_playlists': server_playlists}) 'user_selected': selected_playlists,
else: 'all_playlists': playlist_lst})
plex_servers.append({'server': plex,
'user': 'admin',
'user_playlists': server_playlists})
playlist_dict['data'] = plex_servers playlist_dict['data'] = plex_servers
@ -680,7 +678,7 @@ if __name__ == "__main__":
for x in playlist_dict['data']: for x in playlist_dict['data']:
playlist_dict['server'] = x['server'] playlist_dict['server'] = x['server']
playlist_dict['user'] = x['user'] playlist_dict['user'] = x['user']
playlist_dict['user_playlists'] = x['user_playlists'] playlist_dict['user_selected'] = x['user_selected']
delete_playlist(playlist_dict, opts.jbop) delete_playlist(playlist_dict, opts.jbop)
else: else:
@ -706,7 +704,7 @@ if __name__ == "__main__":
for x in plex_servers: for x in plex_servers:
playlist_dict['server'] = x['server'] playlist_dict['server'] = x['server']
playlist_dict['user'] = x['user'] playlist_dict['user'] = x['user']
playlist_dict['user_playlists'] = x['user_playlists'] playlist_dict['user_selected'] = x['user_selected']
delete_playlist(playlist_dict, opts.jbop) delete_playlist(playlist_dict, opts.jbop)
print('Creating playlist(s)...') print('Creating playlist(s)...')
for x in plex_servers: for x in plex_servers: