mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
use a map for movie to make to lookup easier and faster
This commit is contained in:
parent
d1aabaf803
commit
5dd145a8e8
2 changed files with 26 additions and 24 deletions
|
@ -159,10 +159,9 @@ class LibrarySync():
|
|||
item['Tag'] = []
|
||||
item['Tag'].append(view.get('title'))
|
||||
|
||||
for kodimovie in allKodiMovies:
|
||||
if item["Id"] in kodimovie["file"]:
|
||||
kodimovie = allKodiMovies.get(item["Id"], None)
|
||||
if(kodimovie != None):
|
||||
WriteKodiDB().updateMovieToKodiLibrary(item,kodimovie)
|
||||
break
|
||||
|
||||
if(self.ShouldStop()):
|
||||
return True
|
||||
|
@ -542,14 +541,11 @@ class LibrarySync():
|
|||
for item in allMB3Movies:
|
||||
|
||||
if not item.get('IsFolder'):
|
||||
kodiItem = None
|
||||
for kodimovie in allKodiMovies:
|
||||
if item["Id"] in kodimovie["file"]:
|
||||
kodiItem = kodimovie
|
||||
break
|
||||
kodiItem = allKodiMovies.get(item["Id"], None)
|
||||
|
||||
userData=API().getUserData(item)
|
||||
userData = API().getUserData(item)
|
||||
timeInfo = API().getTimeInfo(item)
|
||||
|
||||
if kodiItem != None:
|
||||
WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")),"movie")
|
||||
kodiresume = int(round(kodiItem['resume'].get("position")))
|
||||
|
|
|
@ -49,22 +49,28 @@ class ReadKodiDB():
|
|||
if(result.has_key('movies')):
|
||||
movies = result['movies']
|
||||
|
||||
return movies
|
||||
kodiMovieMap = None
|
||||
if(movies != None and len(movies) > 0):
|
||||
kodiMovieMap = {}
|
||||
for kodimovie in movies:
|
||||
key = kodimovie["file"][-37:-5] #extract the id from the file name
|
||||
kodiMovieMap[key] = kodimovie
|
||||
|
||||
return kodiMovieMap
|
||||
|
||||
def getKodiMoviesIds(self,returnMB3Ids = False):
|
||||
# returns a list of movieIds or MB3 Id's from all movies currently in the Kodi library
|
||||
allKodiMovies = self.getKodiMovies(False)
|
||||
allKodiMovieIds = list()
|
||||
|
||||
if allKodiMovies != None:
|
||||
for kodimovie in allKodiMovies:
|
||||
if returnMB3Ids:
|
||||
filepath = kodimovie["file"]
|
||||
filepath = filepath.replace(movieLibrary + os.sep, "")
|
||||
filepath = filepath.replace(".strm", "")
|
||||
filepath = filepath.split(os.sep)[0]
|
||||
id = filepath
|
||||
if(allKodiMovies == None):
|
||||
return list()
|
||||
|
||||
if(returnMB3Ids):
|
||||
allKodiMovieIds = list(allKodiMovies.keys())
|
||||
return allKodiMovieIds
|
||||
else:
|
||||
allKodiMovieIds = list()
|
||||
for kodimovie in allKodiMovies.values():
|
||||
id = str(kodimovie["movieid"])
|
||||
allKodiMovieIds.append(id)
|
||||
|
||||
|
|
Loading…
Reference in a new issue