generate and use a client ID, store it for later use

This commit is contained in:
faush01
2014-10-05 16:22:07 +11:00
parent a30745078c
commit c7767766a4
2 changed files with 31 additions and 12 deletions

View File

@@ -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")

View File

@@ -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()