From cd809ba2f03baad72a3d216009cdfe258f8decf7 Mon Sep 17 00:00:00 2001 From: "Nicholas St. Germain" Date: Wed, 2 Oct 2019 13:42:33 -0500 Subject: [PATCH] Add check for already-unshared libraries Fixes #188 --- utility/remove_inactive_users.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/utility/remove_inactive_users.py b/utility/remove_inactive_users.py index 8ef14a8..7576acb 100644 --- a/utility/remove_inactive_users.py +++ b/utility/remove_inactive_users.py @@ -113,5 +113,11 @@ for user in TAUTULLI_USERS: if DRY_RUN: print('{}, and would unshare libraries.'.format(OUTPUT)) else: - print('{}, and has reached their inactivity limit. Unsharing.'.format(OUTPUT)) - ACCOUNT.updateFriend(PLEX_USERS[UID], SERVER, SECTIONS, removeSections=True) + + for server in ACCOUNT.user(PLEX_USERS[UID]).servers: + if server.machineIdentifier == SERVER.machineIdentifier and server.sections(): + print('{}, and has reached their inactivity limit. Unsharing.'.format(OUTPUT)) + ACCOUNT.updateFriend(PLEX_USERS[UID], SERVER, SECTIONS, removeSections=True) + else: + print("{}, has already been unshared, but has not reached their shareless threshold." + "Skipping.".format(OUTPUT))