From e859108697429c7f3a792a5f1b9b69f805ea66f4 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Thu, 19 Mar 2015 22:50:33 +0100 Subject: [PATCH] changed some logging --- resources/lib/ClientInformation.py | 12 ++++++------ resources/lib/DownloadUtils.py | 22 +++++++++++----------- resources/lib/LibrarySync.py | 1 - resources/lib/Player.py | 3 +-- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/resources/lib/ClientInformation.py b/resources/lib/ClientInformation.py index e386d86d..2d0240e5 100644 --- a/resources/lib/ClientInformation.py +++ b/resources/lib/ClientInformation.py @@ -86,13 +86,13 @@ class ClientInformation(): if(len(clientId) == 0): uuid = uuid4() clientId = str("%012X" % uuid) - self.logMsg("ClientId saved to FILE : %s" % clientId) + self.logMsg("ClientId saved to FILE : %s" % clientId,1) os.write(fd, clientId) os.fsync(fd) os.close(fd) - self.logMsg("ClientId saved to WINDOW : %s" % clientId) + self.logMsg("ClientId saved to WINDOW : %s" % clientId,1) WINDOW.setProperty("client_id", clientId) finally: @@ -160,11 +160,11 @@ class User(ClientInformation): # Verify if userId is saved to Window if (w_userId != ""): - self.logMsg("Returning saved (WINDOW) UserId for user: %s UserId: %s" % (username, w_userId)) + self.logMsg("Returning saved (WINDOW) UserId for user: %s UserId: %s" % (username, w_userId),2) return w_userId # Verify if userId is saved in settings elif (s_userId != ""): - self.logMsg("Returning saved (SETTINGS) UserId for user: %s UserId: %s" % (username, s_userId)) + self.logMsg("Returning saved (SETTINGS) UserId for user: %s UserId: %s" % (username, s_userId),2) self.WINDOW.setProperty('userId%s' % username, s_userId) return s_userId else: @@ -178,11 +178,11 @@ class User(ClientInformation): # Verify if token is saved to Window if (w_token != ""): - self.logMsg("Returning saved (WINDOW) AccessToken for user: %s Token: %s" % (username, w_token)) + self.logMsg("Returning saved (WINDOW) AccessToken for user: %s Token: %s" % (username, w_token),2) return w_token # Verify if token is saved in settings elif (s_token != ""): - self.logMsg("Returning saved (SETTINGS) AccessToken for user: %s Token: %s" % (username, s_token)) + self.logMsg("Returning saved (SETTINGS) AccessToken for user: %s Token: %s" % (username, s_token),2) self.WINDOW.setProperty('AccessToken%s' % username, s_token) return s_token else: diff --git a/resources/lib/DownloadUtils.py b/resources/lib/DownloadUtils.py index 2d471b96..74a8e151 100644 --- a/resources/lib/DownloadUtils.py +++ b/resources/lib/DownloadUtils.py @@ -61,13 +61,13 @@ class DownloadUtils(): userid = WINDOW.getProperty("userid" + userName) if(userid != None and userid != ""): - self.logMsg("DownloadUtils -> Returning saved (WINDOW) UserID : " + userid + "UserName: " + userName) + self.logMsg("DownloadUtils -> Returning saved (WINDOW) UserID : " + userid + "UserName: " + userName,2) return userid userid = self.addonSettings.getSetting("userid" + userName) if(userid != None and userid != ""): WINDOW.setProperty("userid" + userName, userid) - self.logMsg("DownloadUtils -> Returning saved (SETTING) UserID : " + userid + "UserName: " + userName) + self.logMsg("DownloadUtils -> Returning saved (SETTING) UserID : " + userid + "UserName: " + userName,2) return userid self.logMsg("Looking for user name: " + userName) @@ -130,13 +130,13 @@ class DownloadUtils(): token = WINDOW.getProperty("AccessToken" + username) if(token != None and token != ""): - self.logMsg("DownloadUtils -> Returning saved (WINDOW) AccessToken for user:" + username + " token:" + token) + self.logMsg("DownloadUtils -> Returning saved (WINDOW) AccessToken for user:" + username + " token:" + token,2) return token token = self.addonSettings.getSetting("AccessToken" + username) if(token != None and token != ""): WINDOW.setProperty("AccessToken" + username, token) - self.logMsg("DownloadUtils -> Returning saved (SETTINGS) AccessToken for user:" + username + " token:" + token) + self.logMsg("DownloadUtils -> Returning saved (SETTINGS) AccessToken for user:" + username + " token:" + token,2) return token port = self.addonSettings.getSetting("port") @@ -234,11 +234,11 @@ class DownloadUtils(): if(authToken != ""): headers["X-MediaBrowser-Token"] = authToken - self.logMsg("Authentication Header : " + str(headers)) + self.logMsg("Authentication Header : " + str(headers),2) return headers def downloadUrl(self, url, suppress=False, postBody=None, type="GET", popup=0, authenticate=True ): - self.logMsg("== ENTER: getURL ==") + self.logMsg("== ENTER: getURL ==",2) if(authenticate == True and suppress == True): token = self.authenticate(retreive=False) @@ -267,16 +267,16 @@ class DownloadUtils(): server = url.split('/')[serversplit] urlPath = "/"+"/".join(url.split('/')[urlsplit:]) - self.logMsg("DOWNLOAD_URL = " + url) - self.logMsg("server = " + str(server)) - self.logMsg("urlPath = " + str(urlPath)) + self.logMsg("DOWNLOAD_URL = " + url,2) + self.logMsg("server = " + str(server),2) + self.logMsg("urlPath = " + str(urlPath),2) if(server[0:1] == ":" or server[-1:] == ":"): self.logMsg("No server host or port set in url") return "" head = self.getAuthHeader(authenticate) - self.logMsg("HEADERS : " + str(head), level=1) + self.logMsg("HEADERS : " + str(head), level=2) conn = httplib.HTTPConnection(server, timeout=5) @@ -284,7 +284,7 @@ class DownloadUtils(): if(postBody != None): head["Content-Type"] = "application/x-www-form-urlencoded" head["Content-Length"] = str(len(postBody)) - self.logMsg("POST DATA : " + postBody) + self.logMsg("POST DATA : " + postBody,2) conn.request(method=type, url=urlPath, body=postBody, headers=head) else: conn.request(method=type, url=urlPath, headers=head) diff --git a/resources/lib/LibrarySync.py b/resources/lib/LibrarySync.py index 8575ecb1..7345511e 100644 --- a/resources/lib/LibrarySync.py +++ b/resources/lib/LibrarySync.py @@ -386,7 +386,6 @@ class LibrarySync(): if not matchFound: #no match so we have to create it - print "episode not found...creating it: " WriteKodiDB().addEpisodeToKodiLibrary(item) updateNeeded = True diff --git a/resources/lib/Player.py b/resources/lib/Player.py index cb98ab8c..c414d55e 100644 --- a/resources/lib/Player.py +++ b/resources/lib/Player.py @@ -91,8 +91,7 @@ class Player( xbmc.Player ): type = data.get("Type") if(refresh_id != None): - #TODO: trigger update of single item, for now trigger full playcounts update - xbmc.log("Invoking refresh of playcounts") + #report updates playcount and resume status to Kodi and MB3 librarySync.updatePlayCount(item_id,type) if(currentPosition != None and self.hasData(runtime)):