From c6917f5bd3f3725dc7005530ed356f15f8114498 Mon Sep 17 00:00:00 2001
From: faush01 <shaun@bluebit.com.au>
Date: Wed, 18 Mar 2015 14:18:30 +1100
Subject: [PATCH] allow play count updates to be pushed to the server even if
 sync is running

---
 resources/lib/CreateFiles.py |  2 +-
 resources/lib/KodiMonitor.py | 28 ++++++++++++++++------------
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/resources/lib/CreateFiles.py b/resources/lib/CreateFiles.py
index b478dc27..24a20188 100644
--- a/resources/lib/CreateFiles.py
+++ b/resources/lib/CreateFiles.py
@@ -91,7 +91,7 @@ class CreateFiles():
         changes = False
         if not xbmcvfs.exists(nfoFile):
             changes = True
-            utils.logMsg("MB3 Syncer","creating NFO file " + nfoFile)
+            #utils.logMsg("MB3 Syncer","creating NFO file " + nfoFile)
             xbmcvfs.mkdir(itemPath)        
             root = Element(rootelement)
             SubElement(root, "id").text = item["Id"]
diff --git a/resources/lib/KodiMonitor.py b/resources/lib/KodiMonitor.py
index fb826ead..a0fcdc4b 100644
--- a/resources/lib/KodiMonitor.py
+++ b/resources/lib/KodiMonitor.py
@@ -23,16 +23,20 @@ class Kodi_Monitor(xbmc.Monitor):
         if method == "VideoLibrary.OnUpdate":
             
             #check windowprop if the sync is busy to prevent any false updates
-            WINDOW = xbmcgui.Window( 10000 )
-            if WINDOW.getProperty("librarysync") != "busy":
-                xbmc.log("Kodi_Monitor -> onNotification -> VideoLibrary.OnUpdate : " + str(data))
-                jsondata = json.loads(data)
-                if jsondata != None:
-                    playcount = None
-                    playcount = jsondata.get("playcount")
-                    item = jsondata.get("item").get("id")
-                    type = jsondata.get("item").get("type")
-                    
-                    if playcount != None:
-                        WriteKodiDB().updatePlayCountFromKodi(item, type, playcount)
+            #WINDOW = xbmcgui.Window( 10000 )
+            #if WINDOW.getProperty("librarysync") != "busy":
+            # I don't thing we need this, the playcount is not present in updates that don't touch that
+            # and when the playcount is updated byt he sync it just sends the same data back to the server
+            # if you add this back in you will never be able to trigger a play status update while the sync is running
+            
+            xbmc.log("Kodi_Monitor -> onNotification -> VideoLibrary.OnUpdate : " + str(data))
+            jsondata = json.loads(data)
+            if jsondata != None:
+                playcount = None
+                playcount = jsondata.get("playcount")
+                item = jsondata.get("item").get("id")
+                type = jsondata.get("item").get("type")
+                
+                if playcount != None:
+                    WriteKodiDB().updatePlayCountFromKodi(item, type, playcount)