allowing --allPlaylists to function properly with remove
This commit is contained in:
parent
c1865f77de
commit
bcec98f189
@ -507,7 +507,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']
|
||||||
playlist_names = playlist_dict['playlist_name']
|
user_playlists = playlist_dict['user_playlists']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# todo-me this needs improvement
|
# todo-me this needs improvement
|
||||||
@ -537,7 +537,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 playlist_names:
|
elif playlist.title in user_playlists:
|
||||||
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))
|
||||||
@ -625,34 +625,29 @@ if __name__ == "__main__":
|
|||||||
# Defining libraries
|
# Defining libraries
|
||||||
libraries = exclusions(opts.allLibraries, opts.libraries, sections_dict)
|
libraries = exclusions(opts.allLibraries, opts.libraries, sections_dict)
|
||||||
|
|
||||||
# Defining playlist
|
# Defining server playlist
|
||||||
if opts.allPlaylists and not opts.playlists:
|
server_playlists = exclusions(opts.allPlaylists, opts.playlists, playlist_lst)
|
||||||
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
|
|
||||||
|
|
||||||
playlist_dict['playlist_name'] = playlists
|
|
||||||
# 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 playlists:
|
if opts.action == 'share' and server_playlists:
|
||||||
print("Sharing playlist(s)...")
|
print("Sharing playlist(s)...")
|
||||||
share_playlists(playlists, users)
|
share_playlists(server_playlists, users)
|
||||||
user_acct = account.user(user)
|
user_acct = account.user(user)
|
||||||
|
user_server = PlexServer(PLEX_URL, user_acct.get_token(plex.machineIdentifier))
|
||||||
plex_servers.append({
|
plex_servers.append({
|
||||||
'server': PlexServer(PLEX_URL, user_acct.get_token(plex.machineIdentifier)),
|
'server': user_server,
|
||||||
'user': user})
|
'user': user,
|
||||||
|
'user_playlists': [pl.title for pl in user_server.playlists()]})
|
||||||
if opts.self:
|
if opts.self:
|
||||||
plex_servers.append({'server': plex,
|
plex_servers.append({'server': plex,
|
||||||
'user': 'admin'})
|
'user': 'admin',
|
||||||
|
'user_playlists': server_playlists})
|
||||||
else:
|
else:
|
||||||
plex_servers.append({'server': plex,
|
plex_servers.append({'server': plex,
|
||||||
'user': 'admin'})
|
'user': 'admin',
|
||||||
|
'user_playlists': server_playlists})
|
||||||
|
|
||||||
# Remove or build playlists
|
# Remove or build playlists
|
||||||
if opts.action == 'remove':
|
if opts.action == 'remove':
|
||||||
@ -660,6 +655,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']
|
||||||
delete_playlist(playlist_dict, opts.jbop)
|
delete_playlist(playlist_dict, opts.jbop)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user