88from plexapi .base import PlexObject
99from plexapi .exceptions import BadRequest , NotFound
1010from plexapi .client import PlexClient
11- from plexapi .compat import ElementTree , quote
11+ from plexapi .compat import ElementTree
1212from plexapi .library import LibrarySection
1313from plexapi .server import PlexServer
1414from plexapi .utils import joinArgs
@@ -243,20 +243,18 @@ def updateFriend(self, user, server, sections=None, removeSections=False, allowS
243243 machineId = server .machineIdentifier if isinstance (server , PlexServer ) else server
244244 sectionIds = self ._getSectionIds (machineId , sections )
245245 headers = {'Content-Type' : 'application/json' }
246-
247246 # Determine whether user has access to the shared server.
248247 user_servers = [s for s in user .servers if s .machineIdentifier == machineId ]
249248 if user_servers and sectionIds :
250249 serverId = user_servers [0 ].id
251250 params = {'server_id' : machineId , 'shared_server' : {'library_section_ids' : sectionIds }}
252251 url = self .FRIENDSERVERS .format (machineId = machineId , serverId = serverId )
253252 else :
254- params = {'server_id' : machineId ,
255- 'shared_server' : { 'library_section_ids' : sectionIds , "invited_id" : user .id }}
253+ params = {'server_id' : machineId , 'shared_server' : { 'library_section_ids' : sectionIds ,
254+ "invited_id" : user .id }}
256255 url = self .FRIENDINVITE .format (machineId = machineId )
257-
256+ # Remove share sections, add shares to user without shares, or update shares
258257 if sectionIds :
259- # Remove share sections, add shares to user without shares, or update shares
260258 if removeSections is True :
261259 response_servers = self .query (url , self ._session .delete , json = params , headers = headers )
262260 elif 'invited_id' in params .get ('shared_server' , '' ):
@@ -265,27 +263,24 @@ def updateFriend(self, user, server, sections=None, removeSections=False, allowS
265263 response_servers = self .query (url , self ._session .put , json = params , headers = headers )
266264 else :
267265 log .warning ('Section name, number of section object is required changing library sections' )
268-
269266 # Update friend filters
270267 url = self .FRIENDUPDATE .format (userId = user .id )
271- d = {}
268+ params = {}
272269 if isinstance (allowSync , bool ):
273- d ['allowSync' ] = '1' if allowSync else '0'
270+ params ['allowSync' ] = '1' if allowSync else '0'
274271 if isinstance (allowCameraUpload , bool ):
275- d ['allowCameraUpload' ] = '1' if allowCameraUpload else '0'
272+ params ['allowCameraUpload' ] = '1' if allowCameraUpload else '0'
276273 if isinstance (allowChannels , bool ):
277- d ['allowChannels' ] = '1' if allowChannels else '0'
274+ params ['allowChannels' ] = '1' if allowChannels else '0'
278275 if isinstance (filterMovies , dict ):
279- d ['filterMovies' ] = self ._filterDictToStr (filterMovies or {}) # '1' if allowChannels else '0'
276+ params ['filterMovies' ] = self ._filterDictToStr (filterMovies or {}) # '1' if allowChannels else '0'
280277 if isinstance (filterTelevision , dict ):
281- d ['filterTelevision' ] = self ._filterDictToStr (filterTelevision or {})
278+ params ['filterTelevision' ] = self ._filterDictToStr (filterTelevision or {})
282279 if isinstance (allowChannels , dict ):
283- d ['filterMusic' ] = self ._filterDictToStr (filterMusic or {})
284-
285- if d :
286- url += joinArgs (d )
280+ params ['filterMusic' ] = self ._filterDictToStr (filterMusic or {})
281+ if params :
282+ url += joinArgs (params )
287283 response_filters = self .query (url , self ._session .put )
288-
289284 return response_servers , response_filters
290285
291286 def user (self , username ):
0 commit comments