X-Git-Url: http://git.code-monkey.de/?p=plugin.video.netflix.git;a=blobdiff_plain;f=resources%2Flib%2FMSL.py;h=ef7e93be5a6c20ba6ab7ce85881eb09bfa009dc3;hp=83a06ee37b5fc0e19d625a4a50d8c61e8c4787be;hb=d778ddd025d9004124274ab28ad4bb0dfa059a7b;hpb=2b1c5fa796929d522c9b9c366d8e01423b15121c diff --git a/resources/lib/MSL.py b/resources/lib/MSL.py index 83a06ee..ef7e93b 100644 --- a/resources/lib/MSL.py +++ b/resources/lib/MSL.py @@ -10,6 +10,8 @@ import os import pprint import random from StringIO import StringIO + +from datetime import datetime import requests import zlib @@ -152,9 +154,13 @@ class MSL: # Audio 'heaac-2-dash', + + #subtiltes 'dfxp-ls-sdh', - 'simplesdh', - 'nflx-cmisc', + #'simplesdh', + #'nflx-cmisc', + + #unkown 'BIF240', 'BIF320' ], @@ -349,6 +355,21 @@ class MSL: segment_base = ET.SubElement(rep, 'SegmentBase', indexRange="0-"+str(init_length), indexRangeExact="true") ET.SubElement(segment_base, 'Initialization', range='0-'+str(init_length)) + # Multiple Adaption Sets for subtiles + for text_track in manifest['textTracks']: + if 'downloadables' not in text_track or text_track['downloadables'] is None: + continue + subtiles_adaption_set = ET.SubElement(period, 'AdaptationSet', + lang=text_track['bcp47'], + codecs='stpp', + contentType='text', + mimeType='application/ttml+xml') + for downloadable in text_track['downloadables']: + rep = ET.SubElement(subtiles_adaption_set, 'Representation', + nflxProfile=downloadable['contentProfile'] + ) + ET.SubElement(rep, 'BaseURL').text = self.__get_base_url(downloadable['urls']) + xml = ET.tostring(root, encoding='utf-8', method='xml') xml = xml.replace('\n', '').replace('\r', '') @@ -559,6 +580,18 @@ class MSL: def __load_msl_data(self): msl_data = json.JSONDecoder().decode(self.load_file(self.kodi_helper.msl_data_path, 'msl_data.json')) + #Check expire date of the token + master_token = json.JSONDecoder().decode(base64.standard_b64decode(msl_data['tokens']['mastertoken']['tokendata'])) + valid_until = datetime.utcfromtimestamp(int(master_token['expiration'])) + present = datetime.now() + difference = valid_until - present + difference = difference.total_seconds() / 60 / 60 + # If token expires in less then 10 hours or is expires renew it + if difference < 10: + self.__load_rsa_keys() + self.__perform_key_handshake() + return + self.__set_master_token(msl_data['tokens']['mastertoken']) self.encryption_key = base64.standard_b64decode(msl_data['encryption_key']) self.sign_key = base64.standard_b64decode(msl_data['sign_key'])