Skip to content

Commit

Permalink
Pass timespec all the way down in dumps
Browse files Browse the repository at this point in the history
  • Loading branch information
daveisfera committed Nov 16, 2023
1 parent 9be37de commit b6b1b1a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions m3u8/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def add_segment(self, segment):
def add_rendition_report(self, report):
self.rendition_reports.append(report)

def dumps(self):
def dumps(self, timespec="milliseconds"):
"""
Returns the current m3u8 as a string.
You could also use unicode(<this obj>) or str(<this obj>)
Expand Down Expand Up @@ -416,7 +416,7 @@ def dumps(self):
for key in self.session_keys:
output.append(str(key))

output.append(str(self.segments))
output.append(self.segments.dumps(timespec))

if self.preload_hint:
output.append(str(self.preload_hint))
Expand Down Expand Up @@ -702,14 +702,17 @@ def base_uri(self, newbase_uri):


class SegmentList(list, GroupedBasePathMixin):
def __str__(self):
def dumps(self, timespec="milliseconds"):
output = []
last_segment = None
for segment in self:
output.append(segment.dumps(last_segment))
output.append(segment.dumps(last_segment, timespec))
last_segment = segment
return "\n".join(output)

def __str__(self):
return self.dumps()

@property
def uri(self):
return [seg.uri for seg in self]
Expand Down

0 comments on commit b6b1b1a

Please sign in to comment.