wvg/python/pre.py

49 lines
1.5 KiB
Python
Raw Normal View History

2024-04-18 20:48:32 +00:00
from pywidevine.cdm import Cdm
2024-04-22 12:05:09 +00:00
from pywidevine.device import Device, DeviceTypes
2024-04-18 20:48:32 +00:00
from pywidevine.pssh import PSSH
import json
2024-05-01 21:37:00 +00:00
import js
import base64
2024-04-18 20:48:32 +00:00
from pyodide.http import pyfetch
# prepare pssh
pssh = PSSH(pssh)
# load device
2024-04-22 12:05:09 +00:00
try:
2024-04-27 21:15:48 +00:00
wvd = await (await pyfetch("device.wvd")).bytes()
device = Device.loads(wvd)
2024-04-22 12:05:09 +00:00
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()
2024-04-30 18:23:08 +00:00
2024-04-22 12:05:09 +00:00
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()
2024-04-30 18:23:08 +00:00
2024-04-22 12:05:09 +00:00
except OSError:
2024-05-01 21:37:00 +00:00
js.document.getElementById('result').value="n0suchd3v1c3f113:r3adth3fuck1ngma2ua1\n\n[MPD?]\nhttps://github.com/FoxRefire/wvg?tab=readme-ov-file#instalation"
2024-04-22 12:05:09 +00:00
raise FileNotFoundError("CDM Keys not found!, RTFM!")
2024-04-30 18:51:00 +00:00
device = Device(client_id=cID,
private_key=pKey,
type_=DeviceTypes['ANDROID'],
security_level=3,
flags=None)
2024-04-18 20:48:32 +00:00
# load cdm
cdm = Cdm.from_device(device)
# open cdm session
session_id = cdm.open()
# get license challenge
challenge = cdm.get_license_challenge(session_id, pssh)
licHeaders=json.loads(licHeaders)