{"id":13907971,"url":"https://github.com/devine-dl/pywidevine","last_synced_at":"2025-07-18T06:32:11.560Z","repository":{"id":47303382,"uuid":"515993268","full_name":"devine-dl/pywidevine","owner":"devine-dl","description":"Python implementation of Google's Widevine DRM CDM (Content Decryption Module)","archived":false,"fork":false,"pushed_at":"2024-01-30T00:21:04.000Z","size":574,"stargazers_count":518,"open_issues_count":10,"forks_count":114,"subscribers_count":24,"default_branch":"master","last_synced_at":"2024-11-07T09:07:23.078Z","etag":null,"topics":["drm","google","python","widevine"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devine-dl.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-20T13:28:09.000Z","updated_at":"2024-11-06T10:58:51.000Z","dependencies_parsed_at":"2023-11-21T10:31:49.412Z","dependency_job_id":"943c06d7-830c-48a0-8111-0e4f1421bd35","html_url":"https://github.com/devine-dl/pywidevine","commit_stats":{"total_commits":255,"total_committers":4,"mean_commits":63.75,"dds":"0.019607843137254943","last_synced_commit":"7ea2a72a8c12a607f0b67fd7e53f669a41d7721e"},"previous_names":["devine-dl/pywidevine"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devine-dl%2Fpywidevine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devine-dl%2Fpywidevine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devine-dl%2Fpywidevine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devine-dl%2Fpywidevine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devine-dl","download_url":"https://codeload.github.com/devine-dl/pywidevine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226361632,"owners_count":17612932,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["drm","google","python","widevine"],"created_at":"2024-08-06T23:02:21.826Z","updated_at":"2024-11-25T16:31:17.211Z","avatar_url":"https://github.com/devine-dl.png","language":"Python","readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"docs/images/widevine_icon_24.png\"\u003e \u003ca href=\"https://github.com/devine-dl/pywidevine\"\u003epywidevine\u003c/a\u003e\n    \u003cbr/\u003e\n    \u003csup\u003e\u003cem\u003ePython Widevine CDM implementation\u003c/em\u003e\u003c/sup\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/devine-dl/pywidevine/actions/workflows/ci.yml\"\u003e\n        \u003cimg src=\"https://github.com/devine-dl/pywidevine/actions/workflows/ci.yml/badge.svg\" alt=\"Build status\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://pypi.org/project/pywidevine\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/python-3.8%2B-informational\" alt=\"Python version\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://deepsource.io/gh/devine-dl/pywidevine\"\u003e\n        \u003cimg src=\"https://deepsource.io/gh/devine-dl/pywidevine.svg/?label=active+issues\" alt=\"DeepSource\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/astral-sh/ruff\"\u003e\n        \u003cimg src=\"https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json\" alt=\"Linter: Ruff\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://python-poetry.org\"\u003e\n        \u003cimg src=\"https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json\" alt=\"Dependency management: Poetry\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n## Features\n\n- 🚀 Seamless Installation via [pip](#installation)\n- 🛡️ Robust Security with message signature verification\n- 🙈 Privacy Mode with Service Certificates\n- 🌐 Servable CDM API Server and Client with Authentication\n- 📦 Custom provision serialization format (WVD v2)\n- 🧰 Create, parse, or convert PSSH headers with ease\n- 🗃️ User-friendly YAML configuration\n- ❤️ Forever FOSS!\n\n## Installation\n\n```shell\n$ pip install pywidevine\n```\n\n\u003e **Note**\nIf pip gives you a warning about a path not being in your PATH environment variable then promptly add that path then\nclose all open command prompt/terminal windows, or `pywidevine` CLI won't work as it will not be found.\n\nVoilà 🎉 — You now have the `pywidevine` package installed!  \nYou can now import pywidevine in scripts ([see below](#usage)).  \nA command-line interface is also available, try `pywidevine --help`.\n\n## Usage\n\nThe following is a minimal example of using pywidevine in a script to get a License for Bitmovin's\nArt of Motion Demo.\n\n```py\nfrom pywidevine.cdm import Cdm\nfrom pywidevine.device import Device\nfrom pywidevine.pssh import PSSH\n\nimport requests\n\n# prepare pssh\npssh = PSSH(\"AAAAW3Bzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAADsIARIQ62dqu8s0Xpa\"\n            \"7z2FmMPGj2hoNd2lkZXZpbmVfdGVzdCIQZmtqM2xqYVNkZmFsa3IzaioCSEQyAA==\")\n\n# load device\ndevice = Device.load(\"C:/Path/To/A/Provision.wvd\")\n\n# load cdm\ncdm = Cdm.from_device(device)\n\n# open cdm session\nsession_id = cdm.open()\n\n# get license challenge\nchallenge = cdm.get_license_challenge(session_id, pssh)\n\n# send license challenge (assuming a generic license server SDK with no API front)\nlicence = requests.post(\"https://...\", data=challenge)\nlicence.raise_for_status()\n\n# parse license challenge\ncdm.parse_license(session_id, licence.content)\n\n# print keys\nfor key in cdm.get_keys(session_id):\n    print(f\"[{key.type}] {key.kid.hex}:{key.key.hex()}\")\n\n# close session, disposes of session data\ncdm.close(session_id)\n```\n\n\u003e **Note**\n\u003e There are various features not shown in this specific example like:\n\u003e\n\u003e - Privacy Mode\n\u003e - Setting Service Certificates\n\u003e - Remote CDMs and Serving\n\u003e - Choosing a License Type to request\n\u003e - Creating WVD files\n\u003e - and much more!\n\u003e\n\u003e Take a look at the methods available in the [Cdm class](/pywidevine/cdm.py) and their doc-strings for\n\u003e further information. For more examples see the [CLI functions](/pywidevine/main.py) which uses a lot\n\u003e of previously mentioned features.\n\n## Disclaimer\n\n1. This project requires a valid Google-provisioned Private Key and Client Identification blob which are not\n   provided by this project.\n2. Public test provisions are available and provided by Google to use for testing projects such as this one.\n3. License Servers have the ability to block requests from any provision, and are likely already blocking test\n   provisions on production endpoints.\n4. This project does not condone piracy or any action against the terms of the DRM systems.\n5. All efforts in this project have been the result of Reverse-Engineering, Publicly available research, and Trial\n   \u0026 Error.\n\n## Key and Output Security\n\n*Licenses, Content Keys, and Decrypted Data is not secure in this CDM implementation.*\n\nThe Content Decryption Module is meant to do all downloading, decrypting, and decoding of content, not just license\nacquisition. This Python implementation only does License Acquisition within the CDM.\n\nThe section of which a 'Decrypt Frame' call is made would be more of a 'Decrypt File' in this implementation. Just\nreturning the original file in plain text defeats the point of the DRM. Even if 'Decrypt File' was somehow secure, the\nContent Keys used to decrypt the files are already exposed to the caller anyway, allowing them to manually decrypt.\n\nAn attack on a 'Decrypt Frame' system would be analogous to doing an HDMI capture or similar attack. This is because it\nwould require re-encoding the video by splicing each individual frame with the right frame-rate, syncing to audio, and\nmore.\n\nWhile a 'Decrypt Video' system would be analogous to downloading a Video and passing it through a script. Not much of\nan attack if at all. The only protection against a system like this would be monitoring the provision and acquisitions\nof licenses and prevent them. This can be done by revoking the device provision, or the user or their authorization to\nthe service.\n\nThere isn't any immediate way to secure either Key or Decrypted information within a Python environment that is not\nHardware backed. Even if obfuscation or some other form of Security by Obscurity was used, this is a Software-based\nContent Protection Module (in Python no less) with no hardware backed security. It would be incredibly trivial to break\nany sort of protection against retrieving the original video data.\n\nThough, it's not impossible. Google's Chrome Browser CDM is a simple library extension file programmed in C++ that has\nbeen improving its security using math and obscurity for years. It's getting harder and harder to break with its latest\nversions only being beaten by Brute-force style methods. However, they have a huge team of very skilled workers, and\nmaking a CDM in C++ has immediate security benefits and a lot of methods to obscure and obfuscate the code.\n\n## Contributors\n\n\u003ca href=\"https://github.com/rlaphoenix\"\u003e\u003cimg src=\"https://images.weserv.nl/?url=avatars.githubusercontent.com/u/17136956?v=4\u0026h=25\u0026w=25\u0026fit=cover\u0026mask=circle\u0026maxage=7d\" alt=\"\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/mediaminister\"\u003e\u003cimg src=\"https://images.weserv.nl/?url=avatars.githubusercontent.com/u/45148099?v=4\u0026h=25\u0026w=25\u0026fit=cover\u0026mask=circle\u0026maxage=7d\" alt=\"\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/sr0lle\"\u003e\u003cimg src=\"https://images.weserv.nl/?url=avatars.githubusercontent.com/u/111277375?v=4\u0026h=25\u0026w=25\u0026fit=cover\u0026mask=circle\u0026maxage=7d\" alt=\"\"/\u003e\u003c/a\u003e\n\n## Licensing\n\nThis software is licensed under the terms of [GNU General Public License, Version 3.0](LICENSE).  \nYou can find a copy of the license in the LICENSE file in the root folder.\n\n- Widevine Icon \u0026copy; Google.\n- Props to the awesome community for their shared research and insight into the Widevine Protocol and Key Derivation.\n\n* * *\n\n© rlaphoenix 2022-2023\n","funding_links":[],"categories":["HarmonyOS"],"sub_categories":["Windows Manager"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevine-dl%2Fpywidevine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevine-dl%2Fpywidevine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevine-dl%2Fpywidevine/lists"}