forked from kenzuya/unshackle
H.266 is remuxed to Matroska with FFmpeg 8+ before mkvmerge, named H.266 and selectable with -v h266; MP4Box names TS inputs correctly, TS track files keep .ts, and core no longer runs an Audio Vivid decoder.
60 lines
1.9 KiB
Python
60 lines
1.9 KiB
Python
from threading import Event
|
|
from typing import TYPE_CHECKING, TypeVar, Union
|
|
|
|
if TYPE_CHECKING:
|
|
from unshackle.core.tracks import Audio, Subtitle, Track, Video
|
|
|
|
DOWNLOAD_CANCELLED = Event()
|
|
DOWNLOAD_LICENCE_ONLY = Event()
|
|
|
|
DEFAULT_SAMPLE = (120, 180)
|
|
DOWNLOAD_ALL_DRM = Event()
|
|
|
|
|
|
class DownloadCancelled(Exception):
|
|
"""A track stopped because ``DOWNLOAD_CANCELLED`` was set, not because it itself failed.
|
|
|
|
The downloader raises this instead of returning short. A short return sends the track on
|
|
to its merge or decrypt step, which then fails on the segments the cancel left behind.
|
|
That fault hides the sibling failure that is the real error.
|
|
"""
|
|
|
|
|
|
DRM_SORT_MAP = ["ClearKey", "Widevine"]
|
|
LANGUAGE_MAX_DISTANCE = 5 # this is max to be considered "same", e.g., en, en-US, en-AU
|
|
LANGUAGE_EXACT_DISTANCE = 0 # exact match only, no variants
|
|
VIDEO_CODEC_MAP = {"AVC": "H.264", "HEVC": "H.265", "VVC": "H.266"}
|
|
DYNAMIC_RANGE_MAP = {
|
|
"HDR10": "HDR",
|
|
"HDR10+": "HDR10P",
|
|
"Dolby Vision": "DV",
|
|
"HDR10 / HDR10+": "HDR10P",
|
|
"HDR10 / HDR10": "HDR",
|
|
"HDR Vivid": "HDRVivid",
|
|
}
|
|
AUDIO_CODEC_MAP = {
|
|
"E-AC-3": "DDP",
|
|
"DD+": "DDP", # Audio.Codec.EC3's value, which the REST API names a track by
|
|
"AC-3": "DD",
|
|
"DTS-UHD": "DTS-X",
|
|
"DTS LBR": "DTS-LBR",
|
|
"MPEG-H 3D Audio": "MPEG-H",
|
|
"MPEG Audio Layer 3": "MP3",
|
|
}
|
|
|
|
SPACED_AUDIO_CODECS = {"DTS-X"}
|
|
|
|
context_settings = dict(
|
|
help_option_names=["-?", "-h", "--help"], # default only has --help
|
|
max_content_width=116, # max PEP8 line-width, -4 to adjust for initial indent
|
|
)
|
|
|
|
# For use in signatures of functions which take one specific type of track at a time
|
|
# (it can't be a list that contains e.g. both Video and Audio objects)
|
|
TrackT = TypeVar("TrackT", bound="Track")
|
|
|
|
# For general use in lists that can contain mixed types of tracks.
|
|
# list[Track] won't work because list is invariant.
|
|
# TODO: Add Chapter?
|
|
AnyTrack = Union["Video", "Audio", "Subtitle"]
|