mirror of
https://github.com/pkkid/python-plexapi
synced 2024-09-21 14:21:57 +00:00
Home user and remove sections
def updateFriend() update to allow for removing sections if `remove_sections=True`. def user() update to find Home user names.
This commit is contained in:
parent
e58df7edb2
commit
0650aaad67
1 changed files with 6 additions and 3 deletions
|
@ -216,7 +216,7 @@ class MyPlexAccount(PlexObject):
|
|||
url = url.format(userId=user.id)
|
||||
return self.query(url, self._session.delete)
|
||||
|
||||
def updateFriend(self, user, server, sections=None, allowSync=False, allowCameraUpload=False,
|
||||
def updateFriend(self, user, server, sections=None, remove_sections=False, allowSync=False, allowCameraUpload=False,
|
||||
allowChannels=False, filterMovies=None, filterTelevision=None, filterMusic=None):
|
||||
""" Update the specified user's share settings.
|
||||
|
||||
|
@ -242,7 +242,10 @@ class MyPlexAccount(PlexObject):
|
|||
params = {'server_id': machineId, 'shared_server': {'library_section_ids': sectionIds}}
|
||||
headers = {'Content-Type': 'application/json'}
|
||||
url = self.FRIENDSERVERS.format(machineId=machineId, serverId=serverId)
|
||||
response_servers = self.query(url, self._session.put, json=params, headers=headers)
|
||||
if remove_sections == True:
|
||||
response_servers = self.query(url, self._session.delete, json=params, headers=headers)
|
||||
else:
|
||||
response_servers = self.query(url, self._session.put, json=params, headers=headers)
|
||||
# Update friend filters
|
||||
url = self.FRIENDUPDATE.format(userId=user.id)
|
||||
url += '?allowSync=%s' % ('1' if allowSync else '0')
|
||||
|
@ -262,7 +265,7 @@ class MyPlexAccount(PlexObject):
|
|||
"""
|
||||
for user in self.users():
|
||||
# Hhome users don't have email, username etc.
|
||||
if username.lower() == user.title:
|
||||
if username.lower() == user.title.lower():
|
||||
return user
|
||||
elif (user.username and user.email and user.id and username.lower() in
|
||||
(user.username.lower(), user.email.lower(), str(user.id))):
|
||||
|
|
Loading…
Reference in a new issue