add input filter check

add basic limit and custom naming
This commit is contained in:
Blacktwin 2019-01-01 09:26:50 -05:00
parent bb674a413d
commit 3b7d5216aa

View File

@ -561,10 +561,16 @@ if __name__ == "__main__":
'pop_tv': pop_tv_title, 'pop_tv': pop_tv_title,
'pop_movie': pop_movie_title, 'pop_movie': pop_movie_title,
'limit': opts.limit} 'limit': opts.limit}
if opts.search: if opts.search:
search = dict([opts.search]) search = dict([opts.search])
if opts.filter: if opts.filter:
filters = dict(opts.filter) filters = dict(opts.filter)
# Check if provided filter exist, exit if it doesn't exist
if not (set(filters.keys()) & set(filter_lst)):
print('({}) was not found in filters list: [{}]'
.format(' '.join(filters.keys()), ', '.join(filter_lst)))
exit()
# Defining users # Defining users
if opts.allUsers and not opts.user: if opts.allUsers and not opts.user:
@ -615,8 +621,16 @@ if __name__ == "__main__":
else: else:
keys_list, title = build_playlist(opts.jbop, libraries, opts.days, opts.top, filters, search) keys_list, title = build_playlist(opts.jbop, libraries, opts.days, opts.top, filters, search)
if len(keys_list) > opts.limit:
keys_list = keys_list[:opts.limit]
if opts.name:
title = opts.name
else:
title = title.title()
if opts.jbop and opts.action == 'show': if opts.jbop and opts.action == 'show':
show_playlist(title.title(), keys_list) show_playlist(title, keys_list)
if opts.action == 'update': if opts.action == 'update':
print("Deleting the playlist(s)...") print("Deleting the playlist(s)...")
@ -626,12 +640,12 @@ if __name__ == "__main__":
delete_playlist(playlist_dict) delete_playlist(playlist_dict)
print('Creating playlist(s)...') print('Creating playlist(s)...')
for x in plex_servers: for x in plex_servers:
create_playlist(title.title(), keys_list, x['server'], x['user']) create_playlist(title, keys_list, x['server'], x['user'])
if opts.action == 'add': if opts.action == 'add':
print('Creating playlist(s)...') print('Creating playlist(s)...')
for x in plex_servers: for x in plex_servers:
create_playlist(title.title(), keys_list, x['server'], x['user']) create_playlist(title, keys_list, x['server'], x['user'])
if opts.action == 'show': if opts.action == 'show':
print("Displaying the user's playlist(s)...") print("Displaying the user's playlist(s)...")