From 887a7cd38fbf38bc80ce192eba5ac1ecbfbd9e23 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 27 Nov 2024 13:41:23 +0100 Subject: [PATCH] + Resolved conflicting dependencies by downgrading to construct 2.8.8 --- pyplayready/__init__.py | 2 +- pyplayready/bcert.py | 5 +++++ pyplayready/pssh.py | 6 +++--- pyplayready/xmrlicense.py | 11 ++++++----- pyproject.toml | 4 ++-- requirements.txt | 2 +- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/pyplayready/__init__.py b/pyplayready/__init__.py index aba3ffd..cd16daa 100644 --- a/pyplayready/__init__.py +++ b/pyplayready/__init__.py @@ -10,4 +10,4 @@ from .session import * from .xml_key import * from .xmrlicense import * -__version__ = "0.3.6" +__version__ = "0.3.7" diff --git a/pyplayready/bcert.py b/pyplayready/bcert.py index 95094bd..5769958 100644 --- a/pyplayready/bcert.py +++ b/pyplayready/bcert.py @@ -1,4 +1,9 @@ from __future__ import annotations +import collections.abc + +# monkey patch for construct 2.8.8 compatibility +if not hasattr(collections, 'Sequence'): + collections.Sequence = collections.abc.Sequence import base64 from pathlib import Path diff --git a/pyplayready/pssh.py b/pyplayready/pssh.py index ec3e919..01845a9 100644 --- a/pyplayready/pssh.py +++ b/pyplayready/pssh.py @@ -2,7 +2,7 @@ import base64 from typing import Union from uuid import UUID -from construct import Struct, Int32ul, Int16ul, Array, this, Bytes, PaddedString, Switch, Int32ub, Const, Container +from construct import Struct, Int32ul, Int16ul, Array, this, Bytes, Switch, Int32ub, Const, Container from pyplayready.wrmheader import WRMHeader @@ -23,7 +23,7 @@ class _PlayreadyPSSHStructs: "data" / Switch( this.type, { - 1: PaddedString(this.length, "utf16") + 1: Bytes(this.length * 2) }, default=Bytes(this.length) ) @@ -96,4 +96,4 @@ class PSSH: def _read_wrm_headers(wrm_header: Container): for record in wrm_header.records: if record.type == 1: - yield record.data + yield record.data.decode("utf-16-le") diff --git a/pyplayready/xmrlicense.py b/pyplayready/xmrlicense.py index fd54125..8c352ae 100644 --- a/pyplayready/xmrlicense.py +++ b/pyplayready/xmrlicense.py @@ -4,7 +4,8 @@ import base64 from pathlib import Path from typing import Union -from construct import Const, GreedyRange, Struct, Int32ub, Bytes, Int16ub, this, Switch, LazyBound, Array, Container +from construct import Const, GreedyRange, Struct, Int32ub, Bytes, Int16ub, this, Switch, LazyBound, Array, Container, \ + If, Byte class _XMRLicenseStructs: @@ -151,12 +152,12 @@ class _XMRLicenseStructs: "minimum_move_protection_level" / Int32ub ) - XMRObject = Struct( + XmrObject = Struct( "flags" / Int16ub, "type" / Int16ub, "length" / Int32ub, "data" / Switch( - lambda this_: this_.type, + lambda ctx: ctx.type, { 0x0005: OutputProtectionLevelRestrictionObject, 0x0008: AnalogVideoOutputConfigurationRestriction, @@ -187,7 +188,7 @@ class _XMRLicenseStructs: 0x005a: SecureStopRestrictionObject, 0x0059: DigitalVideoOutputRestrictionObject }, - default=LazyBound(lambda: _XMRLicenseStructs.XMRObject) + default=LazyBound(lambda ctx: _XMRLicenseStructs.XmrObject) ) ) @@ -195,7 +196,7 @@ class _XMRLicenseStructs: "signature" / Const(b"XMR\x00"), "xmr_version" / Int32ub, "rights_id" / Bytes(16), - "containers" / GreedyRange(XMRObject) + "containers" / GreedyRange(XmrObject) ) diff --git a/pyproject.toml b/pyproject.toml index 2938eed..5908160 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "pyplayready" -version = "0.3.6" +version = "0.3.7" description = "pyplayready CDM (Content Decryption Module) implementation in Python." license = "CC BY-NC-ND 4.0" authors = ["DevLARLEY, Erevoc", "DevataDev"] @@ -33,7 +33,7 @@ include = [ python = ">=3.8,<4.0" requests = "^2.32.3" pycryptodome = "^3.21.0" -construct = "^2.10.70" +construct = "2.8.8" ECPy = "^1.2.5" click = "^8.1.7" xmltodict = "^0.14.2" diff --git a/requirements.txt b/requirements.txt index 57d9df2..c543673 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ requests pycryptodome ecpy -construct +construct==2.8.8 click PyYAML aiohttp