forked from kenzuya/unshackle
feat(cdm): add per-track quality-based CDM selection during runtime DRM switching
Enable quality-based CDM selection during runtime DRM switching by passing track quality to get_cdm() calls. This allows different CDMs to be used for different video quality levels within the same download session.
Example configuration:
cdm:
SERVICE:
"<=1080": wv_l3_local # Widevine L3 for SD/HD
">1080": pr_sl3_remote # PlayReady SL3 for 4K
This commit is contained in:
@@ -1847,15 +1847,19 @@ class dl:
|
|||||||
if not drm:
|
if not drm:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
track_quality = None
|
||||||
if isinstance(track, Video) and track.height:
|
if isinstance(track, Video) and track.height:
|
||||||
pass
|
track_quality = track.height
|
||||||
|
|
||||||
if isinstance(drm, Widevine):
|
if isinstance(drm, Widevine):
|
||||||
if not isinstance(self.cdm, (WidevineCdm, DecryptLabsRemoteCDM)) or (
|
if not isinstance(self.cdm, (WidevineCdm, DecryptLabsRemoteCDM)) or (
|
||||||
isinstance(self.cdm, DecryptLabsRemoteCDM) and self.cdm.is_playready
|
isinstance(self.cdm, DecryptLabsRemoteCDM) and self.cdm.is_playready
|
||||||
):
|
):
|
||||||
widevine_cdm = self.get_cdm(self.service, self.profile, drm="widevine")
|
widevine_cdm = self.get_cdm(self.service, self.profile, drm="widevine", quality=track_quality)
|
||||||
if widevine_cdm:
|
if widevine_cdm:
|
||||||
|
if track_quality:
|
||||||
|
self.log.info(f"Switching to Widevine CDM for Widevine {track_quality}p content")
|
||||||
|
else:
|
||||||
self.log.info("Switching to Widevine CDM for Widevine content")
|
self.log.info("Switching to Widevine CDM for Widevine content")
|
||||||
self.cdm = widevine_cdm
|
self.cdm = widevine_cdm
|
||||||
|
|
||||||
@@ -1863,8 +1867,11 @@ class dl:
|
|||||||
if not isinstance(self.cdm, (PlayReadyCdm, DecryptLabsRemoteCDM)) or (
|
if not isinstance(self.cdm, (PlayReadyCdm, DecryptLabsRemoteCDM)) or (
|
||||||
isinstance(self.cdm, DecryptLabsRemoteCDM) and not self.cdm.is_playready
|
isinstance(self.cdm, DecryptLabsRemoteCDM) and not self.cdm.is_playready
|
||||||
):
|
):
|
||||||
playready_cdm = self.get_cdm(self.service, self.profile, drm="playready")
|
playready_cdm = self.get_cdm(self.service, self.profile, drm="playready", quality=track_quality)
|
||||||
if playready_cdm:
|
if playready_cdm:
|
||||||
|
if track_quality:
|
||||||
|
self.log.info(f"Switching to PlayReady CDM for PlayReady {track_quality}p content")
|
||||||
|
else:
|
||||||
self.log.info("Switching to PlayReady CDM for PlayReady content")
|
self.log.info("Switching to PlayReady CDM for PlayReady content")
|
||||||
self.cdm = playready_cdm
|
self.cdm = playready_cdm
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user