use uniqueid to check of en episode is already in the DB
This commit is contained in:
parent
9ce5bbf27a
commit
85482119a0
3 changed files with 19 additions and 43 deletions
|
@ -436,16 +436,6 @@ class LibrarySync():
|
||||||
for tvshow in viewTVShows:
|
for tvshow in viewTVShows:
|
||||||
|
|
||||||
episodeData = ReadEmbyDB().getEpisodes(tvshow,True)
|
episodeData = ReadEmbyDB().getEpisodes(tvshow,True)
|
||||||
allKodiTVShows = ReadKodiDB().getKodiTvShows(False)
|
|
||||||
if allKodiTVShows != None:
|
|
||||||
kodishow = allKodiTVShows.get(tvshow,None)
|
|
||||||
if kodishow != None:
|
|
||||||
kodiEpisodes = ReadKodiDB().getKodiEpisodes(kodishow["tvshowid"],True,True)
|
|
||||||
else:
|
|
||||||
kodiEpisodes = None
|
|
||||||
else:
|
|
||||||
kodiEpisodes = None
|
|
||||||
|
|
||||||
if episodeData != None:
|
if episodeData != None:
|
||||||
|
|
||||||
if(self.ShouldStop(pDialog)):
|
if(self.ShouldStop(pDialog)):
|
||||||
|
@ -457,31 +447,10 @@ class LibrarySync():
|
||||||
total = len(episodeData) + 1
|
total = len(episodeData) + 1
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
#we have to compare the lists somehow
|
|
||||||
# TODO --> instead of matching by season and episode number we can use the uniqueid
|
|
||||||
for item in episodeData:
|
for item in episodeData:
|
||||||
if(installFirstRun):
|
#if(installFirstRun):
|
||||||
progressAction = "Adding"
|
progressAction = "Adding"
|
||||||
WriteKodiDB().addEpisodeToKodiLibrary(item, connection, cursor)
|
WriteKodiDB().addEpisodeToKodiLibrary(item, connection, cursor)
|
||||||
else:
|
|
||||||
comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber"))
|
|
||||||
matchFound = False
|
|
||||||
if kodiEpisodes != None:
|
|
||||||
KodiItem = kodiEpisodes.get(comparestring1, None)
|
|
||||||
if(KodiItem != None):
|
|
||||||
matchFound = True
|
|
||||||
|
|
||||||
progressAction = "Checking"
|
|
||||||
if not matchFound:
|
|
||||||
#double check the item it might me added delayed by the Kodi scanner
|
|
||||||
if ReadKodiDB().getKodiEpisodeByMbItem(item["Id"],tvshow) == None:
|
|
||||||
#no match so we have to create it
|
|
||||||
WriteKodiDB().addEpisodeToKodiLibrary(item,connection, cursor)
|
|
||||||
progressAction = "Adding"
|
|
||||||
totalItemsAdded += 1
|
|
||||||
|
|
||||||
if(self.ShouldStop(pDialog)):
|
|
||||||
return False
|
|
||||||
|
|
||||||
# update progress bar
|
# update progress bar
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
|
|
|
@ -844,12 +844,19 @@ class WriteKodiDB():
|
||||||
#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
|
||||||
|
|
||||||
|
# first check the episode is not already in the DB using the Emby ID which is stored in c20
|
||||||
|
cursor.execute("SELECT idEpisode FROM episode WHERE c20 = ?",(MBitem["Id"],))
|
||||||
|
result = cursor.fetchone()
|
||||||
|
if result != None:
|
||||||
|
utils.logMsg("Emby", "TV Show already exists in DB : " + MBitem["Id"] + " - " + MBitem["Name"])
|
||||||
|
return
|
||||||
|
|
||||||
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')
|
||||||
server = host + ":" + port
|
server = host + ":" + port
|
||||||
downloadUtils = DownloadUtils()
|
#downloadUtils = DownloadUtils()
|
||||||
userid = downloadUtils.getUserId()
|
#userid = downloadUtils.getUserId()
|
||||||
|
|
||||||
timeInfo = API().getTimeInfo(MBitem)
|
timeInfo = API().getTimeInfo(MBitem)
|
||||||
userData=API().getUserData(MBitem)
|
userData=API().getUserData(MBitem)
|
||||||
|
@ -943,9 +950,9 @@ class WriteKodiDB():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
connection.commit()
|
connection.commit()
|
||||||
utils.logMsg("Emby","Added TV Show to Kodi Library",MBitem["Id"] + " - " + MBitem["Name"])
|
utils.logMsg("Emby","Added TV Show to Kodi Library" + MBitem["Id"] + " - " + MBitem["Name"])
|
||||||
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
|
||||||
|
|
||||||
def deleteMovieFromKodiLibrary(self, id ):
|
def deleteMovieFromKodiLibrary(self, id ):
|
||||||
|
|
Loading…
Reference in a new issue