mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-13 07:27:09 +00:00
Fix flake8 warnings
This commit is contained in:
parent
9c1b81b161
commit
fd015439c4
2 changed files with 13 additions and 19 deletions
|
@ -9,7 +9,6 @@ from plexapi.base import PlexObject
|
||||||
from plexapi.compat import ElementTree
|
from plexapi.compat import ElementTree
|
||||||
from plexapi.exceptions import BadRequest, Unsupported
|
from plexapi.exceptions import BadRequest, Unsupported
|
||||||
from plexapi.playqueue import PlayQueue
|
from plexapi.playqueue import PlayQueue
|
||||||
from plexapi.utils import cast
|
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_MTYPE = 'video'
|
DEFAULT_MTYPE = 'video'
|
||||||
|
|
|
@ -8,7 +8,7 @@ from plexapi import log, logfilter, utils
|
||||||
from plexapi.base import PlexObject
|
from plexapi.base import PlexObject
|
||||||
from plexapi.exceptions import BadRequest, NotFound
|
from plexapi.exceptions import BadRequest, NotFound
|
||||||
from plexapi.client import PlexClient
|
from plexapi.client import PlexClient
|
||||||
from plexapi.compat import ElementTree, quote
|
from plexapi.compat import ElementTree
|
||||||
from plexapi.library import LibrarySection
|
from plexapi.library import LibrarySection
|
||||||
from plexapi.server import PlexServer
|
from plexapi.server import PlexServer
|
||||||
from plexapi.utils import joinArgs
|
from plexapi.utils import joinArgs
|
||||||
|
@ -243,7 +243,6 @@ class MyPlexAccount(PlexObject):
|
||||||
machineId = server.machineIdentifier if isinstance(server, PlexServer) else server
|
machineId = server.machineIdentifier if isinstance(server, PlexServer) else server
|
||||||
sectionIds = self._getSectionIds(machineId, sections)
|
sectionIds = self._getSectionIds(machineId, sections)
|
||||||
headers = {'Content-Type': 'application/json'}
|
headers = {'Content-Type': 'application/json'}
|
||||||
|
|
||||||
# Determine whether user has access to the shared server.
|
# Determine whether user has access to the shared server.
|
||||||
user_servers = [s for s in user.servers if s.machineIdentifier == machineId]
|
user_servers = [s for s in user.servers if s.machineIdentifier == machineId]
|
||||||
if user_servers and sectionIds:
|
if user_servers and sectionIds:
|
||||||
|
@ -251,12 +250,11 @@ class MyPlexAccount(PlexObject):
|
||||||
params = {'server_id': machineId, 'shared_server': {'library_section_ids': sectionIds}}
|
params = {'server_id': machineId, 'shared_server': {'library_section_ids': sectionIds}}
|
||||||
url = self.FRIENDSERVERS.format(machineId=machineId, serverId=serverId)
|
url = self.FRIENDSERVERS.format(machineId=machineId, serverId=serverId)
|
||||||
else:
|
else:
|
||||||
params = {'server_id': machineId,
|
params = {'server_id': machineId, 'shared_server': {'library_section_ids': sectionIds,
|
||||||
'shared_server': {'library_section_ids': sectionIds, "invited_id": user.id}}
|
"invited_id": user.id}}
|
||||||
url = self.FRIENDINVITE.format(machineId=machineId)
|
url = self.FRIENDINVITE.format(machineId=machineId)
|
||||||
|
# Remove share sections, add shares to user without shares, or update shares
|
||||||
if sectionIds:
|
if sectionIds:
|
||||||
# Remove share sections, add shares to user without shares, or update shares
|
|
||||||
if removeSections is True:
|
if removeSections is True:
|
||||||
response_servers = self.query(url, self._session.delete, json=params, headers=headers)
|
response_servers = self.query(url, self._session.delete, json=params, headers=headers)
|
||||||
elif 'invited_id' in params.get('shared_server', ''):
|
elif 'invited_id' in params.get('shared_server', ''):
|
||||||
|
@ -265,27 +263,24 @@ class MyPlexAccount(PlexObject):
|
||||||
response_servers = self.query(url, self._session.put, json=params, headers=headers)
|
response_servers = self.query(url, self._session.put, json=params, headers=headers)
|
||||||
else:
|
else:
|
||||||
log.warning('Section name, number of section object is required changing library sections')
|
log.warning('Section name, number of section object is required changing library sections')
|
||||||
|
|
||||||
# Update friend filters
|
# Update friend filters
|
||||||
url = self.FRIENDUPDATE.format(userId=user.id)
|
url = self.FRIENDUPDATE.format(userId=user.id)
|
||||||
d = {}
|
params = {}
|
||||||
if isinstance(allowSync, bool):
|
if isinstance(allowSync, bool):
|
||||||
d['allowSync'] = '1' if allowSync else '0'
|
params['allowSync'] = '1' if allowSync else '0'
|
||||||
if isinstance(allowCameraUpload, bool):
|
if isinstance(allowCameraUpload, bool):
|
||||||
d['allowCameraUpload'] = '1' if allowCameraUpload else '0'
|
params['allowCameraUpload'] = '1' if allowCameraUpload else '0'
|
||||||
if isinstance(allowChannels, bool):
|
if isinstance(allowChannels, bool):
|
||||||
d['allowChannels'] = '1' if allowChannels else '0'
|
params['allowChannels'] = '1' if allowChannels else '0'
|
||||||
if isinstance(filterMovies, dict):
|
if isinstance(filterMovies, dict):
|
||||||
d['filterMovies'] = self._filterDictToStr(filterMovies or {}) #'1' if allowChannels else '0'
|
params['filterMovies'] = self._filterDictToStr(filterMovies or {}) # '1' if allowChannels else '0'
|
||||||
if isinstance(filterTelevision, dict):
|
if isinstance(filterTelevision, dict):
|
||||||
d['filterTelevision'] = self._filterDictToStr(filterTelevision or {})
|
params['filterTelevision'] = self._filterDictToStr(filterTelevision or {})
|
||||||
if isinstance(allowChannels, dict):
|
if isinstance(allowChannels, dict):
|
||||||
d['filterMusic'] = self._filterDictToStr(filterMusic or {})
|
params['filterMusic'] = self._filterDictToStr(filterMusic or {})
|
||||||
|
if params:
|
||||||
if d:
|
url += joinArgs(params)
|
||||||
url += joinArgs(d)
|
|
||||||
response_filters = self.query(url, self._session.put)
|
response_filters = self.query(url, self._session.put)
|
||||||
|
|
||||||
return response_servers, response_filters
|
return response_servers, response_filters
|
||||||
|
|
||||||
def user(self, username):
|
def user(self, username):
|
||||||
|
|
Loading…
Reference in a new issue