From 7678e0cfef7b288c268b95eaf4506c75f02b6643 Mon Sep 17 00:00:00 2001 From: blacktwin Date: Mon, 14 Jun 2021 00:57:07 -0400 Subject: [PATCH 1/2] add iter on a specific root tag in listAttrs --- plexapi/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plexapi/base.py b/plexapi/base.py index 0a653ac3c..2f836db37 100644 --- a/plexapi/base.py +++ b/plexapi/base.py @@ -295,9 +295,12 @@ def firstAttr(self, *attrs): if value is not None: return value - def listAttrs(self, data, attr, **kwargs): + def listAttrs(self, data, attr, rtag=None, **kwargs): """ Return a list of values from matching attribute. """ results = [] + # rtag to iter on a specific root tag + if rtag: + data = next(data.iter(rtag), []) for elem in data: kwargs['%s__exists' % attr] = True if self._checkAttrs(elem, **kwargs): From 54ce61b00667832a4db53dccbb7ca4daa1e37e1a Mon Sep 17 00:00:00 2001 From: blacktwin Date: Mon, 14 Jun 2021 00:58:13 -0400 Subject: [PATCH 2/2] use rtag for roles and entitlements --- plexapi/myplex.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plexapi/myplex.py b/plexapi/myplex.py index 55227948d..fe856f345 100644 --- a/plexapi/myplex.py +++ b/plexapi/myplex.py @@ -135,11 +135,9 @@ def _loadData(self, data): self.subscriptionPlan = subscription.attrib.get('plan') self.subscriptionFeatures = self.listAttrs(subscription, 'id', etag='feature') - roles = data.find('roles') - self.roles = self.listAttrs(roles, 'id', etag='role') + self.roles = self.listAttrs(data, 'id', rtag='roles', etag='role') - entitlements = data.find('entitlements') - self.entitlements = self.listAttrs(entitlements, 'id', etag='entitlement') + self.entitlements = self.listAttrs(data, 'id', rtag='entitlements', etag='entitlement') # TODO: Fetch missing MyPlexAccount attributes self.profile_settings = None