From a2c2e94bff371a8ec893e96c3e7b93f8760b5b85 Mon Sep 17 00:00:00 2001 From: Blacktwin Date: Wed, 25 Jul 2018 12:55:02 -0400 Subject: [PATCH] check if user has no servers --- utility/plex_api_share.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/utility/plex_api_share.py b/utility/plex_api_share.py index 3c886de..f320a1e 100644 --- a/utility/plex_api_share.py +++ b/utility/plex_api_share.py @@ -120,11 +120,13 @@ def find_shares(user): shared_lst = [] account = plex.myPlexAccount() user_acct = account.user(user) - shared_sections = user_acct.servers[0] - - for section in shared_sections.sections(): - if section.shared == True: - shared_lst.append(section.title) + try: + shared_sections = user_acct.servers[0] + for section in shared_sections.sections(): + if section.shared == True: + shared_lst.append(section.title) + except IndexError: + print('{} has no servers listed.'.format(user)) return shared_lst @@ -256,12 +258,12 @@ if __name__ == "__main__": if opts.share: share(user, libraries, opts.sync, opts.camera, opts.channels, filterMovies, filterTelevision, filterMusic) - if opts.add: + if opts.add and shared: libraries = libraries + shared libraries = list(set(libraries)) share(user, libraries, opts.sync, opts.camera, opts.channels, filterMovies, filterTelevision, filterMusic) - if opts.remove: + if opts.remove and shared: libraries = [sect for sect in shared if sect not in libraries] share(user, libraries, opts.sync, opts.camera, opts.channels, filterMovies, filterTelevision, filterMusic)