Skip to content

How to add custom license scheme yourself

FoxRefire edited this page Oct 14, 2024 · 16 revisions

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 likes pre.py + SCHEME.py + after.py.

3.

Edit popup/main.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.)

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

  • PARAMS:
    • loadAs: Specifies the return type in string, accepts "blob", "str" or "json".
  • RESPONSE: Returns loaded body as user specified format

getChallenge(getAs, *cert): Gets license challenge as format specified in argument, it can also specify a service certificate optionally.

  • PARAMS:
    • getAs: Specifies the return type in string, accepts "blob", "b64" or "list".
    • cert(optional): Specifies the service certificate of license server
  • RESPONSE: Returns generated challenge as user specified format

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)

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