mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 02:36:10 +00:00
remove some of the for loops searches, use a map for lookups
Do a full sync on all items for playcount
This commit is contained in:
parent
a0099a69db
commit
ad1d1d80cc
2 changed files with 25 additions and 35 deletions
|
@ -244,11 +244,9 @@ class LibrarySync():
|
||||||
comparestring1 = str(episode.get("ParentIndexNumber")) + "-" + str(episode.get("IndexNumber"))
|
comparestring1 = str(episode.get("ParentIndexNumber")) + "-" + str(episode.get("IndexNumber"))
|
||||||
matchFound = False
|
matchFound = False
|
||||||
if kodiEpisodes != None:
|
if kodiEpisodes != None:
|
||||||
for KodiItem in kodiEpisodes:
|
KodiItem = kodiEpisodes.get(comparestring1, None)
|
||||||
comparestring2 = str(KodiItem["season"]) + "-" + str(KodiItem["episode"])
|
if(KodiItem != None):
|
||||||
if comparestring1 == comparestring2:
|
|
||||||
matchFound = True
|
matchFound = True
|
||||||
break
|
|
||||||
|
|
||||||
if not matchFound:
|
if not matchFound:
|
||||||
#no match so we have to create it
|
#no match so we have to create it
|
||||||
|
@ -287,13 +285,10 @@ class LibrarySync():
|
||||||
comparestring1 = str(episode.get("ParentIndexNumber")) + "-" + str(episode.get("IndexNumber"))
|
comparestring1 = str(episode.get("ParentIndexNumber")) + "-" + str(episode.get("IndexNumber"))
|
||||||
|
|
||||||
if kodiEpisodes != None:
|
if kodiEpisodes != None:
|
||||||
for KodiItem in kodiEpisodes:
|
KodiItem = kodiEpisodes.get(comparestring1, None)
|
||||||
comparestring2 = str(KodiItem["season"]) + "-" + str(KodiItem["episode"])
|
if(KodiItem != None):
|
||||||
if comparestring1 == comparestring2:
|
|
||||||
#match found - update episode
|
|
||||||
WriteKodiDB().updateEpisodeToKodiLibrary(episode, KodiItem)
|
WriteKodiDB().updateEpisodeToKodiLibrary(episode, KodiItem)
|
||||||
|
|
||||||
|
|
||||||
if(self.ShouldStop()):
|
if(self.ShouldStop()):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -385,14 +380,9 @@ class LibrarySync():
|
||||||
comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber"))
|
comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber"))
|
||||||
matchFound = False
|
matchFound = False
|
||||||
if kodiEpisodes != None:
|
if kodiEpisodes != None:
|
||||||
for KodiItem in kodiEpisodes:
|
KodiItem = kodiEpisodes.get(comparestring1, None)
|
||||||
allEpisodes.append(KodiItem["episodeid"])
|
if(KodiItem != None):
|
||||||
comparestring2 = str(KodiItem["season"]) + "-" + str(KodiItem["episode"])
|
|
||||||
if comparestring1 == comparestring2:
|
|
||||||
#match found - update episode
|
|
||||||
WriteKodiDB().updateEpisodeToKodiLibrary(item,KodiItem)
|
|
||||||
matchFound = True
|
matchFound = True
|
||||||
break
|
|
||||||
|
|
||||||
if not matchFound:
|
if not matchFound:
|
||||||
#no match so we have to create it
|
#no match so we have to create it
|
||||||
|
@ -442,13 +432,9 @@ class LibrarySync():
|
||||||
comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber"))
|
comparestring1 = str(item.get("ParentIndexNumber")) + "-" + str(item.get("IndexNumber"))
|
||||||
matchFound = False
|
matchFound = False
|
||||||
if kodiEpisodes != None:
|
if kodiEpisodes != None:
|
||||||
for KodiItem in kodiEpisodes:
|
KodiItem = kodiEpisodes.get(comparestring1, None)
|
||||||
allEpisodes.append(KodiItem["episodeid"])
|
if(KodiItem != None):
|
||||||
comparestring2 = str(KodiItem["season"]) + "-" + str(KodiItem["episode"])
|
|
||||||
if comparestring1 == comparestring2:
|
|
||||||
#match found - update episode
|
|
||||||
WriteKodiDB().updateEpisodeToKodiLibrary(item, KodiItem)
|
WriteKodiDB().updateEpisodeToKodiLibrary(item, KodiItem)
|
||||||
break
|
|
||||||
|
|
||||||
if(self.ShouldStop()):
|
if(self.ShouldStop()):
|
||||||
return True
|
return True
|
||||||
|
@ -530,7 +516,7 @@ class LibrarySync():
|
||||||
viewCount = len(views)
|
viewCount = len(views)
|
||||||
viewCurrent = 1
|
viewCurrent = 1
|
||||||
for view in views:
|
for view in views:
|
||||||
allMB3Movies = ReadEmbyDB().getMovies(view.get('id'),False)
|
allMB3Movies = ReadEmbyDB().getMovies(view.get('id'),True)
|
||||||
allKodiMovies = ReadKodiDB().getKodiMovies(False)
|
allKodiMovies = ReadKodiDB().getKodiMovies(False)
|
||||||
|
|
||||||
if(self.ShouldStop()):
|
if(self.ShouldStop()):
|
||||||
|
@ -579,7 +565,7 @@ class LibrarySync():
|
||||||
|
|
||||||
#process Tv shows
|
#process Tv shows
|
||||||
if processTvShows:
|
if processTvShows:
|
||||||
tvshowData = ReadEmbyDB().getTVShows(False)
|
tvshowData = ReadEmbyDB().getTVShows(True)
|
||||||
|
|
||||||
if(self.ShouldStop()):
|
if(self.ShouldStop()):
|
||||||
return True
|
return True
|
||||||
|
@ -607,11 +593,7 @@ class LibrarySync():
|
||||||
comparestring1 = str(episode.get("ParentIndexNumber")) + "-" + str(episode.get("IndexNumber"))
|
comparestring1 = str(episode.get("ParentIndexNumber")) + "-" + str(episode.get("IndexNumber"))
|
||||||
matchFound = False
|
matchFound = False
|
||||||
if kodiEpisodes != None:
|
if kodiEpisodes != None:
|
||||||
for KodiEpisode in kodiEpisodes:
|
kodiItem = kodiEpisodes.get(comparestring1, None)
|
||||||
comparestring2 = str(KodiEpisode["season"]) + "-" + str(KodiEpisode["episode"])
|
|
||||||
if comparestring1 == comparestring2:
|
|
||||||
kodiItem = KodiEpisode
|
|
||||||
break
|
|
||||||
|
|
||||||
userData=API().getUserData(episode)
|
userData=API().getUserData(episode)
|
||||||
timeInfo = API().getTimeInfo(episode)
|
timeInfo = API().getTimeInfo(episode)
|
||||||
|
|
|
@ -141,7 +141,15 @@ class ReadKodiDB():
|
||||||
result = jsonobject['result']
|
result = jsonobject['result']
|
||||||
if(result.has_key('episodes')):
|
if(result.has_key('episodes')):
|
||||||
episodes = result['episodes']
|
episodes = result['episodes']
|
||||||
return episodes
|
|
||||||
|
episodeMap = None
|
||||||
|
if(episodes != None):
|
||||||
|
episodeMap = {}
|
||||||
|
for KodiItem in episodes:
|
||||||
|
key = str(KodiItem["season"]) + "-" + str(KodiItem["episode"])
|
||||||
|
episodeMap[key] = KodiItem
|
||||||
|
|
||||||
|
return episodeMap
|
||||||
|
|
||||||
def getKodiEpisodeByMbItem(self, MBitem):
|
def getKodiEpisodeByMbItem(self, MBitem):
|
||||||
xbmc.sleep(sleepVal)
|
xbmc.sleep(sleepVal)
|
||||||
|
|
Loading…
Reference in a new issue