From 26c305a4ecab0366fa05d1d4c3bc9ee24d170029 Mon Sep 17 00:00:00 2001 From: liberty-developer Date: Sun, 29 Jan 2017 15:38:26 +0100 Subject: [PATCH] cleanup / msl-includes --- resources/lib/MSL.py | 23 +++++++++++++++-------- resources/lib/MSLHttpRequestHandler.py | 2 +- resources/lib/common.py | 1 + 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/resources/lib/MSL.py b/resources/lib/MSL.py index 58a25f5..83ae2e7 100644 --- a/resources/lib/MSL.py +++ b/resources/lib/MSL.py @@ -18,7 +18,8 @@ from Crypto.Random import get_random_bytes # from Crypto.Hash import HMAC, SHA256 from Crypto.Util import Padding import xml.etree.ElementTree as ET -from lib import log +from common import log +from common import ADDONUSERDATA pp = pprint.PrettyPrinter(indent=4) @@ -37,7 +38,8 @@ class MSL: handshake_performed = False # Is a handshake already performed and the keys loaded last_drm_context = '' last_playback_context = '' - esn = "NFCDCH-LX-CQE0NU6PA5714R25VPLXVU2A193T36" + #esn = "NFCDCH-LX-CQE0NU6PA5714R25VPLXVU2A193T36" + esn = "WWW-BROWSE-D7GW1G4NPXGR1F0X1H3EQGY3V1F5WE" current_message_id = 0 session = requests.session() rndm = random.SystemRandom() @@ -54,6 +56,10 @@ class MSL: """ self.email = email self.password = password + try: + os.mkdir(ADDONUSERDATA) + except OSError: + pass if self.file_exists('msl_data.json'): self.__load_msl_data() @@ -190,7 +196,7 @@ class MSL: def __tranform_to_dash(self, manifest): - self.save_file('/home/johannes/manifest.json', json.dumps(manifest)) + self.save_file('manifest.json', json.dumps(manifest)) manifest = manifest['result']['viewables'][0] self.last_playback_context = manifest['playbackContextId'] @@ -227,7 +233,8 @@ class MSL: rep = ET.SubElement(video_adaption_set, 'Representation', width=str(downloadable['width']), height=str(downloadable['height']), - bitrate=str(downloadable['bitrate']*8*1024), + bandwidth=str(downloadable['bitrate']*8*1024), + codecs='h264', mimeType='video/mp4') #BaseURL @@ -247,7 +254,7 @@ class MSL: for downloadable in audio_track['downloadables']: rep = ET.SubElement(audio_adaption_set, 'Representation', codecs='aac', - bitrate=str(downloadable['bitrate'] * 8 * 1024), + bandwidth=str(downloadable['bitrate'] * 8 * 1024), mimeType='audio/mp4') #AudioChannel Config @@ -526,7 +533,7 @@ class MSL: :param filename: The filename :return: True if so """ - return os.path.isfile(filename) + return os.path.isfile(ADDONUSERDATA + filename) @staticmethod def save_file(filename, content): @@ -535,7 +542,7 @@ class MSL: :param filename: The filename :param content: The content of the file """ - with open(filename, 'w') as file_: + with open(ADDONUSERDATA + filename, 'w') as file_: file_.write(content) file_.flush() @@ -546,6 +553,6 @@ class MSL: :param filename: The file to load :return: The content of the file """ - with open(filename) as file_: + with open(ADDONUSERDATA + filename) as file_: file_content = file_.read() return file_content diff --git a/resources/lib/MSLHttpRequestHandler.py b/resources/lib/MSLHttpRequestHandler.py index 4d7626b..395dd5a 100644 --- a/resources/lib/MSLHttpRequestHandler.py +++ b/resources/lib/MSLHttpRequestHandler.py @@ -3,7 +3,7 @@ import base64 from urlparse import urlparse, parse_qs from MSL import MSL -from lib import ADDON +from common import ADDON email = ADDON.getSetting('email') password = ADDON.getSetting('password') msl = MSL(email, password) diff --git a/resources/lib/common.py b/resources/lib/common.py index 161bcae..d197938 100644 --- a/resources/lib/common.py +++ b/resources/lib/common.py @@ -9,6 +9,7 @@ ADDONVERSION = ADDON.getAddonInfo('version') ADDONNAME = ADDON.getAddonInfo('name') ADDONPATH = ADDON.getAddonInfo('path').decode('utf-8') ADDONPROFILE = xbmc.translatePath( ADDON.getAddonInfo('profile') ).decode('utf-8') +ADDONUSERDATA = xbmc.translatePath("special://profile/addon_data/service.msl").decode('utf-8') + "/" ICON = ADDON.getAddonInfo('icon') def log(txt): -- 2.30.2