Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f09a06857a | ||
|
|
e4f6a23725 | ||
|
|
f21a21712b | ||
|
|
a1494a3742 | ||
|
|
5b13e1a689 |
15
CHANGELOG.md
15
CHANGELOG.md
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [1.3.1] - 2022-08-04
|
||||
|
||||
### Added
|
||||
|
||||
- Cdm and RemoteCdm can now be supplied a string value for `device_type` for scenarios where providing it as a string
|
||||
is more convenient (e.g., from Config files).
|
||||
|
||||
### Fixed
|
||||
|
||||
- The `force_privacy_mode` key no longer needs to be defined at all in the configuration file. This was previously
|
||||
crashing serve APIs if it wasn't set before starting.
|
||||
- RemoteCdm's Server version check will no longer fail under certain serving conditions e.g., Caddy prepending `Caddy`
|
||||
to the Server header value. It also fixes case sensitivity and removed the full url from the header.
|
||||
|
||||
## [1.3.0] - 2022-08-04
|
||||
|
||||
### Added
|
||||
@@ -165,6 +179,7 @@ This release is primarily a maintenance release for `serve` functionality but so
|
||||
|
||||
Initial Release.
|
||||
|
||||
[1.3.1]: https://github.com/rlaphoenix/pywidevine/releases/tag/v1.3.1
|
||||
[1.3.0]: https://github.com/rlaphoenix/pywidevine/releases/tag/v1.3.0
|
||||
[1.2.1]: https://github.com/rlaphoenix/pywidevine/releases/tag/v1.2.1
|
||||
[1.2.0]: https://github.com/rlaphoenix/pywidevine/releases/tag/v1.2.0
|
||||
|
||||
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.poetry]
|
||||
name = "pywidevine"
|
||||
version = "1.3.0"
|
||||
version = "1.3.1"
|
||||
description = "Widevine CDM (Content Decryption Module) implementation in Python."
|
||||
authors = ["rlaphoenix <rlaphoenix@pm.me>"]
|
||||
license = "GPL-3.0-only"
|
||||
|
||||
@@ -1 +1 @@
|
||||
__version__ = "1.3.0"
|
||||
__version__ = "1.3.1"
|
||||
|
||||
@@ -66,7 +66,7 @@ class Cdm:
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
device_type: Device.Types,
|
||||
device_type: Union[Device.Types, str],
|
||||
system_id: int,
|
||||
security_level: int,
|
||||
client_id: ClientIdentification,
|
||||
@@ -75,6 +75,8 @@ class Cdm:
|
||||
"""Initialize a Widevine Content Decryption Module (CDM)."""
|
||||
if not device_type:
|
||||
raise ValueError("Device Type must be provided")
|
||||
if isinstance(device_type, str):
|
||||
device_type = Device.Types[device_type]
|
||||
if not isinstance(device_type, Device.Types):
|
||||
raise TypeError(f"Expected device_type to be a {Device.Types!r} not {device_type!r}")
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import binascii
|
||||
import re
|
||||
from typing import Union, Optional
|
||||
|
||||
import requests
|
||||
@@ -24,7 +25,7 @@ class RemoteCdm(Cdm):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
device_type: Device.Types,
|
||||
device_type: Union[Device.Types, str],
|
||||
system_id: int,
|
||||
security_level: int,
|
||||
host: str,
|
||||
@@ -34,6 +35,8 @@ class RemoteCdm(Cdm):
|
||||
"""Initialize a Widevine Content Decryption Module (CDM)."""
|
||||
if not device_type:
|
||||
raise ValueError("Device Type must be provided")
|
||||
if isinstance(device_type, str):
|
||||
device_type = Device.Types[device_type]
|
||||
if not isinstance(device_type, Device.Types):
|
||||
raise TypeError(f"Expected device_type to be a {Device.Types!r} not {device_type!r}")
|
||||
|
||||
@@ -80,9 +83,12 @@ class RemoteCdm(Cdm):
|
||||
if r.status_code != 200:
|
||||
raise ValueError(f"Could not test Remote API version [{r.status_code}]")
|
||||
server = r.headers.get("Server")
|
||||
if not server or not server.startswith("https://github.com/rlaphoenix/pywidevine serve"):
|
||||
if not server or "pywidevine serve" not in server.lower():
|
||||
raise ValueError(f"This Remote CDM API does not seem to be a pywidevine serve API ({server}).")
|
||||
server_version = server.split("v")[-1]
|
||||
server_version = re.search(r"pywidevine serve v([\d.]+)", server, re.IGNORECASE)
|
||||
if not server_version:
|
||||
raise ValueError(f"The pywidevine server API is not stating the version correctly, cannot continue.")
|
||||
server_version = server_version.group(1)
|
||||
if server_version < "1.3.0":
|
||||
raise ValueError(f"This pywidevine serve API version ({server_version}) is not supported.")
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ async def challenge(request: web.Request) -> web.Response:
|
||||
}, status=400)
|
||||
|
||||
# enforce service certificate (opt-in)
|
||||
if request.app["config"]["force_privacy_mode"] and not cdm._sessions[session_id].service_certificate:
|
||||
if request.app["config"].get("force_privacy_mode") and not cdm._sessions[session_id].service_certificate:
|
||||
return web.json_response({
|
||||
"status": 403,
|
||||
"message": "No Service Certificate set but Privacy Mode is Enforced."
|
||||
|
||||
Reference in New Issue
Block a user