#144 adding servers as an arg.
This commit is contained in:
parent
ebc5151fbc
commit
cbc71bfc1a
@ -82,18 +82,21 @@ plex = PlexServer(PLEX_URL, PLEX_TOKEN, session=sess)
|
|||||||
|
|
||||||
sections_lst = [x.title for x in plex.library.sections()]
|
sections_lst = [x.title for x in plex.library.sections()]
|
||||||
user_lst = [x.title for x in plex.myPlexAccount().users()]
|
user_lst = [x.title for x in plex.myPlexAccount().users()]
|
||||||
|
servers_dict = {acct.name: acct for acct in plex.myPlexAccount().resources()
|
||||||
|
if 'server' in [acct.provides] and acct.ownerid == 0}
|
||||||
# Adding admin account name to list
|
# Adding admin account name to list
|
||||||
user_lst.append(plex.myPlexAccount().title)
|
user_lst.append(plex.myPlexAccount().title)
|
||||||
|
|
||||||
|
|
||||||
def get_account(user):
|
def get_account(user):
|
||||||
if user == plex.myPlexAccount().title:
|
if user == plex.myPlexAccount().title:
|
||||||
server = plex
|
account = plex
|
||||||
else:
|
else:
|
||||||
# Access Plex User's Account
|
# Access Plex User's Account
|
||||||
userAccount = plex.myPlexAccount().user(user)
|
userAccount = plex.myPlexAccount().user(user)
|
||||||
token = userAccount.get_token(plex.machineIdentifier)
|
token = userAccount.get_token(plex.machineIdentifier)
|
||||||
server = PlexServer(PLEX_URL, token)
|
account = PlexServer(PLEX_URL, token)
|
||||||
return server
|
return account
|
||||||
|
|
||||||
|
|
||||||
def mark_watached(sectionFrom, accountTo, userTo):
|
def mark_watached(sectionFrom, accountTo, userTo):
|
||||||
@ -122,6 +125,9 @@ if __name__ == '__main__':
|
|||||||
'(choices: %(choices)s)')
|
'(choices: %(choices)s)')
|
||||||
parser.add_argument('--allLibraries', action='store_true',
|
parser.add_argument('--allLibraries', action='store_true',
|
||||||
help='Select all libraries.')
|
help='Select all libraries.')
|
||||||
|
parser.add_argument('--servers', nargs='*', choices=servers_dict.keys(),
|
||||||
|
help='Space separated list of case sensitive names to process. Allowed names are: \n'
|
||||||
|
'(choices: %(choices)s)')
|
||||||
parser.add_argument('--ratingKey', nargs=1,
|
parser.add_argument('--ratingKey', nargs=1,
|
||||||
help='Rating key of item whose watch status is to be synced.')
|
help='Rating key of item whose watch status is to be synced.')
|
||||||
requiredNamed.add_argument('--userFrom', choices=user_lst, metavar='username', required=True,
|
requiredNamed.add_argument('--userFrom', choices=user_lst, metavar='username', required=True,
|
||||||
|
Loading…
Reference in New Issue
Block a user