cleanup / msl-includes
authorliberty-developer <liberty.developer@xmail.net>
Sun, 29 Jan 2017 14:38:26 +0000 (15:38 +0100)
committerliberty-developer <liberty.developer@xmail.net>
Sun, 29 Jan 2017 14:38:26 +0000 (15:38 +0100)
resources/lib/MSL.py
resources/lib/MSLHttpRequestHandler.py
resources/lib/common.py

index 58a25f552b00028ddfd3a9e6dffdea98fef0855b..83ae2e7abfe2b34cfff46f67f3fc4bc0ff4ff196 100644 (file)
@@ -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
index 4d7626b88a4c913afc9548ccb7361b0cf2a6a2af..395dd5aedd9fef1d560bf5d316d62c850fbce57b 100644 (file)
@@ -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)
index 161bcae36bda38698d6c8c9c02caaca9c79c7f5d..d1979386309f3e3ae1f626b7258b7325cfac3dfd 100644 (file)
@@ -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):