forked from DRMTalks/devine
Add support for SegmentBase and BaseURL-only DASH Manifests
This commit is contained in:
parent
c06ea4cea8
commit
3b62b50e25
|
@ -856,8 +856,7 @@ class dl:
|
||||||
proxy=proxy,
|
proxy=proxy,
|
||||||
license_widevine=prepare_drm
|
license_widevine=prepare_drm
|
||||||
)
|
)
|
||||||
# no else-if as DASH may convert the track to URL descriptor
|
elif track.descriptor == track.Descriptor.URL:
|
||||||
if track.descriptor == track.Descriptor.URL:
|
|
||||||
try:
|
try:
|
||||||
if not track.drm and isinstance(track, (Video, Audio)):
|
if not track.drm and isinstance(track, (Video, Audio)):
|
||||||
# the service might not have explicitly defined the `drm` property
|
# the service might not have explicitly defined the `drm` property
|
||||||
|
|
|
@ -268,13 +268,10 @@ class DASH:
|
||||||
if segment_list is None:
|
if segment_list is None:
|
||||||
segment_list = adaptation_set.find("SegmentList")
|
segment_list = adaptation_set.find("SegmentList")
|
||||||
|
|
||||||
if segment_template is None and segment_list is None and rep_base_url:
|
segment_base = representation.find("SegmentBase")
|
||||||
# If there's no SegmentTemplate and no SegmentList, then SegmentBase is used or just BaseURL
|
if segment_base is None:
|
||||||
# Regardless which of the two is used, we can just directly grab the BaseURL
|
segment_base = adaptation_set.find("SegmentBase")
|
||||||
# Players would normally calculate segments via Byte-Ranges, but we don't care
|
|
||||||
track.url = rep_base_url
|
|
||||||
track.descriptor = track.Descriptor.URL
|
|
||||||
else:
|
|
||||||
segments: list[tuple[str, Optional[str]]] = []
|
segments: list[tuple[str, Optional[str]]] = []
|
||||||
track_kid: Optional[UUID] = None
|
track_kid: Optional[UUID] = None
|
||||||
|
|
||||||
|
@ -373,6 +370,33 @@ class DASH:
|
||||||
media_url,
|
media_url,
|
||||||
segment_url.get("mediaRange")
|
segment_url.get("mediaRange")
|
||||||
))
|
))
|
||||||
|
elif segment_base is not None:
|
||||||
|
media_range = None
|
||||||
|
init_data = None
|
||||||
|
initialization = segment_base.find("Initialization")
|
||||||
|
if initialization is not None:
|
||||||
|
if initialization.get("range"):
|
||||||
|
init_range_header = {"Range": f"bytes={initialization.get('range')}"}
|
||||||
|
else:
|
||||||
|
init_range_header = None
|
||||||
|
|
||||||
|
res = session.get(url=rep_base_url, headers=init_range_header)
|
||||||
|
res.raise_for_status()
|
||||||
|
init_data = res.content
|
||||||
|
track_kid = track.get_key_id(init_data)
|
||||||
|
total_size = res.headers.get("Content-Range", "").split("/")[-1]
|
||||||
|
if total_size:
|
||||||
|
media_range = f"{len(init_data)}-{total_size}"
|
||||||
|
|
||||||
|
segments.append((
|
||||||
|
rep_base_url,
|
||||||
|
media_range
|
||||||
|
))
|
||||||
|
elif rep_base_url:
|
||||||
|
segments.append((
|
||||||
|
rep_base_url,
|
||||||
|
None
|
||||||
|
))
|
||||||
else:
|
else:
|
||||||
log.error("Could not find a way to get segments from this MPD manifest.")
|
log.error("Could not find a way to get segments from this MPD manifest.")
|
||||||
log.debug(manifest_url)
|
log.debug(manifest_url)
|
||||||
|
|
Loading…
Reference in New Issue