Merge pull request #1642 from croneter/py3-fix-typeerror

Direct Paths: Fix TypeError: "element indices must be integers" on playback startup
This commit is contained in:
croneter 2021-09-30 14:57:02 +02:00 committed by GitHub
commit 5f0a256a16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -260,13 +260,21 @@ class Base(object):
Returns the media streams directly from the PMS xml. Returns the media streams directly from the PMS xml.
Mind to set self.mediastream and self.part before calling this method! Mind to set self.mediastream and self.part before calling this method!
""" """
return self.xml[self.mediastream][self.part] try:
return self.xml[self.mediastream][self.part]
except TypeError:
# Direct Paths when we don't set mediastream and part
return self.xml[0][0]
def part_id(self): def part_id(self):
""" """
Returns the unique id of the currently active part [int] Returns the unique id of the currently active part [int]
""" """
return int(self.xml[self.mediastream][self.part].attrib['id']) try:
return int(self.xml[self.mediastream][self.part].attrib['id'])
except TypeError:
# Direct Paths when we don't set mediastream and part
return int(self.xml[0][0].attrib['id'])
def plot(self): def plot(self):
""" """