mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2025-11-10 18:36:33 +00:00
Added local cache of people
Prevent any access to the people database unless a person must be added.
This commit is contained in:
parent
71b88ba7dc
commit
4a4318c1ed
2 changed files with 16 additions and 1 deletions
|
|
@ -22,6 +22,9 @@ class Kodi(object):
|
|||
def __init__(self):
|
||||
self.artwork = artwork.Artwork(self.cursor)
|
||||
|
||||
self.cursor.execute(QU.get_all_people)
|
||||
self._people_cache = dict(self.cursor.fetchall())
|
||||
|
||||
def create_entry_path(self):
|
||||
self.cursor.execute(QU.create_path)
|
||||
|
||||
|
|
@ -156,7 +159,7 @@ class Kodi(object):
|
|||
|
||||
return person_id
|
||||
|
||||
def get_person(self, *args):
|
||||
def _get_person(self, *args):
|
||||
try:
|
||||
return self.add_person(*args)
|
||||
except IntegrityError:
|
||||
|
|
@ -165,6 +168,14 @@ class Kodi(object):
|
|||
self.cursor.execute(QU.get_person, args)
|
||||
return self.cursor.fetchone()[0]
|
||||
|
||||
def get_person(self, *args):
|
||||
try:
|
||||
return self._people_cache[args]
|
||||
except KeyError:
|
||||
person_id = self._get_person(*args)
|
||||
self._people_cache[args] = person_id
|
||||
return person_id
|
||||
|
||||
def add_genres(self, genres, *args):
|
||||
|
||||
''' Delete current genres first for clean slate.
|
||||
|
|
|
|||
|
|
@ -88,6 +88,10 @@ SELECT strFilename
|
|||
FROM files
|
||||
WHERE idFile = ?
|
||||
"""
|
||||
get_all_people = """
|
||||
SELECT name, actor_id
|
||||
FROM actor
|
||||
"""
|
||||
get_person = """
|
||||
SELECT actor_id
|
||||
FROM actor
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue