mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-03-12 09:29:02 +00:00
Compare commits
3 Commits
6975f4f9f4
...
a7a8c882d8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7a8c882d8 | ||
|
|
7cc4af207e | ||
|
|
492134b8ff |
@@ -1454,6 +1454,7 @@ class dl:
|
||||
)
|
||||
):
|
||||
download.result()
|
||||
|
||||
except KeyboardInterrupt:
|
||||
console.print(Padding(":x: Download Cancelled...", (0, 5, 1, 5)))
|
||||
if self.debug_logger:
|
||||
@@ -2028,12 +2029,21 @@ class dl:
|
||||
if export:
|
||||
keys = {}
|
||||
if export.is_file():
|
||||
keys = jsonpickle.loads(export.read_text(encoding="utf8"))
|
||||
keys = jsonpickle.loads(export.read_text(encoding="utf8")) or {}
|
||||
if str(title) not in keys:
|
||||
keys[str(title)] = {}
|
||||
if str(track) not in keys[str(title)]:
|
||||
keys[str(title)][str(track)] = {}
|
||||
keys[str(title)][str(track)].update(drm.content_keys)
|
||||
|
||||
track_data = keys[str(title)][str(track)]
|
||||
track_data["url"] = track.url
|
||||
track_data["descriptor"] = track.descriptor.name
|
||||
|
||||
if "keys" not in track_data:
|
||||
track_data["keys"] = {}
|
||||
for kid, key in drm.content_keys.items():
|
||||
track_data["keys"][kid.hex] = key
|
||||
|
||||
export.write_text(jsonpickle.dumps(keys, indent=4), encoding="utf8")
|
||||
|
||||
elif isinstance(drm, PlayReady):
|
||||
@@ -2173,12 +2183,21 @@ class dl:
|
||||
if export:
|
||||
keys = {}
|
||||
if export.is_file():
|
||||
keys = jsonpickle.loads(export.read_text(encoding="utf8"))
|
||||
keys = jsonpickle.loads(export.read_text(encoding="utf8")) or {}
|
||||
if str(title) not in keys:
|
||||
keys[str(title)] = {}
|
||||
if str(track) not in keys[str(title)]:
|
||||
keys[str(title)][str(track)] = {}
|
||||
keys[str(title)][str(track)].update(drm.content_keys)
|
||||
|
||||
track_data = keys[str(title)][str(track)]
|
||||
track_data["url"] = track.url
|
||||
track_data["descriptor"] = track.descriptor.name
|
||||
|
||||
if "keys" not in track_data:
|
||||
track_data["keys"] = {}
|
||||
for kid, key in drm.content_keys.items():
|
||||
track_data["keys"][kid.hex] = key
|
||||
|
||||
export.write_text(jsonpickle.dumps(keys, indent=4), encoding="utf8")
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -313,7 +313,7 @@ class HLS:
|
||||
|
||||
if segment.byterange:
|
||||
byte_range = HLS.calculate_byte_range(segment.byterange, range_offset)
|
||||
range_offset = byte_range.split("-")[0]
|
||||
range_offset = int(byte_range.split("-")[0])
|
||||
else:
|
||||
byte_range = None
|
||||
|
||||
|
||||
@@ -99,24 +99,42 @@ class Video(Track):
|
||||
@staticmethod
|
||||
def from_cicp(primaries: int, transfer: int, matrix: int) -> Video.Range:
|
||||
"""
|
||||
ISO/IEC 23001-8 Coding-independent code points to Video Range.
|
||||
Convert CICP (Coding-Independent Code Points) values to Video Range.
|
||||
|
||||
CICP is defined in ITU-T H.273 and ISO/IEC 23091-2 for signaling video
|
||||
color properties independently of the compression codec. These values are
|
||||
used across AVC (H.264), HEVC (H.265), VVC, AV1, and other modern codecs.
|
||||
|
||||
The enum values (Primaries, Transfer, Matrix) match the official specifications:
|
||||
- ITU-T H.273: Coding-independent code points for video signal type identification
|
||||
- ISO/IEC 23091-2: Information technology — Coding-independent code points — Part 2: Video
|
||||
- H.264 Table E-3 (Colour Primaries) and Table E-4 (Transfer Characteristics)
|
||||
- H.265 Table E.3 and E.4 (identical to H.264)
|
||||
|
||||
Note: Value 0 = "Reserved" and Value 2 = "Unspecified" per specification.
|
||||
While both effectively mean "unknown" in practice, the distinction matters for
|
||||
spec compliance. Value 2 was added based on user feedback (GitHub issue) and
|
||||
verified against FFmpeg's AVColorPrimaries/AVColorTransferCharacteristic enums.
|
||||
|
||||
Sources:
|
||||
https://www.itu.int/rec/T-REC-H.Sup19-202104-I
|
||||
- https://www.itu.int/rec/T-REC-H.273
|
||||
- https://www.itu.int/rec/T-REC-H.Sup19-202104-I
|
||||
- https://github.com/FFmpeg/FFmpeg/blob/master/libavutil/pixfmt.h
|
||||
"""
|
||||
|
||||
class Primaries(Enum):
|
||||
Unspecified = 0
|
||||
Reserved = 0
|
||||
BT_709 = 1
|
||||
Unspecified = 2
|
||||
BT_601_625 = 5
|
||||
BT_601_525 = 6
|
||||
BT_2020_and_2100 = 9
|
||||
SMPTE_ST_2113_and_EG_4321 = 12 # P3D65
|
||||
|
||||
class Transfer(Enum):
|
||||
Unspecified = 0
|
||||
Reserved = 0
|
||||
BT_709 = 1
|
||||
Unspecified_Image = 2
|
||||
Unspecified = 2
|
||||
BT_601 = 6
|
||||
BT_2020 = 14
|
||||
BT_2100 = 15
|
||||
@@ -143,7 +161,7 @@ class Video(Track):
|
||||
|
||||
# primaries and matrix does not strictly correlate to a range
|
||||
|
||||
if (primaries, transfer, matrix) == (0, 0, 0):
|
||||
if (primaries, transfer, matrix) == (Primaries.Reserved, Transfer.Reserved, Matrix.RGB):
|
||||
return Video.Range.SDR
|
||||
elif primaries in (Primaries.BT_601_625, Primaries.BT_601_525):
|
||||
return Video.Range.SDR
|
||||
|
||||
Reference in New Issue
Block a user