Skip to content

Repository files navigation

streamlink-plugin-widevine

A Streamlink plugin for playing Widevine DRM-encrypted MPEG-DASH and HLS streams.

The plugin resolves Widevine PSSH data from the media manifest, obtains the required content keys from a Widevine license server, and passes those keys to third-party dashdrm / hlsdrm Streamlink plugins.

Requirements

Installation

Clone the repository and use Streamlink's plugin directory option --plugin-dir.

Alternatively, sideload widevine.py.

Usage

The plugin accepts DASH (.mpd) and HLS (.m3u8) manifests prefixed with the widevine:// scheme.

A license server URL must be provided.

The plugin also requires a Widevine device. The device can either be specified explicitly with --widevine-device or placed in Streamlink's default configuration directory.

streamlink \
    --plugin-dir /path/to/streamlink-plugin-widevine \
    --widevine-device /path/to/device.wvd \
    --widevine-license-url "https://license.example.com/..." \
    "widevine://https://example.com/manifest.mpd" \
    best

Plugin options

The plugin accepts the following parameters:

license-url

Widevine license server URL.

This parameter is required.

--widevine-license-url "https://license.example.com/..."

license-header

A header to add to the license server HTTP request, in Key=Value format.

Can be repeated to add multiple headers.

--widevine-license-header "Host=license.example.com"

license-format

The format of the license server response.

Supported values are:

  • raw (default)
  • json
--widevine-license-format json

license-path

Comma-separated path to the license message in a JSON response.

For example, if the license server returns a JSON object like this:

{
    "license": {
        "message": "BASE64_LICENSE"
    }
}
--widevine-license-format json \
--widevine-license-path "license,message"

device

Path to the Widevine device (.wvd) file.

--widevine-device /path/to/device.wvd

If this option is not specified, the plugin searches for a device in the following locations:

  1. STREAMLINK_WIDEVINE_DEVICE environment variable
  2. Streamlink's default configuration directory for a file named device.wvd

pssh

Widevine PSSH data.

Multiple PSSH strings can be supplied as a comma-separated list.

If omitted, the plugin will attempt to extract Widevine PSSH data automatically from the media manifest and, where applicable, its initialisation segments.

--widevine-pssh "BASE64_PSSH"

Multiple PSSH values:

--widevine-pssh "BASE64_PSSH_1,BASE64_PSSH_2"

Development

The repository contains compatibility code and a bundled version of pywidevine.

No changes should be made to widevine.py or pywidevine_bundled.py directly as these files are generated automatically and any changes to these will be overwritten.

Instead, make changes elsewhere and run the build script to generate the bundled implementation and the Streamlink plugin:

python tools/build.py

The generated widevine.py can then be tested with Streamlink:

streamlink \
    --plugin-dir . \
    --loglevel debug \
    --widevine-license-url "https://license.example.com/..." \
    "widevine://https://example.com/manifest.mpd" \
    best

Disclaimer

This project is intended for lawful use with content and services for which you have the necessary authorisation.

Users are responsible for complying with applicable laws, license terms, and the terms of service of the services they access.

Third-party source code

This project incorporates and modifies code from:

See LICENSE and THIRD-PARTY-NOTICES.md for licensing and attribution information.

About

A Streamlink plugin for playing Widevine DRM-encrypted MPEG-DASH and HLS streams.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages