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) timeInfo = API().getTimeInfo(episode)
WINDOW.setProperty("EmbyUserKey" + userData.get("Key"), episode.get('Id') + ";;" + episode.get("Type")) 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: if kodiItem != None:
WINDOW = xbmcgui.Window( 10000 ) WINDOW = xbmcgui.Window( 10000 )
WINDOW.setProperty("episodeid" + str(kodiItem['episodeid']), episode.get('Name') + ";;" + episode.get('Id')) 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 DownloadUtils import DownloadUtils
from PlaybackUtils import PlaybackUtils from PlaybackUtils import PlaybackUtils
from LibrarySync import LibrarySync from LibrarySync import LibrarySync
from WriteKodiDB import WriteKodiDB
import Utils as utils import Utils as utils
_MODE_BASICPLAY=12 _MODE_BASICPLAY=12
@ -203,7 +204,13 @@ class WebSocketThread(threading.Thread):
# doing items removed # doing items removed
itemsRemoved = data.get("ItemsRemoved") itemsRemoved = data.get("ItemsRemoved")
self.logMsg("Message : Doing LibraryChanged : Items Removed : " + str(itemsRemoved), 0) 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 # doing adds and updates
itemsAdded = data.get("ItemsAdded") itemsAdded = data.get("ItemsAdded")
self.logMsg("Message : Doing LibraryChanged : Items Added : " + str(itemsAdded), 0) self.logMsg("Message : Doing LibraryChanged : Items Added : " + str(itemsAdded), 0)

View file

@ -922,8 +922,12 @@ class WriteKodiDB():
#get the showid #get the showid
cursor.execute("SELECT idShow as showid FROM tvshow WHERE c12 = ?",(MBitem["SeriesId"],)) cursor.execute("SELECT idShow as showid FROM tvshow WHERE c12 = ?",(MBitem["SeriesId"],))
showid = cursor.fetchone()[0] 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 season = 0
if MBitem.get("ParentIndexNumber") != None: if MBitem.get("ParentIndexNumber") != None:
season = int(MBitem.get("ParentIndexNumber")) season = int(MBitem.get("ParentIndexNumber"))

View file

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