Skip to content

Commit

Permalink
Added default values to mpd parser
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbee committed Mar 11, 2019
1 parent 1f72160 commit 29714a9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/dash_tools/mpdparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ def get_text_attribute(self, name):
value = self.node.attrib.get(name, None)
self.__dict__[name] = value

def get_int_attribute(self, name):
def get_int_attribute(self, name, default_value=None):
"Get int attribute to __dict__."
self.attribs.append(name)
value = self.node.attrib.get(name, None)
if value is not None:
value = int(value)
else:
value = default_value
self.__dict__[name] = value

def get_date_attribute(self, name):
Expand Down Expand Up @@ -153,7 +155,8 @@ class SegmentTemplate(MpdObject):

def parse(self):
self.get_int_attribute('duration')
self.get_int_attribute('startNumber')
self.get_int_attribute('timescale', 1)
self.get_int_attribute('startNumber', 1)
self.get_text_attribute('media')
self.get_text_attribute('initialization')

Expand Down

0 comments on commit 29714a9

Please sign in to comment.