mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-02 05:55:08 +00:00
refactor(tracks): make complete_track the one finish step for every track kind
This commit is contained in:
@@ -4,7 +4,9 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from collections.abc import Callable
|
||||
from enum import Enum
|
||||
from functools import partial
|
||||
from http.cookiejar import CookieJar
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Any, NamedTuple, Protocol
|
||||
@@ -249,11 +251,15 @@ class TitleSource(metaclass=ABCMeta):
|
||||
def get_sample_decrypter(self, track: AnyTrack, entry: int) -> bytes | SampleDecrypter:
|
||||
"""The content key, or a `cbcs.SampleDecrypter`, for `stsd` entry `entry` (1-based) of `track`.
|
||||
|
||||
unshackle calls this only for a track `decrypts_samples` names. A remote session runs it on the
|
||||
server, so a decrypter that needs a local process works for remote clients too.
|
||||
unshackle calls this only for a track `decrypts_samples` names, before TRACK_DOWNLOADED. A remote session
|
||||
runs it on the server, so a decrypter that needs a local process works for remote clients too.
|
||||
"""
|
||||
raise NotImplementedError(f"{self.__class__.__name__} does not decrypt samples")
|
||||
|
||||
def sample_decrypter(self, track: AnyTrack) -> Callable[[int], bytes | SampleDecrypter] | None:
|
||||
"""`get_sample_decrypter` for `track`, when `decrypts_samples` names it."""
|
||||
return partial(self.get_sample_decrypter, track) if self.decrypts_samples(track) else None
|
||||
|
||||
# Optional Event methods
|
||||
|
||||
def on_segment_downloaded(self, track: AnyTrack, segment: Path) -> None:
|
||||
@@ -267,20 +273,20 @@ class TitleSource(metaclass=ABCMeta):
|
||||
|
||||
def on_track_downloaded(self, track: AnyTrack) -> None:
|
||||
"""
|
||||
Called once when a Track has finished downloading, after unshackle decrypted its `drm`.
|
||||
Called once when a Track has finished downloading, after unshackle decrypted it.
|
||||
In a licence-only run the track has no file.
|
||||
|
||||
Parameters:
|
||||
track: The downloaded Track object.
|
||||
"""
|
||||
|
||||
def on_track_decrypted(self, track: AnyTrack, drm: DRM_T, segment: m3u8.Segment | None = None) -> None:
|
||||
def on_track_decrypted(self, track: AnyTrack, drm: DRM_T | None, segment: m3u8.Segment | None = None) -> None:
|
||||
"""
|
||||
Called when a Track has finished decrypting.
|
||||
|
||||
Parameters:
|
||||
track: The decrypted Track object.
|
||||
drm: The DRM object it decrypted with.
|
||||
drm: The DRM object it decrypted with. None for a track `get_sample_decrypter` decrypted.
|
||||
segment: The decrypted HLS segment information. None for DASH and ISM tracks and
|
||||
for an HLS track that merged during the download (merge_segments).
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user