speed improvements

This commit is contained in:
im85288 2015-04-04 18:20:48 +01:00
parent 86e7a9622e
commit b880555829
4 changed files with 75 additions and 80 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.emby" <addon id="plugin.video.emby"
name="Emby" name="Emby"
version="0.0.13" version="0.0.14"
provider-name="Emby.media"> provider-name="Emby.media">
<requires> <requires>
<import addon="xbmc.python" version="2.1.0"/> <import addon="xbmc.python" version="2.1.0"/>

View file

@ -45,23 +45,24 @@ class LibrarySync():
try: try:
completed = True completed = True
connection = utils.KodiSQL()
cursor = connection.cursor()
# sync movies # sync movies
if(syncInstallRunDone == False): # on first install run do a full sync with model progress dialog if(syncInstallRunDone == False): # on first install run do a full sync with model progress dialog
completed = completed and self.TvShowsSync(True, True) completed = completed and self.TvShowsSync(connection, cursor,True, True)
completed = completed and self.MoviesSync(True, True) completed = completed and self.MoviesSync(connection, cursor,True, True)
completed = completed and self.MusicVideosSync(True, True) completed = completed and self.MusicVideosSync(True, True,connection , cursor)
elif(startupDone == False): # on first run after startup do a inc then a full sync elif(startupDone == False): # on first run after startup do a inc then a full sync
self.TvShowsSync(False, False) self.TvShowsSync(connection, cursor,False, False)
self.MoviesSync(False, False) self.MoviesSync(connection, cursor,False, False)
self.MusicVideosSync(False, False) self.MusicVideosSync(False, False, connection,cursor)
self.TvShowsSync(True, False) self.TvShowsSync(connection, cursor,True, False)
self.MoviesSync(True, False) self.MoviesSync(connection, cursor,True, False)
self.MusicVideosSync(True, False) self.MusicVideosSync(True, False,connection,cursor)
else: # on scheduled sync do a full sync else: # on scheduled sync do a full sync
self.TvShowsSync(True, False) self.TvShowsSync(connection, cursor,True, False)
self.MoviesSync(True, False) self.MoviesSync(connection, cursor,True, False)
self.MusicVideosSync(True, False) self.MusicVideosSync(True, False,connection,cursor)
# set the install done setting # set the install done setting
if(syncInstallRunDone == False and completed): if(syncInstallRunDone == False and completed):
@ -73,10 +74,11 @@ class LibrarySync():
finally: finally:
WINDOW.setProperty("SyncDatabaseRunning", "false") WINDOW.setProperty("SyncDatabaseRunning", "false")
cursor.close()
return True return True
def MoviesSync(self, fullsync, installFirstRun, itemList = []): def MoviesSync(self,connection, cursor, fullsync, installFirstRun,itemList = []):
WINDOW = xbmcgui.Window( 10000 ) WINDOW = xbmcgui.Window( 10000 )
pDialog = None pDialog = None
@ -131,7 +133,7 @@ class LibrarySync():
item['Tag'].append(view.get('title')) item['Tag'].append(view.get('title'))
if item["Id"] not in allKodiIds: if item["Id"] not in allKodiIds:
WriteKodiDB().addMovieToKodiLibrary(item) WriteKodiDB().addMovieToKodiLibrary(item,connection, cursor)
totalItemsAdded += 1 totalItemsAdded += 1
if(self.ShouldStop(pDialog)): if(self.ShouldStop(pDialog)):
@ -170,7 +172,7 @@ class LibrarySync():
if(kodimovie != None): if(kodimovie != None):
#WriteKodiDB().updateMovieToKodiLibrary(item, kodimovie) #WriteKodiDB().updateMovieToKodiLibrary(item, kodimovie)
updated = WriteKodiDB().updateMovieToKodiLibrary_Batched(item, kodimovie) updated = WriteKodiDB().updateMovieToKodiLibrary_Batched(item, kodimovie, connection, cursor)
if(updated): if(updated):
totalItemsUpdated += 1 totalItemsUpdated += 1
@ -207,7 +209,7 @@ class LibrarySync():
if(self.ShouldStop(pDialog)): if(self.ShouldStop(pDialog)):
return False return False
boxsetMovies = ReadEmbyDB().getMoviesInBoxSet(boxset["Id"]) boxsetMovies = ReadEmbyDB().getMoviesInBoxSet(boxset["Id"])
WriteKodiDB().addBoxsetToKodiLibrary(boxset) WriteKodiDB().addBoxsetToKodiLibrary(boxset,connection, cursor)
for boxsetMovie in boxsetMovies: for boxsetMovie in boxsetMovies:
if(self.ShouldStop(pDialog)): if(self.ShouldStop(pDialog)):
@ -264,7 +266,7 @@ class LibrarySync():
return True return True
def TvShowsSync(self, fullsync, installFirstRun, itemList = []): def TvShowsSync(self, connection, cursor ,fullsync, installFirstRun, itemList = []):
addon = xbmcaddon.Addon(id='plugin.video.emby') addon = xbmcaddon.Addon(id='plugin.video.emby')
WINDOW = xbmcgui.Window( 10000 ) WINDOW = xbmcgui.Window( 10000 )
@ -325,7 +327,7 @@ class LibrarySync():
if not matchFound: if not matchFound:
#no match so we have to create it #no match so we have to create it
print "creating episode in incremental sync!" print "creating episode in incremental sync!"
WriteKodiDB().addEpisodeToKodiLibrary(episode) WriteKodiDB().addEpisodeToKodiLibrary(episode,connection, cursor)
progressAction = "Adding" progressAction = "Adding"
totalItemsAdded += 1 totalItemsAdded += 1
@ -364,7 +366,7 @@ class LibrarySync():
if kodiEpisodes != None: if kodiEpisodes != None:
KodiItem = kodiEpisodes.get(comparestring1, None) KodiItem = kodiEpisodes.get(comparestring1, None)
if(KodiItem != None): if(KodiItem != None):
WriteKodiDB().updateEpisodeToKodiLibrary(episode, KodiItem) WriteKodiDB().updateEpisodeToKodiLibrary(episode, KodiItem, connection, cursor)
if(self.ShouldStop(pDialog)): if(self.ShouldStop(pDialog)):
return False return False
@ -402,7 +404,7 @@ class LibrarySync():
allTVShows.append(item["Id"]) allTVShows.append(item["Id"])
progMessage = "Processing" progMessage = "Processing"
if item["Id"] not in allKodiIds: if item["Id"] not in allKodiIds:
WriteKodiDB().addTVShowToKodiLibrary(item) WriteKodiDB().addTVShowToKodiLibrary(item,connection, cursor)
totalItemsAdded += 1 totalItemsAdded += 1
if(self.ShouldStop(pDialog)): if(self.ShouldStop(pDialog)):
@ -450,7 +452,7 @@ class LibrarySync():
for item in episodeData: for item in episodeData:
if(installFirstRun): if(installFirstRun):
progressAction = "Adding" progressAction = "Adding"
WriteKodiDB().addEpisodeToKodiLibrary(item) WriteKodiDB().addEpisodeToKodiLibrary(item, connection, cursor)
else: else:
comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber")) comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber"))
matchFound = False matchFound = False
@ -497,7 +499,7 @@ class LibrarySync():
kodishow = None kodishow = None
if(kodishow != None): if(kodishow != None):
updated = WriteKodiDB().updateTVShowToKodiLibrary(item,kodishow) updated = WriteKodiDB().updateTVShowToKodiLibrary(item,kodishow,connection, cursor)
if(updated): if(updated):
totalItemsUpdated += 1 totalItemsUpdated += 1
@ -545,7 +547,7 @@ class LibrarySync():
if kodiEpisodes != None: if kodiEpisodes != None:
KodiItem = kodiEpisodes.get(comparestring1, None) KodiItem = kodiEpisodes.get(comparestring1, None)
if(KodiItem != None): if(KodiItem != None):
updated = WriteKodiDB().updateEpisodeToKodiLibrary(item, KodiItem) updated = WriteKodiDB().updateEpisodeToKodiLibrary(item, KodiItem, connection, cursor)
if(updated): if(updated):
totalItemsUpdated += 1 totalItemsUpdated += 1
@ -626,7 +628,7 @@ class LibrarySync():
return True return True
def MusicVideosSync(self, fullsync, installFirstRun): def MusicVideosSync(self, fullsync, installFirstRun,connection, cursor):
addon = xbmcaddon.Addon(id='plugin.video.emby') addon = xbmcaddon.Addon(id='plugin.video.emby')
WINDOW = xbmcgui.Window( 10000 ) WINDOW = xbmcgui.Window( 10000 )
@ -669,7 +671,7 @@ class LibrarySync():
allEmbyMusicVideoIds.append(item["Id"]) allEmbyMusicVideoIds.append(item["Id"])
if item["Id"] not in allKodiIds: if item["Id"] not in allKodiIds:
WriteKodiDB().addMusicVideoToKodiLibrary(item) WriteKodiDB().addMusicVideoToKodiLibrary(item, connection, cursor)
if(self.ShouldStop(pDialog)): if(self.ShouldStop(pDialog)):
return False return False

