Skip to content

stream.dash: refactor parser and use base classes #5248

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 3 commits into from
Mar 16, 2023

Conversation

bastimeyer
Copy link
Member

Follow-up of #5247 / 456dd53

Refactor `walk_back()`:
- compare ancestor nodes by type and not by tag name
- rename mapper parameter and check its result before yielding the node

Refactor `walk_back_get_attr()`:
- allow finding attributes from specific ancestor nodes only
- stop iterating after the first match

Refactor `attr(inherited=...)`:
- allow inheriting from ancestor nodes, optionally from a specific type,
  and not just the parent node
- Make `AdaptationSet` and `Representation` inherit from the common
  `_RepresentationBaseType` class
- Move and logically group class definitions
- Define common attributes in `_RepresentationBaseType` that get
  inherited from ancestor nodes of the same base type, and find
  common child nodes
- Fix, clean up, reorder and selectively add attributes
  - Remove `Representation.numChannels` (invalid and unused)
  - Turn `Representation.lang` into a property which reads its value
    from the parent `AdaptationSet.lang`
    (it's not an attribute on `Representation` according to the spec,
    but it gets read by `DASHStream.parse_manifest`, so keep the alias)
  - Rename `contentProtection` attribute to `contentProtections`
    and `subRepresentation` to `subRepresentations`, to stay consistent
    with other attributes of child node lists
- Fix tests with old assertions: non-inhertied attributes that led to
  different expectations (e.g. the resulting stream name)
- Make `SegmentBase`, `SegmentList` and `SegmentTemplate` inherit from
  the common `_SegmentBaseType` and `_MultipleSegmentBaseType` classes
- Logically move class definitions
- Define common attributes in `_{,Multiple}SegmentBaseType`
  that get inherited from nodes of the same type in ancestor nodes,
  and find common child nodes
- Find inherited attributes independently
- Fix, clean up, reorder and selectively add attributes
  - Add `_SegmentBaseType.availabilityTimeOffset` (currently unused)
- Fix `MPD.minBufferTime` type (required attribute which can't be None)
@gravyboat gravyboat merged commit 17493ba into streamlink:master Mar 16, 2023
@bastimeyer bastimeyer deleted the stream/dash/base-classes branch March 16, 2023 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants