mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-10 14:14:19 +00:00
Remove unneeded util functions
This commit is contained in:
parent
c0958a0edc
commit
1815e67804
3 changed files with 2 additions and 106 deletions
|
@ -354,9 +354,9 @@ class Playable(object):
|
|||
"""
|
||||
def _loadData(self, data):
|
||||
self.sessionKey = utils.cast(int, data.attrib.get('sessionKey')) # session
|
||||
self.username = utils.findUsername(data) # session
|
||||
self.usernames = self.listAttrs(data, 'title', etag='User') # session
|
||||
self.players = self.findItems(data, etag='Player') # session
|
||||
self.transcodeSession = utils.findTranscodeSession(self._server, data) # session
|
||||
self.transcodeSessions = self.findItems(data, etag='TranscodeSession') # session
|
||||
self.viewedAt = utils.toDatetime(data.attrib.get('viewedAt')) # history
|
||||
self.playlistItemID = utils.cast(int, data.attrib.get('playlistItemID')) # playlist
|
||||
|
||||
|
|
|
@ -66,50 +66,6 @@ def cast(func, value):
|
|||
return value
|
||||
|
||||
|
||||
def findPlayer(server, data, initpath):
|
||||
""" Returns the :class:`~plexapi.client.PlexClient` object found in the specified data.
|
||||
|
||||
Parameters:
|
||||
server (:class:`~plexapi.server.PlexServer`): PlexServer object this is from.
|
||||
data (ElementTree): XML data to find Player in.
|
||||
"""
|
||||
elem = data.find('Player')
|
||||
if elem is not None:
|
||||
from plexapi.client import PlexClient
|
||||
addr = elem.attrib.get('address')
|
||||
port = elem.attrib.get('port')
|
||||
baseurl = '%s:%s' % (addr, port) if port else addr
|
||||
return PlexClient(baseurl, server=server, data=elem, initpath=initpath)
|
||||
|
||||
|
||||
def findTranscodeSession(server, data):
|
||||
""" Returns a :class:`~plexapi.media.TranscodeSession` object if found within the specified
|
||||
XML data.
|
||||
|
||||
Parameters:
|
||||
server (:class:`~plexapi.server.PlexServer`): PlexServer object this is from.
|
||||
data (ElementTree): XML data to find TranscodeSession in.
|
||||
"""
|
||||
|
||||
elem = data.find('TranscodeSession')
|
||||
if elem is not None:
|
||||
from plexapi import media
|
||||
return media.TranscodeSession(server, elem)
|
||||
return None
|
||||
|
||||
|
||||
def findUsername(data):
|
||||
""" Returns the username if found in the specified XML data. Returns None if not found.
|
||||
|
||||
Parameters:
|
||||
data (ElementTree): XML data to find username in.
|
||||
"""
|
||||
elem = data.find('User')
|
||||
if elem is not None:
|
||||
return elem.attrib.get('title')
|
||||
return None
|
||||
|
||||
|
||||
def firstAttr(elem, *attrs):
|
||||
""" Return the first attribute in attrs that is not None. """
|
||||
for attr in attrs:
|
||||
|
@ -129,15 +85,6 @@ def getattributeOrNone(obj, self, attr):
|
|||
return None
|
||||
|
||||
|
||||
def isInt(str):
|
||||
""" Returns True if the specified string passes as an int. """
|
||||
try:
|
||||
int(str)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
def joinArgs(args):
|
||||
""" Returns a query string (uses for HTTP URLs) where only the value is URL encoded.
|
||||
Example return value: '?genre=action&type=1337'.
|
||||
|
@ -154,16 +101,6 @@ def joinArgs(args):
|
|||
return '?%s' % '&'.join(arglist)
|
||||
|
||||
|
||||
def listChoices(server, path):
|
||||
""" Returns a dict of {title:key} for all simple choices in a search filter.
|
||||
|
||||
Parameters:
|
||||
server (:class:`~plexapi.server.PlexServer`): PlexServer object this is from.
|
||||
path (str): Relative path to request XML data from.
|
||||
"""
|
||||
return {c.attrib['title']: c.attrib['key'] for c in server.query(path)}
|
||||
|
||||
|
||||
def rget(obj, attrstr, default=None, delim='.'): # pragma: no cover
|
||||
""" Returns the value at the specified attrstr location within a nexted tree of
|
||||
dicts, lists, tuples, functions, classes, etc. The lookup is done recursivley
|
||||
|
|
|
@ -24,52 +24,11 @@ def test_utils_searchType():
|
|||
utils.searchType('kekekekeke')
|
||||
|
||||
|
||||
def _test_utils_listItems():
|
||||
# TODO: Implement test_utils_listItems
|
||||
pass
|
||||
|
||||
|
||||
def _test_utils_listChoices(pms):
|
||||
# TODO: Implement test_utils_listChoices
|
||||
pass
|
||||
|
||||
|
||||
def test_utils_joinArgs():
|
||||
test_dict = {'genre': 'action', 'type': 1337}
|
||||
assert utils.joinArgs(test_dict) == '?genre=action&type=1337'
|
||||
|
||||
|
||||
def test_utils_isInt():
|
||||
assert utils.isInt(1) is True
|
||||
assert utils.isInt('got_you') is False
|
||||
assert utils.isInt('1337') is True
|
||||
|
||||
|
||||
def _test_utils_findUsername():
|
||||
# TODO: Implement test_utils_findUsername
|
||||
pass
|
||||
|
||||
|
||||
def _test_utils_findStreams():
|
||||
# TODO: Implement test_utils_findStreams
|
||||
pass
|
||||
|
||||
|
||||
def _test_utils_findPlayer():
|
||||
# TODO: Implement test_utils_findPlayer
|
||||
pass
|
||||
|
||||
|
||||
def _test_utils_findLocations():
|
||||
# TODO: Implement test_utils_findLocations
|
||||
pass
|
||||
|
||||
|
||||
def _test_utils_findItem():
|
||||
# TODO: Implement test_utils_findItem
|
||||
pass
|
||||
|
||||
|
||||
def test_utils_cast():
|
||||
t_int_int = utils.cast(int, 1)
|
||||
t_int_str_int = utils.cast(int, '1')
|
||||
|
|
Loading…
Reference in a new issue