perform all database commits at once instead of 1 by 1
This commit is contained in:
parent
e637af1b78
commit
383fb37ca3
3 changed files with 19 additions and 25 deletions
|
@ -83,7 +83,7 @@ class LibrarySync():
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.emby') #force a new instance of the addon
|
addon = xbmcaddon.Addon(id='plugin.video.emby') #force a new instance of the addon
|
||||||
addon.setSetting("SyncInstallRunDone", "true")
|
addon.setSetting("SyncInstallRunDone", "true")
|
||||||
|
|
||||||
# Force refresh the library
|
# Commit all DB changes at once and Force refresh the library
|
||||||
xbmc.executebuiltin("UpdateLibrary(video)")
|
xbmc.executebuiltin("UpdateLibrary(video)")
|
||||||
|
|
||||||
# set prop to show we have run for the first time
|
# set prop to show we have run for the first time
|
||||||
|
@ -92,6 +92,7 @@ class LibrarySync():
|
||||||
finally:
|
finally:
|
||||||
WINDOW.setProperty("SyncDatabaseRunning", "false")
|
WINDOW.setProperty("SyncDatabaseRunning", "false")
|
||||||
utils.logMsg("Sync DB", "syncDatabase Exiting", 0)
|
utils.logMsg("Sync DB", "syncDatabase Exiting", 0)
|
||||||
|
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
|
@ -149,6 +150,9 @@ class LibrarySync():
|
||||||
WINDOW.setProperty(kodiId,"deleted")
|
WINDOW.setProperty(kodiId,"deleted")
|
||||||
WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor)
|
WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor)
|
||||||
|
|
||||||
|
### commit all changes to database ###
|
||||||
|
connection.commit()
|
||||||
|
|
||||||
def MusicVideosFullSync(self,connection,cursor, pDialog):
|
def MusicVideosFullSync(self,connection,cursor, pDialog):
|
||||||
|
|
||||||
allKodiMusicvideoIds = list()
|
allKodiMusicvideoIds = list()
|
||||||
|
@ -195,6 +199,9 @@ class LibrarySync():
|
||||||
WINDOW.setProperty(kodiId,"deleted")
|
WINDOW.setProperty(kodiId,"deleted")
|
||||||
WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor)
|
WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor)
|
||||||
|
|
||||||
|
### commit all changes to database ###
|
||||||
|
connection.commit()
|
||||||
|
|
||||||
def TvShowsFullSync(self,connection,cursor,pDialog):
|
def TvShowsFullSync(self,connection,cursor,pDialog):
|
||||||
|
|
||||||
views = ReadEmbyDB().getCollections("tvshows")
|
views = ReadEmbyDB().getCollections("tvshows")
|
||||||
|
@ -252,6 +259,9 @@ class LibrarySync():
|
||||||
WINDOW.setProperty(kodiId,"deleted")
|
WINDOW.setProperty(kodiId,"deleted")
|
||||||
WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor)
|
WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor)
|
||||||
|
|
||||||
|
### commit all changes to database ###
|
||||||
|
connection.commit()
|
||||||
|
|
||||||
def EpisodesFullSync(self,connection,cursor,showId):
|
def EpisodesFullSync(self,connection,cursor,showId):
|
||||||
|
|
||||||
WINDOW = xbmcgui.Window( 10000 )
|
WINDOW = xbmcgui.Window( 10000 )
|
||||||
|
@ -300,6 +310,7 @@ class LibrarySync():
|
||||||
WINDOW.setProperty(kodiId,"deleted")
|
WINDOW.setProperty(kodiId,"deleted")
|
||||||
WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor)
|
WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor)
|
||||||
|
|
||||||
|
|
||||||
def IncrementalSync(self, itemList):
|
def IncrementalSync(self, itemList):
|
||||||
#this will only perform sync for items received by the websocket
|
#this will only perform sync for items received by the websocket
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
||||||
|
@ -356,6 +367,9 @@ class LibrarySync():
|
||||||
if not item.get('IsFolder'):
|
if not item.get('IsFolder'):
|
||||||
WriteKodiDB().addOrUpdateMusicVideoToKodiLibrary(item["Id"],connection, cursor)
|
WriteKodiDB().addOrUpdateMusicVideoToKodiLibrary(item["Id"],connection, cursor)
|
||||||
|
|
||||||
|
### commit all changes to database ###
|
||||||
|
connection.commit()
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
xbmc.executebuiltin("UpdateLibrary(video)")
|
xbmc.executebuiltin("UpdateLibrary(video)")
|
||||||
|
|
|
@ -180,11 +180,12 @@ class WebSocketThread(threading.Thread):
|
||||||
self.update_items(itemsToUpdate)
|
self.update_items(itemsToUpdate)
|
||||||
|
|
||||||
def remove_items(self, itemsRemoved):
|
def remove_items(self, itemsRemoved):
|
||||||
for item in itemsRemoved:
|
|
||||||
connection = utils.KodiSQL()
|
connection = utils.KodiSQL()
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
for item in itemsRemoved:
|
||||||
self.logMsg("Message : Doing LibraryChanged : Items Removed : Calling deleteEpisodeFromKodiLibraryByMbId: " + item, 0)
|
self.logMsg("Message : Doing LibraryChanged : Items Removed : Calling deleteEpisodeFromKodiLibraryByMbId: " + item, 0)
|
||||||
WriteKodiDB().deleteItemFromKodiLibrary(item, connection, cursor)
|
WriteKodiDB().deleteItemFromKodiLibrary(item, connection, cursor)
|
||||||
|
connection.commit()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
def update_items(self, itemsToUpdate):
|
def update_items(self, itemsToUpdate):
|
||||||
|
|
|
@ -199,9 +199,6 @@ class WriteKodiDB():
|
||||||
total = int(round(float(timeInfo.get("TotalTime"))))*60
|
total = int(round(float(timeInfo.get("TotalTime"))))*60
|
||||||
self.setKodiResumePoint(fileid, resume, total, cursor)
|
self.setKodiResumePoint(fileid, resume, total, cursor)
|
||||||
|
|
||||||
#commit changes and return the id
|
|
||||||
connection.commit()
|
|
||||||
return movieid
|
|
||||||
|
|
||||||
def addOrUpdateMusicVideoToKodiLibrary( self, embyId ,connection, cursor):
|
def addOrUpdateMusicVideoToKodiLibrary( self, embyId ,connection, cursor):
|
||||||
|
|
||||||
|
@ -336,9 +333,6 @@ class WriteKodiDB():
|
||||||
total = int(round(float(timeInfo.get("TotalTime"))))*60
|
total = int(round(float(timeInfo.get("TotalTime"))))*60
|
||||||
self.setKodiResumePoint(fileid, resume, total, cursor)
|
self.setKodiResumePoint(fileid, resume, total, cursor)
|
||||||
|
|
||||||
#commit changes and return the id
|
|
||||||
connection.commit()
|
|
||||||
|
|
||||||
def addOrUpdateTvShowToKodiLibrary( self, embyId, connection, cursor, viewTag ):
|
def addOrUpdateTvShowToKodiLibrary( self, embyId, connection, cursor, viewTag ):
|
||||||
|
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
||||||
|
@ -463,8 +457,6 @@ class WriteKodiDB():
|
||||||
#update season details
|
#update season details
|
||||||
self.updateSeasons(MBitem["Id"], showid, connection, cursor)
|
self.updateSeasons(MBitem["Id"], showid, connection, cursor)
|
||||||
|
|
||||||
#commit changes and return the id
|
|
||||||
connection.commit()
|
|
||||||
|
|
||||||
def addMusicVideoToKodiLibrary( self, MBitem, connection, cursor ):
|
def addMusicVideoToKodiLibrary( self, MBitem, connection, cursor ):
|
||||||
|
|
||||||
|
@ -530,12 +522,6 @@ class WriteKodiDB():
|
||||||
pathsql="insert into musicvideo(idMVideo, idFile, c00, c04, c08, c23) values(?, ?, ?, ?, ?, ?)"
|
pathsql="insert into musicvideo(idMVideo, idFile, c00, c04, c08, c23) values(?, ?, ?, ?, ?, ?)"
|
||||||
cursor.execute(pathsql, (musicvideoid, fileid, title, runtime, plot, MBitem["Id"]))
|
cursor.execute(pathsql, (musicvideoid, fileid, title, runtime, plot, MBitem["Id"]))
|
||||||
|
|
||||||
try:
|
|
||||||
connection.commit()
|
|
||||||
utils.logMsg("Emby","Added musicvideo to Kodi Library",MBitem["Id"] + " - " + MBitem["Name"])
|
|
||||||
except:
|
|
||||||
utils.logMsg("Emby","Error adding musicvideo to Kodi Library",MBitem["Id"] + " - " + MBitem["Name"])
|
|
||||||
actionPerformed = False
|
|
||||||
|
|
||||||
def addOrUpdateEpisodeToKodiLibrary(self, embyId, showid, connection, cursor):
|
def addOrUpdateEpisodeToKodiLibrary(self, embyId, showid, connection, cursor):
|
||||||
|
|
||||||
|
@ -676,9 +662,6 @@ class WriteKodiDB():
|
||||||
#update artwork
|
#update artwork
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Primary"), episodeid, "episode", "thumb", cursor)
|
self.addOrUpdateArt(API().getArtwork(MBitem, "Primary"), episodeid, "episode", "thumb", cursor)
|
||||||
|
|
||||||
#commit changes
|
|
||||||
connection.commit()
|
|
||||||
|
|
||||||
def deleteItemFromKodiLibrary(self, id, connection, cursor ):
|
def deleteItemFromKodiLibrary(self, id, connection, cursor ):
|
||||||
|
|
||||||
cursor.execute("SELECT kodi_id, media_type FROM emby WHERE emby_id=?", (id,))
|
cursor.execute("SELECT kodi_id, media_type FROM emby WHERE emby_id=?", (id,))
|
||||||
|
@ -702,8 +685,6 @@ class WriteKodiDB():
|
||||||
#delete the record in emby table
|
#delete the record in emby table
|
||||||
cursor.execute("DELETE FROM emby WHERE emby_id = ?", (id,))
|
cursor.execute("DELETE FROM emby WHERE emby_id = ?", (id,))
|
||||||
|
|
||||||
connection.commit()
|
|
||||||
|
|
||||||
def updateSeasons(self,embyTvShowId, kodiTvShowId, connection, cursor):
|
def updateSeasons(self,embyTvShowId, kodiTvShowId, connection, cursor):
|
||||||
|
|
||||||
seasonData = ReadEmbyDB().getTVShowSeasons(embyTvShowId)
|
seasonData = ReadEmbyDB().getTVShowSeasons(embyTvShowId)
|
||||||
|
@ -1058,8 +1039,6 @@ class WriteKodiDB():
|
||||||
result = cursor.fetchone()
|
result = cursor.fetchone()
|
||||||
if result != None:
|
if result != None:
|
||||||
setid = result[0]
|
setid = result[0]
|
||||||
connection.commit()
|
|
||||||
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue