用于与netflix msl api交互的python库
pymsl的Python项目详细描述
Pymsl
用于与Netflix MSL API交互的Python库
用法
基本用法
>>>importpymsl>>>user_auth_data={...'scheme':'EMAIL_PASSWORD',...'authdata':{...'email':email,...'password':password...}...}>>>client=pymsl.MslClient(user_auth_data)>>>client.load_manifest(80092521){'version':2,...
所有用户身份验证方案都在msl wiki中定义:https://github.com/Netflix/msl/wiki/User-Authentication-(Configuration)
自定义Kwargs
pymsl.MslClient()
需要额外的kwarg来覆盖默认值;初始化所需的唯一参数是用户身份验证数据:
>>>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
是用于与msl通信的标识。不同的esn有不同的特权。drm_system
将确定您将在清单中接收哪种初始化数据。profiles
是一个配置文件列表,用于告诉msl您希望在清单中接收什么。keypair
是在初始密钥交换中使用的rsa密钥对。message_id
是用于标识msl客户端会话的随机整数。languages
是用于确定所接收清单的语言的列表。proxies
是传递给requests库的代理dict。key_request_data
是一个dict,通过它来覆盖普通的ASYMMETRIC_WRAPPED
密钥请求dict,以便启用其他密钥交换机制。请注意,您可能需要对parse_handshake
函数进行monkey补丁,以便它与指定的密钥交换机制一起工作。extra_manifest_params
是额外清单参数的dict。以下是在清单请求中发送的默认清单参数:
'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}
通过使用这个Kwarg,您可以向这个参数dict添加任何您想要的值。例如,如果您想要showAllSubDubTracks
为真,您可以将extra_manifest_params
设置为{'showAllSubDubTracks': True}
。manifest param dict只是用extra_manifest_params
来.update()
,因此您可以覆盖默认值或添加新值。
方法
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.
安装
要安装,您可以克隆存储库并运行python setup.py install
,也可以运行pip install pymsl
待办事项
- [X]实施许可证获取
- []清除分块负载分析