Pass DRM and Segment objects to Track OnDecrypted event

This commit is contained in:
rlaphoenix 2024-02-10 17:48:26 +00:00
parent 439e376b38
commit c18fe5706b
4 changed files with 6 additions and 5 deletions

View File

@ -899,7 +899,7 @@ class dl:
drm.decrypt(save_path) drm.decrypt(save_path)
track.drm = None track.drm = None
if callable(track.OnDecrypted): if callable(track.OnDecrypted):
track.OnDecrypted() track.OnDecrypted(drm)
progress(downloaded="Decrypted", completed=100) progress(downloaded="Decrypted", completed=100)
if isinstance(track, Subtitle): if isinstance(track, Subtitle):

View File

@ -507,7 +507,7 @@ class DASH:
drm.decrypt(save_path) drm.decrypt(save_path)
track.drm = None track.drm = None
if callable(track.OnDecrypted): if callable(track.OnDecrypted):
track.OnDecrypted() track.OnDecrypted(drm)
progress(downloaded="Decrypted", completed=100) progress(downloaded="Decrypted", completed=100)
track.path = save_path track.path = save_path

View File

@ -511,7 +511,7 @@ class HLS:
newest_segment_key[0].decrypt(out_path) newest_segment_key[0].decrypt(out_path)
track.drm = None track.drm = None
if callable(track.OnDecrypted): if callable(track.OnDecrypted):
track.OnDecrypted() track.OnDecrypted(newest_segment_key[0], segment)
return download_size return download_size

View File

@ -7,6 +7,7 @@ from pathlib import Path
from typing import Any, Callable, Iterable, Optional, Union from typing import Any, Callable, Iterable, Optional, Union
from uuid import UUID from uuid import UUID
import m3u8
import requests import requests
from langcodes import Language from langcodes import Language
@ -57,8 +58,8 @@ class Track:
# TODO: This should realistically be before decryption # TODO: This should realistically be before decryption
# Called after the Track has been fully downloaded and decrypted # Called after the Track has been fully downloaded and decrypted
self.OnDownloaded: Optional[Callable] = None self.OnDownloaded: Optional[Callable] = None
# Called after the Track or a Segment has been decrypted # Called after the Track or one of its segments have been decrypted
self.OnDecrypted: Optional[Callable] = None self.OnDecrypted: Optional[Callable[[DRM_T, Optional[m3u8.Segment]], None]] = None
# Called after the Track has been repackaged # Called after the Track has been repackaged
self.OnRepacked: Optional[Callable] = None self.OnRepacked: Optional[Callable] = None
# Called before the Track is multiplexed # Called before the Track is multiplexed