Store DRM in the track.drm property in HLS and DASH

This commit is contained in:
rlaphoenix 2023-03-04 11:49:53 +00:00
parent f8166f098c
commit 318832e6b2
2 changed files with 3 additions and 1 deletions

View File

@ -302,6 +302,7 @@ class DASH:
adaptation_set.findall("ContentProtection") adaptation_set.findall("ContentProtection")
) )
if drm: if drm:
track.drm = drm
drm = drm[0] # just use the first supported DRM system for now drm = drm[0] # just use the first supported DRM system for now
if isinstance(drm, Widevine): if isinstance(drm, Widevine):
# license and grab content keys # license and grab content keys
@ -336,7 +337,6 @@ class DASH:
# Players would normally calculate segments via Byte-Ranges, but we don't care # Players would normally calculate segments via Byte-Ranges, but we don't care
track.url = urljoin(period_base_url, base_url) track.url = urljoin(period_base_url, base_url)
track.descriptor = track.Descriptor.URL track.descriptor = track.Descriptor.URL
track.drm = [drm] if drm else []
else: else:
segments: list[tuple[str, Optional[str]]] = [] segments: list[tuple[str, Optional[str]]] = []
@ -442,6 +442,7 @@ class DASH:
# it might not have Widevine DRM, or might not have found the PSSH # it might not have Widevine DRM, or might not have found the PSSH
log.warning("No Widevine PSSH was found for this track, is it DRM free?") log.warning("No Widevine PSSH was found for this track, is it DRM free?")
else: else:
track.drm = [drm]
# license and grab content keys # license and grab content keys
if not license_widevine: if not license_widevine:
raise ValueError("license_widevine func must be supplied to use Widevine DRM") raise ValueError("license_widevine func must be supplied to use Widevine DRM")

View File

@ -242,6 +242,7 @@ class HLS:
sys.exit(1) sys.exit(1)
else: else:
if drm: if drm:
track.drm = drm
drm = drm[0] # just use the first supported DRM system for now drm = drm[0] # just use the first supported DRM system for now
log.debug("Got segment key, %s", drm) log.debug("Got segment key, %s", drm)
if isinstance(drm, Widevine): if isinstance(drm, Widevine):