mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-22 11:43:13 +00:00
Refactor usage of listAttrs
This commit is contained in:
parent
3fc69a3709
commit
f81456d3b6
1 changed files with 5 additions and 13 deletions
|
@ -128,26 +128,18 @@ class MyPlexAccount(PlexObject):
|
|||
self.title = data.attrib.get('title')
|
||||
self.username = data.attrib.get('username')
|
||||
self.uuid = data.attrib.get('uuid')
|
||||
subscription = data.find('subscription')
|
||||
|
||||
subscription = data.find('subscription')
|
||||
self.subscriptionActive = utils.cast(bool, subscription.attrib.get('active'))
|
||||
self.subscriptionStatus = subscription.attrib.get('status')
|
||||
self.subscriptionPlan = subscription.attrib.get('plan')
|
||||
|
||||
self.subscriptionFeatures = []
|
||||
for feature in subscription.iter('feature'):
|
||||
self.subscriptionFeatures.append(feature.attrib.get('id'))
|
||||
self.subscriptionFeatures = self.listAttrs(subscription, 'id', etag='feature')
|
||||
|
||||
roles = data.find('roles')
|
||||
self.roles = []
|
||||
if roles is not None:
|
||||
for role in roles.iter('role'):
|
||||
self.roles.append(role.attrib.get('id'))
|
||||
self.roles = self.listAttrs(roles, 'id', etag='role')
|
||||
|
||||
entitlements = data.find('entitlements')
|
||||
self.entitlements = []
|
||||
for entitlement in entitlements.iter('entitlement'):
|
||||
self.entitlements.append(entitlement.attrib.get('id'))
|
||||
self.entitlements = self.listAttrs(entitlements, 'id', etag='entitlement')
|
||||
|
||||
# TODO: Fetch missing MyPlexAccount attributes
|
||||
self.profile_settings = None
|
||||
|
@ -1070,7 +1062,7 @@ class MyPlexDevice(PlexObject):
|
|||
self.screenDensity = data.attrib.get('screenDensity')
|
||||
self.createdAt = utils.toDatetime(data.attrib.get('createdAt'))
|
||||
self.lastSeenAt = utils.toDatetime(data.attrib.get('lastSeenAt'))
|
||||
self.connections = [connection.attrib.get('uri') for connection in data.iter('Connection')]
|
||||
self.connections = self.listAttrs(data, 'uri', etag='Connection')
|
||||
|
||||
def connect(self, timeout=None):
|
||||
""" Returns a new :class:`~plexapi.client.PlexClient` or :class:`~plexapi.server.PlexServer`
|
||||
|
|
Loading…
Reference in a new issue