Skip to content

Commit 624c3f8

Browse files
authored
Merge pull request #778 from pkkid/account_roles
Fix for accessing Account of non Plex Pass account
2 parents ca06ca6 + 54ce61b commit 624c3f8

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

plexapi/base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,12 @@ def firstAttr(self, *attrs):
295295
if value is not None:
296296
return value
297297

298-
def listAttrs(self, data, attr, **kwargs):
298+
def listAttrs(self, data, attr, rtag=None, **kwargs):
299299
""" Return a list of values from matching attribute. """
300300
results = []
301+
# rtag to iter on a specific root tag
302+
if rtag:
303+
data = next(data.iter(rtag), [])
301304
for elem in data:
302305
kwargs['%s__exists' % attr] = True
303306
if self._checkAttrs(elem, **kwargs):

plexapi/myplex.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,9 @@ def _loadData(self, data):
135135
self.subscriptionPlan = subscription.attrib.get('plan')
136136
self.subscriptionFeatures = self.listAttrs(subscription, 'id', etag='feature')
137137

138-
roles = data.find('roles')
139-
self.roles = self.listAttrs(roles, 'id', etag='role')
138+
self.roles = self.listAttrs(data, 'id', rtag='roles', etag='role')
140139

141-
entitlements = data.find('entitlements')
142-
self.entitlements = self.listAttrs(entitlements, 'id', etag='entitlement')
140+
self.entitlements = self.listAttrs(data, 'id', rtag='entitlements', etag='entitlement')
143141

144142
# TODO: Fetch missing MyPlexAccount attributes
145143
self.profile_settings = None

0 commit comments

Comments
 (0)