diff --git a/resources/lib/ClientInformation.py b/resources/lib/ClientInformation.py index ea595b1..cf9719d 100644 --- a/resources/lib/ClientInformation.py +++ b/resources/lib/ClientInformation.py @@ -1,10 +1,33 @@ -from uuid import getnode as get_mac +from uuid import uuid4 as uuid4 import xbmcaddon +import xbmc +import xbmcgui class ClientInformation(): def getMachineId(self): - return "%012X"%get_mac() + + WINDOW = xbmcgui.Window( 10000 ) + + clientId = WINDOW.getProperty("client_id") + + if(clientId == None or clientId == ""): + xbmc.log("CLIENT_ID - > No Client ID in WINDOW") + addonSettings = xbmcaddon.Addon(id='plugin.video.mbcon') + clientId = addonSettings.getSetting("client_id") + + if(clientId == None or clientId == ""): + xbmc.log("CLIENT_ID - > No Client ID in SETTINGS") + uuid = uuid4() + clientId = "%012X" % uuid + WINDOW.setProperty("client_id", clientId) + addonSettings.setSetting("client_id",clientId) + xbmc.log("CLIENT_ID - > New Client ID : " + clientId) + else: + WINDOW.setProperty("client_id", clientId) + xbmc.log("CLIENT_ID - > Client ID saved to WINDOW from Settings : " + clientId) + + return clientId def getVersion(self): version = xbmcaddon.Addon(id="plugin.video.mbcon").getAddonInfo("version") diff --git a/resources/lib/DownloadUtils.py b/resources/lib/DownloadUtils.py index 209976b..82ae797 100644 --- a/resources/lib/DownloadUtils.py +++ b/resources/lib/DownloadUtils.py @@ -9,10 +9,7 @@ import hashlib import StringIO import gzip import sys -#import inspect import json as json -#from random import randrange -from uuid import getnode as get_mac from ClientInformation import ClientInformation class DownloadUtils(): @@ -33,9 +30,6 @@ class DownloadUtils(): if(self.logLevel >= level): xbmc.log("MBCon DownloadUtils -> " + msg) - def getMachineId(self): - return "%012X"%get_mac() - def getArtwork(self, data, type, index = "0"): id = data.get("Id") @@ -170,8 +164,9 @@ class DownloadUtils(): url = "http://" + self.addonSettings.getSetting("ipaddress") + ":" + self.addonSettings.getSetting("port") + "/mediabrowser/Users/AuthenticateByName?format=json" - txt_mac = self.getMachineId() - version = ClientInformation().getVersion() + clientInfo = ClientInformation() + txt_mac = clientInfo.getMachineId() + version = clientInfo.getVersion() deviceName = self.addonSettings.getSetting('deviceName') deviceName = deviceName.replace("\"", "_") @@ -196,8 +191,9 @@ class DownloadUtils(): return "" def getAuthHeader(self): - txt_mac = self.getMachineId() - version = ClientInformation().getVersion() + clientInfo = ClientInformation() + txt_mac = clientInfo.getMachineId() + version = clientInfo.getVersion() userid = self.getUserId()