diff --git a/README.md b/README.md index 2ffb383..7cdcfba 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,59 @@ See [Poetry's Docs] on various ways of making calls under the virtual-environmen [Poetry]: [Poetry's Docs]: +## Usage + +The following is a minimal example of using pywidevine in a script. It gets a License for Bitmovin's +Art of Motion Demo. There's various stuff not shown in this specific example like: + +- Privacy Mode +- Setting Service Certificates +- Remote CDMs and Serving +- Choosing a License Type to request +- Creating WVD files +- and much more! + +Just take a look around the Cdm code to see what stuff does. Everything is documented quite well. +There's also various functions in `main.py` that showcases a lot of features. + +```py +from pywidevine.cdm import Cdm +from pywidevine.device import Device +from pywidevine.pssh import PSSH + +import requests + +# prepare pssh +pssh = PSSH("AAAAW3Bzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAADsIARIQ62dqu8s0Xpa" + "7z2FmMPGj2hoNd2lkZXZpbmVfdGVzdCIQZmtqM2xqYVNkZmFsa3IzaioCSEQyAA==") + +# load device +device = Device.load("C:/Path/To/A/Provision.wvd") + +# 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) + +# send license challenge (assuming a generic license server SDK with no API front) +licence = requests.post("https://...", data=challenge) +licence.raise_for_status() + +# parse license challenge +cdm.parse_license(session_id, licence.content) + +# print keys +for key in cdm.get_keys(session_id): + print(f"[{key.type}] {key.kid.hex}:{key.key.hex()}") + +# close session, disposes of session data +cdm.close(session_id) +``` + ## Troubleshooting ### Executable `pywidevine` was not found