Skip to content

stream.dash: various SegmentList/SegmentTemplate fixes #5247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
stream.dash: inherit SegmentList attributes
Inherit attributes from ancestor `SegmentList` nodes, if set,
similar to `SegmentTemplate`.

Also fix `presentationTimeOffset` not being inherited in
`SegmentTemplate`.

TODO: use common `MultipleSegmentBaseType` class for these attributes
  • Loading branch information
bastimeyer committed Mar 14, 2023
commit eb9779e7446ce4192d5a87f265a515b8fe306142
26 changes: 17 additions & 9 deletions src/streamlink/stream/dash_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,19 +530,27 @@ def __init__(self, *args, period: "Period", **kwargs) -> None:

self.period = period

self.presentation_time_offset = self.attr("presentationTimeOffset")
self.timescale = self.attr(
"timescale",
parser=int,
)
self.defaultSegmentList = self.walk_back_get_attr("segmentList")

self.duration = self.attr(
"duration",
parser=int,
default=self.defaultSegmentList.duration if self.defaultSegmentList else None,
)
self.timescale: int = self.attr(
"timescale",
parser=int,
default=self.defaultSegmentList.timescale if self.defaultSegmentList else 1,
)
self.start_number = self.attr(
self.startNumber: int = self.attr(
"startNumber",
parser=int,
default=1,
default=self.defaultSegmentList.startNumber if self.defaultSegmentList else 1,
)
self.presentationTimeOffset = self.attr(
"presentationTimeOffset",
parser=MPDParsers.timedelta(self.timescale),
default=self.defaultSegmentList.presentationTimeOffset if self.defaultSegmentList else timedelta(),
)

self.duration_seconds = self.duration / self.timescale if self.duration and self.timescale else None
Expand All @@ -561,7 +569,7 @@ def segments(self) -> Iterator[Segment]:
content=False,
byterange=self.initialization.range,
)
for number, segment_url in enumerate(self.segment_urls, self.start_number):
for number, segment_url in enumerate(self.segment_urls, self.startNumber):
yield Segment(
url=self.make_url(segment_url.media),
number=number,
Expand Down Expand Up @@ -682,7 +690,7 @@ def __init__(self, *args, period: "Period", **kwargs) -> None:
self.presentationTimeOffset = self.attr(
"presentationTimeOffset",
parser=MPDParsers.timedelta(self.timescale),
default=timedelta(),
default=self.defaultSegmentTemplate.presentationTimeOffset if self.defaultSegmentTemplate else timedelta(),
)

self.duration_seconds = self.duration / self.timescale if self.duration and self.timescale else None
Expand Down