Support more CDM types

This commit is contained in:
FoxRefire 2024-04-22 21:05:09 +09:00
parent f6011f1ff5
commit 907093defc
2 changed files with 42 additions and 6 deletions

View File

@ -8,7 +8,14 @@ Looking for legacy version?: https://github.com/FoxRefire/wvg/tree/legacy
### Instalation
1. Donwload or clone this code
2. At the same directory of `manifest.json`(root directory of this extension), put the device file named `device.wvd`
2. At the same directory of `manifest.json`(root directory of this extension), put the one of the following Android L3 CDM file(s).
* Supported CDM Types
1\. `device.wvd`
2\. `device_client_id_blob` + `device_private_key`
3\. `client_id.bin` + `private_key.pem`
3. Install extension
* Firefox
@ -36,6 +43,11 @@ Looking for legacy version?: https://github.com/FoxRefire/wvg/tree/legacy
### Todo
* Improve UI
* Localization
* JSON rules for License URL and scheme selection
For contributors, see here:
https://github.com/FoxRefire/wvg/blob/next/CONTRIBUTION.md
### Disclaimer

View File

@ -1,5 +1,5 @@
from pywidevine.cdm import Cdm
from pywidevine.device import Device
from pywidevine.device import Device, DeviceTypes
from pywidevine.pssh import PSSH
import json
@ -9,10 +9,34 @@ from pyodide.http import pyfetch
pssh = PSSH(pssh)
# load device
try:
with open('device.wvd', 'wb') as f:
wvdExt=await (await pyfetch("device.wvd")).bytes()
f.write(wvdExt)
device = Device.load("device.wvd")
except OSError:
try:
print("device.wvd not found! looking for device_client_id_blob and device_private_key...")
cID=await (await pyfetch("device_client_id_blob")).bytes()
pKey=await (await pyfetch("device_private_key")).bytes()
device = Device(client_id=cID,
private_key=pKey,
type_=DeviceTypes['ANDROID'],
security_level=3,
flags=None)
except OSError:
try:
print("device_client_id_blob and device_private_key not found! looking for client_id.bin and private_key.pem...")
cID=await (await pyfetch("client_id.bin")).bytes()
pKey=await (await pyfetch("private_key.pem")).bytes()
device = Device(client_id=cID,
private_key=pKey,
type_=DeviceTypes['ANDROID'],
security_level=3,
flags=None)
except OSError:
raise FileNotFoundError("CDM Keys not found!, RTFM!")
# load cdm
cdm = Cdm.from_device(device)