mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
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.setSetting("SyncInstallRunDone", "true")
|
||||
|
||||
# Force refresh the library
|
||||
# Commit all DB changes at once and Force refresh the library
|
||||
xbmc.executebuiltin("UpdateLibrary(video)")
|
||||
|
||||
# set prop to show we have run for the first time
|
||||
|
@ -92,6 +92,7 @@ class LibrarySync():
|
|||
finally:
|
||||
WINDOW.setProperty("SyncDatabaseRunning", "false")
|
||||
utils.logMsg("Sync DB", "syncDatabase Exiting", 0)
|
||||
|
||||
cursor.close()
|
||||
|
||||
if(pDialog != None):
|
||||
|
@ -148,6 +149,9 @@ class LibrarySync():
|
|||
if not kodiId in allEmbyMovieIds:
|
||||
WINDOW.setProperty(kodiId,"deleted")
|
||||
WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor)
|
||||
|
||||
### commit all changes to database ###
|
||||
connection.commit()
|
||||
|
||||
def MusicVideosFullSync(self,connection,cursor, pDialog):
|
||||
|
||||
|
@ -194,6 +198,9 @@ class LibrarySync():
|
|||
if not kodiId in allEmbyMusicvideoIds:
|
||||
WINDOW.setProperty(kodiId,"deleted")
|
||||
WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor)
|
||||
|
||||
### commit all changes to database ###
|
||||
connection.commit()
|
||||
|
||||
def TvShowsFullSync(self,connection,cursor,pDialog):
|
||||
|
||||
|
@ -251,6 +258,9 @@ class LibrarySync():
|
|||
if not kodiId in allEmbyTvShowIds:
|
||||
WINDOW.setProperty(kodiId,"deleted")
|
||||
WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor)
|
||||
|
||||
### commit all changes to database ###
|
||||
connection.commit()
|
||||
|
||||
def EpisodesFullSync(self,connection,cursor,showId):
|
||||
|
||||
|
@ -299,6 +309,7 @@ class LibrarySync():
|
|||
if (not kodiId in allEmbyEpisodeIds):
|
||||
WINDOW.setProperty(kodiId,"deleted")
|
||||
WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor)
|
||||
|
||||
|
||||
def IncrementalSync(self, itemList):
|
||||
#this will only perform sync for items received by the websocket
|
||||
|
@ -355,6 +366,9 @@ class LibrarySync():
|
|||
for item in allEmbyMusicvideos:
|
||||
if not item.get('IsFolder'):
|
||||
WriteKodiDB().addOrUpdateMusicVideoToKodiLibrary(item["Id"],connection, cursor)
|
||||
|
||||
### commit all changes to database ###
|
||||
connection.commit()
|
||||
|
||||
finally:
|
||||
cursor.close()
|
||||
|
|
|
@ -180,12 +180,13 @@ class WebSocketThread(threading.Thread):
|
|||
self.update_items(itemsToUpdate)
|
||||
|
||||
def remove_items(self, itemsRemoved):
|
||||
connection = utils.KodiSQL()
|
||||
cursor = connection.cursor()
|
||||
for item in itemsRemoved:
|
||||
connection = utils.KodiSQL()
|
||||
cursor = connection.cursor()
|
||||
self.logMsg("Message : Doing LibraryChanged : Items Removed : Calling deleteEpisodeFromKodiLibraryByMbId: " + item, 0)
|
||||
WriteKodiDB().deleteItemFromKodiLibrary(item, connection, cursor)
|
||||
cursor.close()
|
||||
connection.commit()
|
||||
cursor.close()
|
||||
|
||||
def update_items(self, itemsToUpdate):
|
||||
# doing adds and updates
|
||||
|
|
|
@ -199,9 +199,6 @@ class WriteKodiDB():
|
|||
total = int(round(float(timeInfo.get("TotalTime"))))*60
|
||||
self.setKodiResumePoint(fileid, resume, total, cursor)
|
||||
|
||||
#commit changes and return the id
|
||||
connection.commit()
|
||||
return movieid
|
||||
|
||||
def addOrUpdateMusicVideoToKodiLibrary( self, embyId ,connection, cursor):
|
||||
|
||||
|
@ -335,9 +332,6 @@ class WriteKodiDB():
|
|||
resume = int(round(float(timeInfo.get("ResumeTime"))))*60
|
||||
total = int(round(float(timeInfo.get("TotalTime"))))*60
|
||||
self.setKodiResumePoint(fileid, resume, total, cursor)
|
||||
|
||||
#commit changes and return the id
|
||||
connection.commit()
|
||||
|
||||
def addOrUpdateTvShowToKodiLibrary( self, embyId, connection, cursor, viewTag ):
|
||||
|
||||
|
@ -463,8 +457,6 @@ class WriteKodiDB():
|
|||
#update season details
|
||||
self.updateSeasons(MBitem["Id"], showid, connection, cursor)
|
||||
|
||||
#commit changes and return the id
|
||||
connection.commit()
|
||||
|
||||
def addMusicVideoToKodiLibrary( self, MBitem, connection, cursor ):
|
||||
|
||||
|
@ -530,12 +522,6 @@ class WriteKodiDB():
|
|||
pathsql="insert into musicvideo(idMVideo, idFile, c00, c04, c08, c23) values(?, ?, ?, ?, ?, ?)"
|
||||
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):
|
||||
|
||||
|
@ -675,9 +661,6 @@ class WriteKodiDB():
|
|||
|
||||
#update artwork
|
||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Primary"), episodeid, "episode", "thumb", cursor)
|
||||
|
||||
#commit changes
|
||||
connection.commit()
|
||||
|
||||
def deleteItemFromKodiLibrary(self, id, connection, cursor ):
|
||||
|
||||
|
@ -701,8 +684,6 @@ class WriteKodiDB():
|
|||
|
||||
#delete the record in emby table
|
||||
cursor.execute("DELETE FROM emby WHERE emby_id = ?", (id,))
|
||||
|
||||
connection.commit()
|
||||
|
||||
def updateSeasons(self,embyTvShowId, kodiTvShowId, connection, cursor):
|
||||
|
||||
|
@ -1058,8 +1039,6 @@ class WriteKodiDB():
|
|||
result = cursor.fetchone()
|
||||
if result != None:
|
||||
setid = result[0]
|
||||
connection.commit()
|
||||
|
||||
|
||||
return True
|
||||
|
||||
|
|
Loading…
Reference in a new issue