14 How to add custom license scheme yourself
FoxRefire edited this page 2024-07-30 17:27:26 +09:00

Requirements

  • Basic level of network skill

  • Basic level of Python skill (Especially about Pywidevine)

Guide

1.

Check the contents of the request/response to the license server

2.

Create a python scheme file according to the reference described below.

Scheme files are located in python/schemes.

The scheme file should only describe the part that handles the license acquisition and will eventually be concatenated and executed as pre.py+SCHEME.py+after.py.

3.

Edit popup.html to allow the added scheme file to run.

4.

Edit the Config files as needed.

See Config files for more informations

5.

After you've created new license scheme, consider opening PR to improve this project!

See Contribution for more informations

References of scheme file

licUrl: License URL as string that is automatically collected by extension.

licHeaders: Headers as JSON object that is automatically collected by extension. (It is passed as a string from JS, but is automatically read as a dict in pre.py.)

licBody: Request payloads of License server as Base64 string that is automatically collected by extension. Use loadBody() API to load it in scheme file.

corsFetch(url, method, headers, body, resType): Use this function for requesting to license server.

  • PARAMS:
    • url: Specifies URL to request in string.
    • method: Specifies request method in string, "POST" is used in most cases.
    • headers: Specifies headers of request in dict or str, in most cases, specifying licHeaders as is.
    • body: Specifies requestBody of request in bytes, str, or dict, in most cases, either a licBody with a modified payload or a challenge is specified as is.
    • resType: Specifies the return type in string, accepts "blob", "str" or "json".
  • RESPONSE: Returns fetch response as bytes, str or dict depending on the argument (Asynchronous)

loadBody(loadAs): Loads requestBody into scheme from licBody variable.

  • PARAMS:
    • loadAs: Specifies the return type in string, accepts "blob", "str" or "json".
  • RESPONSE: Returns decoded body as bytes, str or dict depending on the argument

challenge: License challenge as bytes, send as is or set it to a modified body.

licence: Set the final acquired license into this variable and it will be automatically parsed by pywidevine.