fixed some errors

This commit is contained in:
Marcel van der Veldt 2015-05-02 12:51:46 +02:00
parent 61c6fedc19
commit 8c6b90923e
2 changed files with 63 additions and 49 deletions

View file

@ -65,6 +65,7 @@ class LibrarySync():
#sync Tvshows and episodes #sync Tvshows and episodes
self.TvShowsFullSync(connection,cursor,pDialog) self.TvShowsFullSync(connection,cursor,pDialog)
# set the install done setting # set the install done setting
if(syncInstallRunDone == False and completed): if(syncInstallRunDone == False and completed):
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
@ -115,7 +116,7 @@ class LibrarySync():
if(pDialog != None): if(pDialog != None):
progressTitle = "Processing " + view.get('title') + " (" + str(count) + " of " + str(total) + ")" progressTitle = "Processing " + view.get('title') + " (" + str(count) + " of " + str(total) + ")"
pDialog.update(0, "Emby for Kodi - Running Sync", progressTitle) pDialog.update(0, "Emby for Kodi - Running Sync", progressTitle)
count = 1 count += 1
kodiMovie = None kodiMovie = None
for kodimovie in allKodiMovies: for kodimovie in allKodiMovies:
@ -164,7 +165,7 @@ class LibrarySync():
if(pDialog != None): if(pDialog != None):
progressTitle = "Processing " + view.get('title') + " (" + str(count) + " of " + str(total) + ")" progressTitle = "Processing " + view.get('title') + " (" + str(count) + " of " + str(total) + ")"
pDialog.update(0, "Emby for Kodi - Running Sync", progressTitle) pDialog.update(0, "Emby for Kodi - Running Sync", progressTitle)
count = 1 count += 1
#build a list with all Id's and get the existing entry (if exists) in Kodi DB #build a list with all Id's and get the existing entry (if exists) in Kodi DB
kodiShow = None kodiShow = None
@ -241,6 +242,7 @@ class LibrarySync():
connection = utils.KodiSQL() connection = utils.KodiSQL()
cursor = connection.cursor() cursor = connection.cursor()
try:
#### PROCESS MOVIES #### #### PROCESS MOVIES ####
views = ReadEmbyDB().getCollections("movies") views = ReadEmbyDB().getCollections("movies")
for view in views: for view in views:
@ -262,7 +264,7 @@ class LibrarySync():
for item in itemList: for item in itemList:
MBitem = ReadEmbyDB().getItem(item) MBitem = ReadEmbyDB().getItem(item)
print MBitem
if MBitem["Type"] == "Episode": if MBitem["Type"] == "Episode":
#get the tv show #get the tv show
@ -272,12 +274,14 @@ class LibrarySync():
kodi_show_id = result[0] kodi_show_id = result[0]
else: else:
kodi_show_id = None kodi_show_id = None
print "show id not found!"
if kodi_show_id: if kodi_show_id:
WriteKodiDB().addOrUpdateEpisodeToKodiLibrary(item["Id"], kodi_show_id, connection, cursor) WriteKodiDB().addOrUpdateEpisodeToKodiLibrary(item["Id"], kodi_show_id, connection, cursor)
finally:
cursor.close() cursor.close()
#close the progress dialog
if(pDialog != None): if(pDialog != None):
pDialog.close() pDialog.close()

View file

