See details

- Only sync at startup
- Allow websocket to delete episodes
- NoneType fix
This commit is contained in:
xnappo 2015-04-11 10:53:17 -05:00
parent 0d616fef94
commit 478470607c
4 changed files with 29 additions and 29 deletions

View file

@ -846,7 +846,7 @@ class LibrarySync():
timeInfo = API().getTimeInfo(episode)
WINDOW.setProperty("EmbyUserKey" + userData.get("Key"), episode.get('Id') + ";;" + episode.get("Type"))
WINDOW.setProperty(episode.get('Id'), "episode;;" + str(kodishow["tvshowid"]) + ";;" +str(kodiItem['episodeid']))
if kodiItem != None:
WINDOW = xbmcgui.Window( 10000 )
WINDOW.setProperty("episodeid" + str(kodiItem['episodeid']), episode.get('Name') + ";;" + episode.get('Id'))

View file

@ -17,6 +17,7 @@ from ClientInformation import ClientInformation
from DownloadUtils import DownloadUtils
from PlaybackUtils import PlaybackUtils
from LibrarySync import LibrarySync
from WriteKodiDB import WriteKodiDB
import Utils as utils
_MODE_BASICPLAY=12
@ -203,7 +204,13 @@ class WebSocketThread(threading.Thread):
# doing items removed
itemsRemoved = data.get("ItemsRemoved")
self.logMsg("Message : Doing LibraryChanged : Items Removed : " + str(itemsRemoved), 0)
itemsRemoved = data.get("ItemsRemoved")
for item in itemsRemoved:
WINDOW = xbmcgui.Window( 10000 )
itemInfo=WINDOW.getProperty(item)
if "episode" in itemInfo:
type, tvshowid, episodeid = WINDOW.getProperty(item).split(";;")
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.RemoveEpisode", "params": { "episodeid": %i}, "id": 1 }' %int(episodeid))
# doing adds and updates
itemsAdded = data.get("ItemsAdded")
self.logMsg("Message : Doing LibraryChanged : Items Added : " + str(itemsAdded), 0)

View file

@ -922,8 +922,12 @@ class WriteKodiDB():
#get the showid
cursor.execute("SELECT idShow as showid FROM tvshow WHERE c12 = ?",(MBitem["SeriesId"],))
try:
showid = cursor.fetchone()[0]
except:
utils.logMsg("Emby","Error adding episode to Kodi Library, couldn't find show - ID: " + MBitem["Id"] + " - " + MBitem["Name"])
actionPerformed = False
return
season = 0
if MBitem.get("ParentIndexNumber") != None:
season = int(MBitem.get("ParentIndexNumber"))

View file

@ -53,11 +53,12 @@ class Service():
lastProgressUpdate = datetime.today()
interval_FullSync = 600
interval_IncrementalSync = 300
startupComplete = False
#interval_FullSync = 600
#interval_IncrementalSync = 300
cur_seconds_fullsync = interval_FullSync
cur_seconds_incrsync = interval_IncrementalSync
#cur_seconds_fullsync = interval_FullSync
#cur_seconds_incrsync = interval_IncrementalSync
user = UserClient()
player = Player()
@ -109,29 +110,17 @@ class Service():
ws.start()
#full sync
if(cur_seconds_fullsync >= interval_FullSync):
if(startupComplete == False):
xbmc.log("Doing_Db_Sync: syncDatabase (Started)")
worked = librarySync.syncDatabase()
xbmc.log("Doing_Db_Sync: syncDatabase (Finished) " + str(worked))
if(worked):
cur_seconds_fullsync = 0
else:
cur_seconds_fullsync = interval_FullSync - 10
else:
cur_seconds_fullsync += 1
libSync = librarySync.syncDatabase()
xbmc.log("Doing_Db_Sync: syncDatabase (Finished) " + str(libSync))
countSync = librarySync.updatePlayCounts()
xbmc.log("Doing_Db_Sync: updatePlayCounts (Finished) " + str(countSync))
#incremental sync
if(cur_seconds_incrsync >= interval_IncrementalSync):
xbmc.log("Doing_Db_Sync: updatePlayCounts (Started)")
worked = librarySync.updatePlayCounts()
xbmc.log("Doing_Db_Sync: updatePlayCounts (Finished) " + str(worked))
if(worked):
cur_seconds_incrsync = 0
if(libSync and countSync):
startupComplete = True
else:
cur_seconds_incrsync = interval_IncrementalSync - 10
else:
cur_seconds_incrsync += 1
xbmc.sleep(10000)
else:
xbmc.log("Not authenticated yet")