Merge pull request 'Optionally add custom data as a string in get_license_challenge' (#3) from moszkowski/pyplayready:feature/add-custom-data into main

Reviewed-on: https://git.gay/ready-dl/pyplayready/pulls/3
This commit is contained in:
DevLARLEY 2026-01-02 23:59:37 +01:00 committed by git.gay
commit 333d185e08
No known key found for this signature in database
GPG Key ID: BDA2A7586B5E1432
2 changed files with 13 additions and 5 deletions

View File

@ -94,7 +94,8 @@ class Cdm:
self, self,
session_id: bytes, session_id: bytes,
wrm_header: Union[WRMHeader, str], wrm_header: Union[WRMHeader, str],
rev_lists: Optional[List[UUID]]=None # default: RevocationList.SupportedListIds rev_lists: Optional[List[UUID]] = None, # default: RevocationList.SupportedListIds
custom_data: Optional[str] = None
) -> str: ) -> str:
session = self.__sessions.get(session_id) session = self.__sessions.get(session_id)
if not session: if not session:
@ -126,7 +127,8 @@ class Cdm:
client_data=self._get_cipher_data(session), client_data=self._get_cipher_data(session),
signing_key=self.signing_key, signing_key=self.signing_key,
client_info=self.client_version, client_info=self.client_version,
revocation_lists=rev_lists revocation_lists=rev_lists,
custom_data=custom_data
) )
soap_message = SoapMessage.create(acquire_license_message) soap_message = SoapMessage.create(acquire_license_message)

View File

@ -71,7 +71,8 @@ class XmlBuilder:
wrmserver_data: bytes, wrmserver_data: bytes,
client_data: bytes, client_data: bytes,
client_info: Optional[str] = None, client_info: Optional[str] = None,
revocation_lists: Optional[List[UUID]] = None revocation_lists: Optional[List[UUID]] = None,
custom_data: Optional[str] = None
) -> ET.Element: ) -> ET.Element:
LA = ET.SubElement(parent, "LA", { LA = ET.SubElement(parent, "LA", {
"xmlns": "http://schemas.microsoft.com/DRM/2007/03/protocols", "xmlns": "http://schemas.microsoft.com/DRM/2007/03/protocols",
@ -91,6 +92,10 @@ class XmlBuilder:
if revocation_lists is not None: if revocation_lists is not None:
XmlBuilder._RevocationLists(LA, revocation_lists) XmlBuilder._RevocationLists(LA, revocation_lists)
if custom_data is not None:
CustomData = ET.SubElement(LA, "CustomData")
CustomData.text = html.escape(custom_data)
LicenseNonce = ET.SubElement(LA, "LicenseNonce") LicenseNonce = ET.SubElement(LA, "LicenseNonce")
LicenseNonce.text = base64.b64encode(get_random_bytes(16)).decode() LicenseNonce.text = base64.b64encode(get_random_bytes(16)).decode()
@ -161,7 +166,8 @@ class XmlBuilder:
client_data: bytes, client_data: bytes,
signing_key: ECCKey, signing_key: ECCKey,
client_info: Optional[str] = None, client_info: Optional[str] = None,
revocation_lists: Optional[List[UUID]] = None revocation_lists: Optional[List[UUID]] = None,
custom_data: Optional[str] = None
) -> ET.Element: ) -> ET.Element:
AcquireLicense = ET.Element("AcquireLicense", { AcquireLicense = ET.Element("AcquireLicense", {
"xmlns": "http://schemas.microsoft.com/DRM/2007/03/protocols" "xmlns": "http://schemas.microsoft.com/DRM/2007/03/protocols"
@ -171,7 +177,7 @@ class XmlBuilder:
"xmlns": "http://schemas.microsoft.com/DRM/2007/03/protocols/messages" "xmlns": "http://schemas.microsoft.com/DRM/2007/03/protocols/messages"
}) })
LA = XmlBuilder._LicenseAcquisition(Challenge, wrmheader, protocol_version, wrmserver_data, client_data, client_info, revocation_lists) LA = XmlBuilder._LicenseAcquisition(Challenge, wrmheader, protocol_version, wrmserver_data, client_data, client_info, revocation_lists, custom_data)
Signature = ET.SubElement(Challenge, "Signature", { Signature = ET.SubElement(Challenge, "Signature", {
"xmlns": "http://www.w3.org/2000/09/xmldsig#" "xmlns": "http://www.w3.org/2000/09/xmldsig#"