@ -148,6 +148,9 @@ class WriteKodiDB():
##### ADD THE MOVIE ############ ##### ADD THE MOVIE ############
if movieid == None: if movieid == None:
utils.logMsg("ADD movie to Kodi library","Id: %s - Title: %s" % (embyId, title))
#create the movie #create the movie
cursor.execute("select coalesce(max(idMovie),0) as movieid from movie") cursor.execute("select coalesce(max(idMovie),0) as movieid from movie")
movieid = cursor.fetchone()[0] movieid = cursor.fetchone()[0]
@ -167,6 +170,7 @@ class WriteKodiDB():
#### UPDATE THE MOVIE ##### #### UPDATE THE MOVIE #####
else: else:
utils.logMsg("UPDATE movie to Kodi library","Id: %s - Title: %s" % (embyId, title))
pathsql="update movie SET c00 = ?, c01 = ?, c02 = ?, c05 = ?, c06 = ?, c07 = ?, c09 = ?, c10 = ?, c11 = ?, c12 = ?, c14 = ?, c15 = ?, c16 = ?, c18 = ?, c19 = ? WHERE idMovie = ?" pathsql="update movie SET c00 = ?, c01 = ?, c02 = ?, c05 = ?, c06 = ?, c07 = ?, c09 = ?, c10 = ?, c11 = ?, c12 = ?, c14 = ?, c15 = ?, c16 = ?, c18 = ?, c19 = ? WHERE idMovie = ?"
cursor.execute(pathsql, (title, plot, shortplot, rating, writer, year, imdb, sorttitle, runtime, mpaa, genre, director, title, studio, trailerUrl, movieid)) cursor.execute(pathsql, (title, plot, shortplot, rating, writer, year, imdb, sorttitle, runtime, mpaa, genre, director, title, studio, trailerUrl, movieid))
@ -255,6 +259,8 @@ class WriteKodiDB():
#### ADD THE TV SHOW TO KODI ############## #### ADD THE TV SHOW TO KODI ##############
if showid == None: if showid == None:
utils.logMsg("ADD tvshow to Kodi library","Id: %s - Title: %s" % (embyId, title))
#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")
pathid = cursor.fetchone()[0] pathid = cursor.fetchone()[0]
@ -293,6 +299,8 @@ class WriteKodiDB():
#### UPDATE THE TV SHOW ############# #### UPDATE THE TV SHOW #############
else: else:
utils.logMsg("UPDATE tvshow to Kodi library","Id: %s - Title: %s" % (embyId, title))
pathsql="UPDATE tvshow SET c00 = ?, c01 = ?, c04 = ?, c05 = ?, c08 = ?, c09 = ?, c13 = ?, c14 = ?, c15 = ? WHERE idShow = ?" pathsql="UPDATE tvshow SET c00 = ?, c01 = ?, c04 = ?, c05 = ?, c08 = ?, c09 = ?, c13 = ?, c14 = ?, c15 = ? WHERE idShow = ?"
cursor.execute(pathsql, (title, plot, rating, premieredate, title, genre, mpaa, studio, sorttitle, showid)) cursor.execute(pathsql, (title, plot, rating, premieredate, title, genre, mpaa, studio, sorttitle, showid))
@ -496,7 +504,7 @@ class WriteKodiDB():
# ADD EPISODE TO KODI # ADD EPISODE TO KODI
if episodeid == None: if episodeid == None:
utils.logMsg("ADD episode to Kodi library","Id: %s - Title: %s" % (embyId, title))
#create the episode #create the episode
cursor.execute("select coalesce(max(idEpisode),0) as episodeid from episode") cursor.execute("select coalesce(max(idEpisode),0) as episodeid from episode")
episodeid = cursor.fetchone()[0] episodeid = cursor.fetchone()[0]
@ -513,6 +521,8 @@ class WriteKodiDB():
# UPDATE THE EPISODE IN KODI (for now, we just send in all data) # UPDATE THE EPISODE IN KODI (for now, we just send in all data)
else: else:
utils.logMsg("UPDATE episode to Kodi library","Id: %s - Title: %s" % (embyId, title))
pathsql = "UPDATE episode SET c00 = ?, c01 = ?, c03 = ?, c04 = ?, c05 = ?, c09 = ?, c10 = ?, c12 = ?, c13 = ?, c14 = ?, c15 = ?, c16 = ? WHERE idEpisode = ?" pathsql = "UPDATE episode SET c00 = ?, c01 = ?, c03 = ?, c04 = ?, c05 = ?, c09 = ?, c10 = ?, c12 = ?, c13 = ?, c14 = ?, c15 = ?, c16 = ? WHERE idEpisode = ?"
cursor.execute(pathsql, (title, plot, rating, writer, premieredate, runtime, director, season, episode, title, "-1", "-1", episodeid)) cursor.execute(pathsql, (title, plot, rating, writer, premieredate, runtime, director, season, episode, title, "-1", "-1", episodeid))