From 833716299178a887b898b472fb80e5c073b2b497 Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Wed, 8 Mar 2023 21:34:08 +0000 Subject: [PATCH] Prepare DRM on URL tracks if they already have DRM Previously it would only prepare the DRM, if it had to find DRM from the init data. Now it prepares DRM if already pre-provided with DRM objects. --- devine/commands/dl.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/devine/commands/dl.py b/devine/commands/dl.py index 258f48e..bf0719e 100644 --- a/devine/commands/dl.py +++ b/devine/commands/dl.py @@ -790,13 +790,20 @@ class dl: # the service might not have explicitly defined the `drm` property # try find widevine DRM information from the init data of URL try: - drm = Widevine.from_track(track, service.session) + track.drm = [Widevine.from_track(track, service.session)] except Widevine.Exceptions.PSSHNotFound: # it might not have Widevine DRM, or might not have found the PSSH self.log.warning("No Widevine PSSH was found for this track, is it DRM free?") - else: - track.drm = [drm] + + if track.drm: + drm = track.drm[0] # just use the first supported DRM system for now + if isinstance(drm, Widevine): + # license and grab content keys + if not prepare_drm: + raise ValueError("prepare_drm func must be supplied to use Widevine DRM") prepare_drm(drm) + else: + drm = None asyncio.run(aria2c( uri=track.url, @@ -808,8 +815,7 @@ class dl: track.path = save_path - if track.drm: - drm = track.drm[0] # just use the first supported DRM system for now + if drm: drm.decrypt(save_path) track.drm = None if callable(track.OnDecrypted):