mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
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
|
@ -435,17 +435,7 @@ class LibrarySync():
|
|||
# do episode adds
|
||||
for tvshow in viewTVShows:
|
||||
|
||||
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
|
||||
|
||||
episodeData = ReadEmbyDB().getEpisodes(tvshow,True)
|
||||
if episodeData != None:
|
||||
|
||||
if(self.ShouldStop(pDialog)):
|
||||
|
@ -457,32 +447,11 @@ class LibrarySync():
|
|||
total = len(episodeData) + 1
|
||||
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:
|
||||
if(installFirstRun):
|
||||
progressAction = "Adding"
|
||||
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
|
||||
|
||||
#if(installFirstRun):
|
||||
progressAction = "Adding"
|
||||
WriteKodiDB().addEpisodeToKodiLibrary(item, connection, cursor)
|
||||
|
||||
# update progress bar
|
||||
if(pDialog != None):
|
||||
percentage = int(((float(count) / float(total)) * 100))
|
||||
|
|
|
@ -210,7 +210,7 @@ class WebSocketThread(threading.Thread):
|
|||
connection = utils.KodiSQL()
|
||||
cursor = connection.cursor()
|
||||
LibrarySync().MoviesSync(connection, cursor, fullsync = False, installFirstRun = False, itemList = itemsToUpdate)
|
||||
LibrarySync().TvShowsSync(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):
|
||||
|
|
|
@ -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
|
||||
#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')
|
||||
port = addon.getSetting('port')
|
||||
host = addon.getSetting('ipaddress')
|
||||
server = host + ":" + port
|
||||
downloadUtils = DownloadUtils()
|
||||
userid = downloadUtils.getUserId()
|
||||
#downloadUtils = DownloadUtils()
|
||||
#userid = downloadUtils.getUserId()
|
||||
|
||||
timeInfo = API().getTimeInfo(MBitem)
|
||||
userData=API().getUserData(MBitem)
|
||||
|
@ -943,9 +950,9 @@ class WriteKodiDB():
|
|||
|
||||
try:
|
||||
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:
|
||||
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
|
||||
|
||||
def deleteMovieFromKodiLibrary(self, id ):
|
||||
|
@ -1097,7 +1104,7 @@ class WriteKodiDB():
|
|||
cursor.execute("INSERT into art(media_id, media_type, type, url) values(?, ?, ?, ?)", (seasonid,"season","banner",API().getArtwork(season, "Banner")))
|
||||
|
||||
connection.commit()
|
||||
#cursor.close()
|
||||
#cursor.close()
|
||||
|
||||
def setKodiResumePoint(self, id, resume_seconds, total_seconds, fileType):
|
||||
#use sqlite to set the resume point while json api doesn't support this yet
|
||||
|
@ -1286,7 +1293,7 @@ class WriteKodiDB():
|
|||
cursor.execute(peoplesql, (actorid,id,Role,None))
|
||||
|
||||
connection.commit()
|
||||
#cursor.close()
|
||||
#cursor.close()
|
||||
|
||||
return True
|
||||
|
||||
|
|
Loading…
Reference in a new issue