fixed some errors
This commit is contained in:
parent
61c6fedc19
commit
8c6b90923e
2 changed files with 63 additions and 49 deletions
|
@ -65,6 +65,7 @@ class LibrarySync():
|
|||
#sync Tvshows and episodes
|
||||
self.TvShowsFullSync(connection,cursor,pDialog)
|
||||
|
||||
|
||||
# set the install done setting
|
||||
if(syncInstallRunDone == False and completed):
|
||||
addon = xbmcaddon.Addon(id='plugin.video.emby') #force a new instance of the addon
|
||||
|
@ -115,7 +116,7 @@ class LibrarySync():
|
|||
if(pDialog != None):
|
||||
progressTitle = "Processing " + view.get('title') + " (" + str(count) + " of " + str(total) + ")"
|
||||
pDialog.update(0, "Emby for Kodi - Running Sync", progressTitle)
|
||||
count = 1
|
||||
count += 1
|
||||
|
||||
kodiMovie = None
|
||||
for kodimovie in allKodiMovies:
|
||||
|
@ -128,12 +129,12 @@ class LibrarySync():
|
|||
if kodiMovie[2] != API().getChecksum(item):
|
||||
WriteKodiDB().addOrUpdateMovieToKodiLibrary(item["Id"],connection, cursor, view.get('title'))
|
||||
|
||||
#### PROCESS DELETES #####
|
||||
allEmbyMovieIds = set(allEmbyMovieIds)
|
||||
for kodiId in allKodiMovieIds:
|
||||
if not kodiId in allEmbyMovieIds:
|
||||
WINDOW.setProperty(kodiId,"deleted")
|
||||
WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor)
|
||||
#### PROCESS DELETES #####
|
||||
allEmbyMovieIds = set(allEmbyMovieIds)
|
||||
for kodiId in allKodiMovieIds:
|
||||
if not kodiId in allEmbyMovieIds:
|
||||
WINDOW.setProperty(kodiId,"deleted")
|
||||
WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor)
|
||||
|
||||
|
||||
def TvShowsFullSync(self,connection,cursor,pDialog):
|
||||
|
@ -164,7 +165,7 @@ class LibrarySync():
|
|||
if(pDialog != None):
|
||||
progressTitle = "Processing " + view.get('title') + " (" + str(count) + " of " + str(total) + ")"
|
||||
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
|
||||
kodiShow = None
|
||||
|
@ -184,12 +185,12 @@ class LibrarySync():
|
|||
#### PROCESS EPISODES ######
|
||||
self.EpisodesFullSync(connection,cursor,item["Id"], kodiId)
|
||||
|
||||
#### TVSHOW: PROCESS DELETES #####
|
||||
allEmbyTvShowIds = set(allEmbyTvShowIds)
|
||||
for kodiId in allKodiTvShowIds:
|
||||
if not kodiId in allEmbyTvShowIds:
|
||||
WINDOW.setProperty(kodiId,"deleted")
|
||||
WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor)
|
||||
#### TVSHOW: PROCESS DELETES #####
|
||||
allEmbyTvShowIds = set(allEmbyTvShowIds)
|
||||
for kodiId in allKodiTvShowIds:
|
||||
if not kodiId in allEmbyTvShowIds:
|
||||
WINDOW.setProperty(kodiId,"deleted")
|
||||
WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor)
|
||||
|
||||
|
||||
def EpisodesFullSync(self,connection,cursor,embyShowId, kodiShowId):
|
||||
|
@ -241,43 +242,46 @@ class LibrarySync():
|
|||
connection = utils.KodiSQL()
|
||||
cursor = connection.cursor()
|
||||
|
||||
#### PROCESS MOVIES ####
|
||||
views = ReadEmbyDB().getCollections("movies")
|
||||
for view in views:
|
||||
allEmbyMovies = ReadEmbyDB().getMovies(view.get('id'), itemList)
|
||||
for item in allEmbyMovies:
|
||||
try:
|
||||
#### PROCESS MOVIES ####
|
||||
views = ReadEmbyDB().getCollections("movies")
|
||||
for view in views:
|
||||
allEmbyMovies = ReadEmbyDB().getMovies(view.get('id'), itemList)
|
||||
for item in allEmbyMovies:
|
||||
|
||||
if not item.get('IsFolder'):
|
||||
WriteKodiDB().addOrUpdateMovieToKodiLibrary(item["Id"],connection, cursor, view.get('title'))
|
||||
if not item.get('IsFolder'):
|
||||
WriteKodiDB().addOrUpdateMovieToKodiLibrary(item["Id"],connection, cursor, view.get('title'))
|
||||
|
||||
#### PROCESS TV SHOWS ####
|
||||
views = ReadEmbyDB().getCollections("tvshows")
|
||||
for view in views:
|
||||
allEmbyTvShows = ReadEmbyDB().getTvShows(view.get('id'),itemList)
|
||||
for item in allEmbyTvShows:
|
||||
if item.get('IsFolder') and item.get('RecursiveItemCount') != 0:
|
||||
kodiId = WriteKodiDB().addOrUpdateTvShowToKodiLibrary(item["Id"],connection, cursor, view.get('title'))
|
||||
#### PROCESS TV SHOWS ####
|
||||
views = ReadEmbyDB().getCollections("tvshows")
|
||||
for view in views:
|
||||
allEmbyTvShows = ReadEmbyDB().getTvShows(view.get('id'),itemList)
|
||||
for item in allEmbyTvShows:
|
||||
if item.get('IsFolder') and item.get('RecursiveItemCount') != 0:
|
||||
kodiId = WriteKodiDB().addOrUpdateTvShowToKodiLibrary(item["Id"],connection, cursor, view.get('title'))
|
||||
|
||||
#### PROCESS EPISODES ######
|
||||
for item in itemList:
|
||||
#### PROCESS EPISODES ######
|
||||
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
|
||||
cursor.execute("SELECT kodi_id FROM emby WHERE media_type='tvshow' AND emby_id=?", (MBitem["SeriesId"],))
|
||||
result = cursor.fetchall()
|
||||
if result:
|
||||
kodi_show_id = result[0]
|
||||
else:
|
||||
kodi_show_id = None
|
||||
print "show id not found!"
|
||||
|
||||
#get the tv show
|
||||
cursor.execute("SELECT kodi_id FROM emby WHERE media_type='tvshow' AND emby_id=?", (MBitem["SeriesId"],))
|
||||
result = cursor.fetchall()
|
||||
if result:
|
||||
kodi_show_id = result[0]
|
||||
else:
|
||||
kodi_show_id = None
|
||||
if kodi_show_id:
|
||||
WriteKodiDB().addOrUpdateEpisodeToKodiLibrary(item["Id"], kodi_show_id, connection, cursor)
|
||||
finally:
|
||||
cursor.close()
|
||||
|
||||
if kodi_show_id:
|
||||
WriteKodiDB().addOrUpdateEpisodeToKodiLibrary(item["Id"], kodi_show_id, connection, cursor)
|
||||
|
||||
|
||||
cursor.close()
|
||||
#close the progress dialog
|
||||
if(pDialog != None):
|
||||
pDialog.close()
|
||||
|
||||
|
|
|
@ -148,6 +148,9 @@ class WriteKodiDB():
|
|||
|
||||
##### ADD THE MOVIE ############
|
||||
if movieid == None:
|
||||
|
||||
utils.logMsg("ADD movie to Kodi library","Id: %s - Title: %s" % (embyId, title))
|
||||
|
||||
#create the movie
|
||||
cursor.execute("select coalesce(max(idMovie),0) as movieid from movie")
|
||||
movieid = cursor.fetchone()[0]
|
||||
|
@ -167,6 +170,7 @@ class WriteKodiDB():
|
|||
|
||||
#### UPDATE THE MOVIE #####
|
||||
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 = ?"
|
||||
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 ##############
|
||||
if showid == None:
|
||||
|
||||
utils.logMsg("ADD tvshow to Kodi library","Id: %s - Title: %s" % (embyId, title))
|
||||
|
||||
#create the tv show path
|
||||
cursor.execute("select coalesce(max(idPath),0) as pathid from path")
|
||||
pathid = cursor.fetchone()[0]
|
||||
|
@ -293,6 +299,8 @@ class WriteKodiDB():
|
|||
|
||||
#### UPDATE THE TV SHOW #############
|
||||
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 = ?"
|
||||
cursor.execute(pathsql, (title, plot, rating, premieredate, title, genre, mpaa, studio, sorttitle, showid))
|
||||
|
||||
|
@ -496,7 +504,7 @@ class WriteKodiDB():
|
|||
|
||||
# ADD EPISODE TO KODI
|
||||
if episodeid == None:
|
||||
|
||||
utils.logMsg("ADD episode to Kodi library","Id: %s - Title: %s" % (embyId, title))
|
||||
#create the episode
|
||||
cursor.execute("select coalesce(max(idEpisode),0) as episodeid from episode")
|
||||
episodeid = cursor.fetchone()[0]
|
||||
|
@ -513,6 +521,8 @@ class WriteKodiDB():
|
|||
|
||||
# UPDATE THE EPISODE IN KODI (for now, we just send in all data)
|
||||
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 = ?"
|
||||
cursor.execute(pathsql, (title, plot, rating, writer, premieredate, runtime, director, season, episode, title, "-1", "-1", episodeid))
|
||||
|
||||
|
|
Loading…
Reference in a new issue