Skip to main content

pymsl

Build Status License: GPL v3

Python library for interacting with the Netflix MSL API

Usage

Basic Usage

>>> import pymsl
>>> user_auth_data = {
...     'scheme': 'EMAIL_PASSWORD',
...     'authdata': {
...         'email': email,
...         'password': password
...     }
... }
>>> client = pymsl.MslClient(user_auth_data)
>>> client.load_manifest(80092521)
{'version': 2, ...

All user authentication schemes are defined in the MSL wiki: https://github.com/Netflix/msl/wiki/User-Authentication-(Configuration)

Custom Kwargs

pymsl.MslClient() takes additional kwargs as well to override the defaults; the only required arg for initialization is user_auth_data:

>>> pymsl.MslClient(
...     user_auth_data,
...     esn=CUSTOM_ESN, # default is NFCDCH-02-[random device ID]
...     drm_system=CUSTOM_DRM_SYSTEM, # default is 'widevine', you can use 'playready', 'fps', etc.
...     profiles=LIST_OF_PROFILES, # default is ['playready-h264mpl30-dash', 'playready-h264mpl31-dash', 'playready-h264mpl40-dash', 'heaac-2-dash', 'simplesdh', 'nflx-cmisc', 'BIF240', 'BIF320']
...     keypair=CUSTOM_CRYPTODOME_RSA_KEYPAIR, # default is a random 2048-bit keypair
...     message_id=CUSTOM_MESSAGE_ID, # default is a random integer between 0 and 2^52
...     languages=LIST_OF_LANGUAGES, # default is ['en_US']
...     proxies=PROXIES, # default is None
...     key_request_data=CUSTOM_KEY_REQUEST_DATA, # default is ASYMMETRIC_WRAPPED
...     extra_manifest_params=EXTRA_MANIFEST_PARAMS # default is a blank dict
... )
  • esn is the identity used for communicating with MSL. Different ESNs have different priveleges.
  • drm_system will determine what kind of initialization data you will receive in the manifest.
  • profiles is a list of profiles used for telling MSL what you want to receive in the manifest.
  • keypair is the RSA keypair used in the initial key exchange.
  • message_id is a random integer used for identifying the MSL client session.
  • languages is a list of languages used for determining the language of the manifest received.
  • proxies is a proxy dict passed the same way you would pass it to the requests library.
  • key_request_data is a dict passed to override the normal ASYMMETRIC_WRAPPED key request dict in order to enable using other key exchange mechanisms. Note that you may have to monkey patch the parse_handshake function in order for it to work with your specified key exchange mechanism.
  • extra_manifest_params is a dict of extra manifest params. Here's the default manifest params sent in a manifest request:
'params': {
    'type': 'standard',
    'viewableId': viewable_id,
    'profiles': self.msl_session['profiles'],
    'flavor': 'STANDARD',
    'drmType': self.msl_session['drm_system'],
    'drmVersion': 25,
    'usePsshBox': True,
    'isBranching': False,
    'useHttpsStreams': True,
    'imageSubtitleHeight': 720,
    'uiVersion': 'shakti-v4bf615c3',
    'clientVersion': '6.0011.511.011',
    'supportsPreReleasePin': True,
    'supportsWatermark': True,
    'showAllSubDubTracks': False,
    'videoOutputInfo': [
        {
            'type': 'DigitalVideoOutputDescriptor',
            'outputType': 'unknown',
            'supportedHdcpVersions': [],
            'isHdcpEngaged': False
        }
    ],
    'preferAssistiveAudio': False,
    'isNonMember': False
}

By using this kwarg you can add any values you want to this param dict. For example, if you wanted showAllSubDubTracks to be true, you would set extra_manifest_params to {'showAllSubDubTracks': True}. The manifest param dict is simply .update()'ed with extra_manifest_params, so you can overwrite default values or add new ones.

Methods

load_manifest(viewable_id)

@param viewable_ids: Int of viewable ID
                     to obtain manifest for

@return: manifest (dict)

This function performs a manifest request based on
the parameters supplied when initalizing the client
object. If there are no errors, it will return the
manifest as a dict. If there are errors, it will
raise a ManifestError exception with the response
from the MSL API as the body.

get_license(challenge, session_id)

@param challenge:  EME license request as a byte string
                   that will be used to obtain a license

@param session_id: DRM specific session ID passed as a string

@return: license (dict)

This function performs a license request based on
the parameters supplied when initalizing the client
object. If there are no errors, it will return the
licenses as a list of dicts. If there are errors, it will
raise a LicenseError exception with the response
from the MSL API as the body.

Installation

To install, you can either clone the repository and run python setup.py install or you can run pip install pymsl

To-Do

  • Implement license acquisition
  • Clean up chunked payload parsing

Release files for pymsl 1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymsl 1.3
File Size Uploaded
pymsl-1.3.tar.gz 8.1 kB Details

Release files / pymsl-1.3.tar.gz

Download URL pymsl-1.3.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5d96c9845a816af2c4463f2b8312b7deeac96d1d4b7f44beade3b2eef35fe1bf
BLAKE2b-256 checksum
How to use checksums
9a142cca96d73eadf9c310eb031d2f3f8db4ac9a66e4781cc23520ee574394d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release history Release notifications | RSS feed

This release

1.3 This release

1 release file

1.2

2 release files

1.1

1 release file

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page