View file

@ -207,8 +207,11 @@ class WebSocketThread(threading.Thread):
itemsToUpdate = itemsAdded + itemsUpdated itemsToUpdate = itemsAdded + itemsUpdated
if(len(itemsToUpdate) > 0): if(len(itemsToUpdate) > 0):
self.logMsg("Message : Doing LibraryChanged : Processing Added and Updated : " + str(itemsToUpdate), 0) self.logMsg("Message : Doing LibraryChanged : Processing Added and Updated : " + str(itemsToUpdate), 0)
LibrarySync().MoviesSync(fullsync = False, installFirstRun = False, itemList = itemsToUpdate) connection = utils.KodiSQL()
LibrarySync().TvShowsSync(fullsync = False, installFirstRun = False, itemList = itemsToUpdate) cursor = connection.cursor()
LibrarySync().MoviesSync(connection, cursor, fullsync = False, installFirstRun = False, itemList = itemsToUpdate)
LibrarySync().TvShowsSync(connection, cursor,fullsync = False, installFirstRun = False, itemList = itemsToUpdate)
cursor.close()
def on_error(self, ws, error): def on_error(self, ws, error):
self.logMsg("Error : " + str(error)) self.logMsg("Error : " + str(error))

View file

@ -45,7 +45,7 @@ class WriteKodiDB():
else: else:
downloadUtils.downloadUrl(watchedurl, type="DELETE") downloadUtils.downloadUrl(watchedurl, type="DELETE")
def updateMovieToKodiLibrary_Batched(self, MBitem, KodiItem): def updateMovieToKodiLibrary_Batched(self, MBitem, KodiItem,connection, cursor):
addon = xbmcaddon.Addon(id='plugin.video.emby') addon = xbmcaddon.Addon(id='plugin.video.emby')
port = addon.getSetting('port') port = addon.getSetting('port')
host = addon.getSetting('ipaddress') host = addon.getSetting('ipaddress')
@ -68,7 +68,7 @@ class WriteKodiDB():
#set Filename #set Filename
playurl = PlayUtils().getPlayUrl(server, MBitem["Id"], MBitem) playurl = PlayUtils().getPlayUrl(server, MBitem["Id"], MBitem)
self.setKodiFilename(KodiItem["movieid"], KodiItem["file"], playurl, "movie", MBitem["Id"]) self.setKodiFilename(KodiItem["movieid"], KodiItem["file"], playurl, "movie", MBitem["Id"], connection, cursor)
#update common properties #update common properties
if KodiItem["runtime"] == 0: if KodiItem["runtime"] == 0:
@ -138,7 +138,7 @@ class WriteKodiDB():
result = xbmc.executeJSONRPC(jsoncommand.encode("utf-8")) result = xbmc.executeJSONRPC(jsoncommand.encode("utf-8"))
#add actors #add actors
changes |= self.AddActorsToMedia(KodiItem,MBitem.get("People"), "movie") changes |= self.AddActorsToMedia(KodiItem,MBitem.get("People"), "movie", connection, cursor)
if(changes): if(changes):
utils.logMsg("Updated item to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"], level=0) utils.logMsg("Updated item to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"], level=0)
@ -202,7 +202,7 @@ class WriteKodiDB():
if(changes): if(changes):
utils.logMsg("Updated musicvideo to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"], level=0) utils.logMsg("Updated musicvideo to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"], level=0)
def updateMovieToKodiLibrary(self, MBitem, KodiItem): def updateMovieToKodiLibrary(self, MBitem, KodiItem, connection, cursor):
addon = xbmcaddon.Addon(id='plugin.video.emby') addon = xbmcaddon.Addon(id='plugin.video.emby')
port = addon.getSetting('port') port = addon.getSetting('port')
@ -270,16 +270,16 @@ class WriteKodiDB():
changes |= self.updateProperty(KodiItem,"trailer",trailerUrl,"movie") changes |= self.updateProperty(KodiItem,"trailer",trailerUrl,"movie")
#add actors #add actors
changes |= self.AddActorsToMedia(KodiItem,MBitem.get("People"),"movie") changes |= self.AddActorsToMedia(KodiItem,MBitem.get("People"),"movie", connection, cursor)
#set Filename #set Filename
playurl = PlayUtils().getPlayUrl(server, MBitem["Id"], MBitem) playurl = PlayUtils().getPlayUrl(server, MBitem["Id"], MBitem)
self.setKodiFilename(KodiItem["movieid"], KodiItem["file"], playurl, "movie") self.setKodiFilename(KodiItem["movieid"], KodiItem["file"], playurl, "movie", connection, cursor)
if changes: if changes:
utils.logMsg("Updated item to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"]) utils.logMsg("Updated item to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"])
def updateTVShowToKodiLibrary( self, MBitem, KodiItem ): def updateTVShowToKodiLibrary( self, MBitem, KodiItem,connection, cursor ):
addon = xbmcaddon.Addon(id='plugin.video.emby') addon = xbmcaddon.Addon(id='plugin.video.emby')
port = addon.getSetting('port') port = addon.getSetting('port')
@ -303,7 +303,7 @@ class WriteKodiDB():
playurl = PlayUtils().getPlayUrl(server, MBitem["Id"], MBitem) playurl = PlayUtils().getPlayUrl(server, MBitem["Id"], MBitem)
#make sure that the path always ends with a slash #make sure that the path always ends with a slash
playurl = playurl + "/" playurl = playurl + "/"
self.setKodiFilename(KodiItem["tvshowid"], KodiItem["file"], playurl, "tvshow", MBitem["Id"]) self.setKodiFilename(KodiItem["tvshowid"], KodiItem["file"], playurl, "tvshow", MBitem["Id"], connection, cursor)
#update/check all artwork #update/check all artwork
changes |= self.updateArtWork(KodiItem,MBitem) changes |= self.updateArtWork(KodiItem,MBitem)
@ -337,17 +337,17 @@ class WriteKodiDB():
changes |= self.updatePropertyArray(KodiItem,"country",MBitem.get("ProductionLocations"),"tvshow") changes |= self.updatePropertyArray(KodiItem,"country",MBitem.get("ProductionLocations"),"tvshow")
#add actors #add actors
changes |= self.AddActorsToMedia(KodiItem,MBitem.get("People"),"tvshow") changes |= self.AddActorsToMedia(KodiItem,MBitem.get("People"),"tvshow", connection, cursor)
#update season details #update season details
self.updateSeasons(MBitem, KodiItem) self.updateSeasons(MBitem, KodiItem,connection, cursor)
if changes: if changes:
utils.logMsg("Updated item to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"]) utils.logMsg("Updated item to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"])
return changes return changes
def updateEpisodeToKodiLibrary( self, MBitem, KodiItem ): def updateEpisodeToKodiLibrary( self, MBitem, KodiItem, connection, cursor ):
addon = xbmcaddon.Addon(id='plugin.video.emby') addon = xbmcaddon.Addon(id='plugin.video.emby')
port = addon.getSetting('port') port = addon.getSetting('port')
@ -372,7 +372,7 @@ class WriteKodiDB():
#set Filename (will update the filename in db if changed) #set Filename (will update the filename in db if changed)
playurl = PlayUtils().getPlayUrl(server, MBitem["Id"], MBitem) playurl = PlayUtils().getPlayUrl(server, MBitem["Id"], MBitem)
docleanup = self.setKodiFilename(KodiItem["episodeid"], KodiItem["file"], playurl, "episode", MBitem["Id"]) docleanup = self.setKodiFilename(KodiItem["episodeid"], KodiItem["file"], playurl, "episode", MBitem["Id"], connection, cursor)
#update common properties #update common properties
if KodiItem["runtime"] == 0: if KodiItem["runtime"] == 0:
@ -395,7 +395,7 @@ class WriteKodiDB():
changes |= self.updatePropertyArray(KodiItem,"writer",people.get("Writer"),"episode") changes |= self.updatePropertyArray(KodiItem,"writer",people.get("Writer"),"episode")
#add actors #add actors
changes |= self.AddActorsToMedia(KodiItem,MBitem.get("People"),"episode") changes |= self.AddActorsToMedia(KodiItem,MBitem.get("People"),"episode", connection, cursor)
if changes: if changes:
utils.logMsg("Updated item to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"]) utils.logMsg("Updated item to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"])
@ -641,7 +641,7 @@ class WriteKodiDB():
return pendingChanges return pendingChanges
def addMovieToKodiLibrary( self, MBitem ): def addMovieToKodiLibrary( self, MBitem ,connection, cursor):
#adds a movie to Kodi by directly inserting it to the DB while there is no addmovie available on the json API #adds a movie to Kodi by directly inserting it to the DB while there is no addmovie available on the json API
#TODO: PR at Kodi team for a addMovie endpoint on their API #TODO: PR at Kodi team for a addMovie endpoint on their API
@ -670,8 +670,8 @@ class WriteKodiDB():
else: else:
dateadded = None dateadded = None
connection = utils.KodiSQL() #connection = utils.KodiSQL()
cursor = connection.cursor() #cursor = connection.cursor()
# we need to store both the path and the filename seperately in the kodi db so we split them up # we need to store both the path and the filename seperately in the kodi db so we split them up
if "\\" in playurl: if "\\" in playurl:
@ -749,12 +749,10 @@ class WriteKodiDB():
except: except:
utils.logMsg("Emby","Error adding movie to Kodi Library",MBitem["Id"] + " - " + MBitem["Name"]) utils.logMsg("Emby","Error adding movie to Kodi Library",MBitem["Id"] + " - " + MBitem["Name"])
actionPerformed = False actionPerformed = False
finally:
cursor.close()
def addMusicVideoToKodiLibrary( self, MBitem ): def addMusicVideoToKodiLibrary( self, MBitem, connection, cursor ):
#adds a musicvideo to Kodi by directly inserting it to the DB while there is no addMusicVideo available on the json API #adds a musicvideo to Kodi by directly inserting it to connectionthe DB while there is no addMusicVideo available on the json API
#TODO: PR at Kodi team for a addMusicVideo endpoint on their API #TODO: PR at Kodi team for a addMusicVideo endpoint on their API
addon = xbmcaddon.Addon(id='plugin.video.emby') addon = xbmcaddon.Addon(id='plugin.video.emby')
@ -782,8 +780,8 @@ class WriteKodiDB():
else: else:
dateadded = None dateadded = None
connection = utils.KodiSQL() #connection = utils.KodiSQL()
cursor = connection.cursor() #cursor = connection.cursor()
# we need to store both the path and the filename seperately in the kodi db so we split them up # we need to store both the path and the filename seperately in the kodi db so we split them up
if "\\" in playurl: if "\\" in playurl:
@ -839,10 +837,8 @@ class WriteKodiDB():
except: except:
utils.logMsg("Emby","Error adding musicvideo to Kodi Library",MBitem["Id"] + " - " + MBitem["Name"]) utils.logMsg("Emby","Error adding musicvideo to Kodi Library",MBitem["Id"] + " - " + MBitem["Name"])
actionPerformed = False actionPerformed = False
finally:
cursor.close()
def addEpisodeToKodiLibrary(self, MBitem): def addEpisodeToKodiLibrary(self, MBitem, connection, cursor):
#adds a Episode to Kodi by directly inserting it to the DB while there is no addEpisode available on the json API #adds a Episode to Kodi by directly inserting it to the DB while there is no addEpisode available on the json API
#TODO: PR at Kodi team for a addEpisode endpoint on their API #TODO: PR at Kodi team for a addEpisode endpoint on their API
@ -877,8 +873,8 @@ class WriteKodiDB():
else: else:
lastplayed = None lastplayed = None
connection = utils.KodiSQL() #connection = utils.KodiSQL()
cursor = connection.cursor() #cursor = connection.cursor()
# we need to store both the path and the filename seperately in the kodi db so we split them up # we need to store both the path and the filename seperately in the kodi db so we split them up
if "\\" in playurl: if "\\" in playurl:
@ -950,8 +946,6 @@ class WriteKodiDB():
except: except:
utils.logMsg("Emby","Error adding tvshow to Kodi Library",MBitem["Id"] + " - " + MBitem["Name"]) utils.logMsg("Emby","Error adding tvshow to Kodi Library",MBitem["Id"] + " - " + MBitem["Name"])
actionPerformed = False actionPerformed = False
finally:
cursor.close()
def deleteMovieFromKodiLibrary(self, id ): def deleteMovieFromKodiLibrary(self, id ):
kodiItem = ReadKodiDB().getKodiMovie(id) kodiItem = ReadKodiDB().getKodiMovie(id)
@ -976,7 +970,7 @@ class WriteKodiDB():
else: else:
utils.logMsg("episode not found in kodi DB",episodeid) utils.logMsg("episode not found in kodi DB",episodeid)
def addTVShowToKodiLibrary( self, MBitem ): def addTVShowToKodiLibrary( self, MBitem, connection, cursor ):
#adds a Tvshow to Kodi by directly inserting it to the DB while there is no addTvShow available on the json API #adds a Tvshow to Kodi by directly inserting it to the DB while there is no addTvShow available on the json API
#TODO: PR at Kodi team for a addTvShow endpoint on their API #TODO: PR at Kodi team for a addTvShow endpoint on their API
@ -1006,8 +1000,8 @@ class WriteKodiDB():
else: else:
dateadded = None dateadded = None
connection = utils.KodiSQL() #connection = utils.KodiSQL()
cursor = connection.cursor() #cursor = connection.cursor()
#create the tv show path #create the tv show path
cursor.execute("select coalesce(max(idPath),0) as pathid from path") cursor.execute("select coalesce(max(idPath),0) as pathid from path")
@ -1061,8 +1055,6 @@ class WriteKodiDB():
except: except:
utils.logMsg("Emby","Error adding tvshow to Kodi Library",MBitem["Id"] + " - " + MBitem["Name"]) utils.logMsg("Emby","Error adding tvshow to Kodi Library",MBitem["Id"] + " - " + MBitem["Name"])
actionPerformed = False actionPerformed = False
finally:
cursor.close()
def deleteTVShowFromKodiLibrary(self, id): def deleteTVShowFromKodiLibrary(self, id):
xbmc.sleep(sleepVal) xbmc.sleep(sleepVal)
@ -1075,12 +1067,12 @@ class WriteKodiDB():
utils.logMsg("deleting tvshow from Kodi library ", "Kodi ID : " + str(kodiId)) utils.logMsg("deleting tvshow from Kodi library ", "Kodi ID : " + str(kodiId))
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.RemoveTVShow", "params": { "tvshowid": %i}, "id": 1 }' %(kodiId)) xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.RemoveTVShow", "params": { "tvshowid": %i}, "id": 1 }' %(kodiId))
def updateSeasons(self,MBitem, KodiItem): def updateSeasons(self,MBitem, KodiItem, connection, cursor):
#use sqlite to set the season details because no method in API available for this #use sqlite to set the season details because no method in API available for this
tvshowid = KodiItem["tvshowid"] tvshowid = KodiItem["tvshowid"]
connection = utils.KodiSQL() #connection = utils.KodiSQL()
cursor = connection.cursor() #cursor = connection.cursor()
seasonData = ReadEmbyDB().getTVShowSeasons(MBitem["Id"]) seasonData = ReadEmbyDB().getTVShowSeasons(MBitem["Id"])
if seasonData != None: if seasonData != None:
@ -1104,7 +1096,7 @@ class WriteKodiDB():
cursor.execute("INSERT into art(media_id, media_type, type, url) values(?, ?, ?, ?)", (seasonid,"season","banner",API().getArtwork(season, "Banner"))) cursor.execute("INSERT into art(media_id, media_type, type, url) values(?, ?, ?, ?)", (seasonid,"season","banner",API().getArtwork(season, "Banner")))
connection.commit() connection.commit()
cursor.close() #cursor.close()
def setKodiResumePoint(self, id, resume_seconds, total_seconds, fileType): def setKodiResumePoint(self, id, resume_seconds, total_seconds, fileType):
#use sqlite to set the resume point while json api doesn't support this yet #use sqlite to set the resume point while json api doesn't support this yet
@ -1133,7 +1125,7 @@ class WriteKodiDB():
connection.commit() connection.commit()
cursor.close() cursor.close()
def setKodiFilename(self, id, oldFileName, newFileName, fileType, mbId): def setKodiFilename(self, id, oldFileName, newFileName, fileType, mbId, connection, cursor):
#use sqlite to set the filename in DB -- needed to avoid problems with resumepoints etc #use sqlite to set the filename in DB -- needed to avoid problems with resumepoints etc
#return True if any action is performed, False if no action is performed #return True if any action is performed, False if no action is performed
#todo --> submit PR to kodi team to get this added to the jsonrpc api #todo --> submit PR to kodi team to get this added to the jsonrpc api
@ -1148,8 +1140,8 @@ class WriteKodiDB():
if oldFileName != newFileName: if oldFileName != newFileName:
# xbmc.sleep(sleepVal) # xbmc.sleep(sleepVal)
connection = utils.KodiSQL() #connection = utils.KodiSQL()
cursor = connection.cursor() #cursor = connection.cursor()
utils.logMsg("Emby","setting filename in kodi db..." + fileType + ": " + str(id)) utils.logMsg("Emby","setting filename in kodi db..." + fileType + ": " + str(id))
utils.logMsg("Emby","old filename -->" + oldFileName) utils.logMsg("Emby","old filename -->" + oldFileName)
utils.logMsg("Emby","new filename -->" + newFileName) utils.logMsg("Emby","new filename -->" + newFileName)
@ -1227,12 +1219,10 @@ class WriteKodiDB():
except: except:
utils.logMsg("Emby","Error setting filename in kodi db for: " + fileType + ": " + str(id)) utils.logMsg("Emby","Error setting filename in kodi db for: " + fileType + ": " + str(id))
actionPerformed = False actionPerformed = False
finally:
cursor.close()
return actionPerformed return actionPerformed
def AddActorsToMedia(self, KodiItem, people, mediatype): def AddActorsToMedia(self, KodiItem, people, mediatype, connection, cursor):
#use sqlite to set add the actors while json api doesn't support this yet #use sqlite to set add the actors while json api doesn't support this yet
#todo --> submit PR to kodi team to get this added to the jsonrpc api #todo --> submit PR to kodi team to get this added to the jsonrpc api
@ -1263,8 +1253,8 @@ class WriteKodiDB():
utils.logMsg("AddActorsToMedia", "List needs updating") utils.logMsg("AddActorsToMedia", "List needs updating")
# xbmc.sleep(sleepVal) # xbmc.sleep(sleepVal)
connection = utils.KodiSQL() #connection = utils.KodiSQL()
cursor = connection.cursor() #cursor = connection.cursor()
if(people != None): if(people != None):
for person in people: for person in people:
@ -1295,14 +1285,14 @@ class WriteKodiDB():
cursor.execute(peoplesql, (actorid,id,Role,None)) cursor.execute(peoplesql, (actorid,id,Role,None))
connection.commit() connection.commit()
cursor.close() #cursor.close()
return True return True
def addBoxsetToKodiLibrary(self, boxset): def addBoxsetToKodiLibrary(self, boxset, connection, cursor):
#use sqlite to set add the set #use sqlite to set add the set
connection = utils.KodiSQL() #connection = utils.KodiSQL()
cursor = connection.cursor() #cursor = connection.cursor()
strSet = boxset["Name"] strSet = boxset["Name"]
# check if exists # check if exists
@ -1346,7 +1336,7 @@ class WriteKodiDB():
if result != None: if result != None:
setid = result[0] setid = result[0]
connection.commit() connection.commit()
cursor.close() #cursor.close()
return True return True