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.title = data.attrib.get('title')
|
||||||
self.username = data.attrib.get('username')
|
self.username = data.attrib.get('username')
|
||||||
self.uuid = data.attrib.get('uuid')
|
self.uuid = data.attrib.get('uuid')
|
||||||
subscription = data.find('subscription')
|
|
||||||
|
|
||||||
|
subscription = data.find('subscription')
|
||||||
self.subscriptionActive = utils.cast(bool, subscription.attrib.get('active'))
|
self.subscriptionActive = utils.cast(bool, subscription.attrib.get('active'))
|
||||||
self.subscriptionStatus = subscription.attrib.get('status')
|
self.subscriptionStatus = subscription.attrib.get('status')
|
||||||
self.subscriptionPlan = subscription.attrib.get('plan')
|
self.subscriptionPlan = subscription.attrib.get('plan')
|
||||||
|
self.subscriptionFeatures = self.listAttrs(subscription, 'id', etag='feature')
|
||||||
self.subscriptionFeatures = []
|
|
||||||
for feature in subscription.iter('feature'):
|
|
||||||
self.subscriptionFeatures.append(feature.attrib.get('id'))
|
|
||||||
|
|
||||||
roles = data.find('roles')
|
roles = data.find('roles')
|
||||||
self.roles = []
|
self.roles = self.listAttrs(roles, 'id', etag='role')
|
||||||
if roles is not None:
|
|
||||||
for role in roles.iter('role'):
|
|
||||||
self.roles.append(role.attrib.get('id'))
|
|
||||||
|
|
||||||
entitlements = data.find('entitlements')
|
entitlements = data.find('entitlements')
|
||||||
self.entitlements = []
|
self.entitlements = self.listAttrs(entitlements, 'id', etag='entitlement')
|
||||||
for entitlement in entitlements.iter('entitlement'):
|
|
||||||
self.entitlements.append(entitlement.attrib.get('id'))
|
|
||||||
|
|
||||||
# TODO: Fetch missing MyPlexAccount attributes
|
# TODO: Fetch missing MyPlexAccount attributes
|
||||||
self.profile_settings = None
|
self.profile_settings = None
|
||||||
|
@ -1070,7 +1062,7 @@ class MyPlexDevice(PlexObject):
|
||||||
self.screenDensity = data.attrib.get('screenDensity')
|
self.screenDensity = data.attrib.get('screenDensity')
|
||||||
self.createdAt = utils.toDatetime(data.attrib.get('createdAt'))
|
self.createdAt = utils.toDatetime(data.attrib.get('createdAt'))
|
||||||
self.lastSeenAt = utils.toDatetime(data.attrib.get('lastSeenAt'))
|
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):
|
def connect(self, timeout=None):
|
||||||
""" Returns a new :class:`~plexapi.client.PlexClient` or :class:`~plexapi.server.PlexServer`
|
""" Returns a new :class:`~plexapi.client.PlexClient` or :class:`~plexapi.server.PlexServer`
|
||||||
|
|
Loading…
Reference in a new issue