fixed issue with episode sync

This commit is contained in:
Marcel van der Veldt 2015-05-02 14:57:43 +02:00
parent 6e9983edba
commit a05bdeb844
3 changed files with 15 additions and 6 deletions

View File

@ -174,15 +174,14 @@ class LibrarySync():
if kodiShow == None:
# Tv show doesn't exist in Kodi yet so proceed and add it
kodiId = WriteKodiDB().addOrUpdateTvShowToKodiLibrary(item["Id"],connection, cursor, view.get('title'))
WriteKodiDB().addOrUpdateTvShowToKodiLibrary(item["Id"],connection, cursor, view.get('title'))
else:
kodiId = kodishow[0]
# If there are changes to the item, perform a full sync of the item
if kodiShow[2] != API().getChecksum(item):
WriteKodiDB().addOrUpdateTvShowToKodiLibrary(item["Id"],connection, cursor, view.get('title'))
#### PROCESS EPISODES ######
self.EpisodesFullSync(connection,cursor,item["Id"], kodiId)
self.EpisodesFullSync(connection,cursor,item["Id"])
#### TVSHOW: PROCESS DELETES #####
allEmbyTvShowIds = set(allEmbyTvShowIds)
@ -192,14 +191,18 @@ class LibrarySync():
WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor)
def EpisodesFullSync(self,connection,cursor,embyShowId, kodiShowId):
def EpisodesFullSync(self,connection,cursor,showId):
WINDOW = xbmcgui.Window( 10000 )
allKodiEpisodeIds = list()
allEmbyEpisodeIds = list()
allEmbyEpisodes = ReadEmbyDB().getEpisodes(embyShowId)
#get the kodi parent id
cursor.execute("SELECT kodi_id FROM emby WHERE emby_id=?",(showId,))
kodiShowId = cursor.fetchone()[0]
allEmbyEpisodes = ReadEmbyDB().getEpisodes(showId)
allKodiEpisodes = ReadKodiDB().getKodiEpisodes(connection, cursor, kodiShowId)
for kodiepisode in allKodiEpisodes:
@ -222,6 +225,8 @@ class LibrarySync():
else:
# If there are changes to the item, perform a full sync of the item
if kodiEpisode[2] != API().getChecksum(item):
print "previous checksum--> " + kodiEpisode[2]
print "new checksum--> " + API().getChecksum(item)
WriteKodiDB().addOrUpdateEpisodeToKodiLibrary(item["Id"], kodiShowId, connection, cursor)
#### EPISODES: PROCESS DELETES #####

View File

@ -37,6 +37,7 @@ class ReadKodiDB():
cursor.execute("SELECT kodi_id, emby_id, checksum FROM emby WHERE media_type=?",("episode",))
else:
cursor.execute("SELECT kodi_id, emby_id, checksum FROM emby WHERE media_type=? AND parent_id=?",("episode", showid))
allepisodes = cursor.fetchall()
#this will return a list with tuples of all items returned from the database
return allepisodes

View File

@ -333,7 +333,6 @@ class WriteKodiDB():
#commit changes and return the id
connection.commit()
return showid
def addMusicVideoToKodiLibrary( self, MBitem, connection, cursor ):
@ -567,6 +566,10 @@ class WriteKodiDB():
if media_type == "musicvideo":
utils.logMsg("deleting musicvideo from Kodi library --> ",id)
cursor.execute("DELETE FROM musicvideo WHERE idMVideo = ?", (kodi_id,))
#delete the record in emby table
cursor.execute("DELETE FROM emby WHERE emby_id = ?", (id,))
connection.commit()
def updateSeasons(self,embyTvShowId, kodiTvShowId, connection, cursor):