mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 02:36:10 +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
|
@ -436,16 +436,6 @@ class LibrarySync():
|
|||
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
|
||||
|
||||
if episodeData != None:
|
||||
|
||||
if(self.ShouldStop(pDialog)):
|
||||
|
@ -457,31 +447,10 @@ 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):
|
||||
#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
|
||||
|
||||
# update progress bar
|
||||
if(pDialog != None):
|
||||
|
|
|
@ -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 ):
|
||||
|
|
Loading…
Reference in a new issue