mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 18:26:15 +00:00
Rework people sync to avoid exception program flow
This commit is contained in:
parent
a78ab1377c
commit
2d60480df3
1 changed files with 11 additions and 10 deletions
|
@ -163,21 +163,22 @@ class Kodi(object):
|
||||||
return self.cursor.lastrowid
|
return self.cursor.lastrowid
|
||||||
|
|
||||||
def _get_person(self, *args):
|
def _get_person(self, *args):
|
||||||
try:
|
'''Retrieve person from the database, or add them if they don't exist
|
||||||
|
'''
|
||||||
|
resp = self.cursor.execute(QU.get_person, args).fetchone()
|
||||||
|
if len(resp) > 0:
|
||||||
|
return resp[0]
|
||||||
|
else:
|
||||||
return self.add_person(*args)
|
return self.add_person(*args)
|
||||||
except IntegrityError:
|
|
||||||
# The person already exists in the database
|
|
||||||
# Now we can do the expensive operation of fetching the id
|
|
||||||
self.cursor.execute(QU.get_person, args)
|
|
||||||
return self.cursor.fetchone()[0]
|
|
||||||
|
|
||||||
def get_person(self, *args):
|
def get_person(self, *args):
|
||||||
try:
|
'''Retrieve person from cache, else forward to db query
|
||||||
return self._people_cache[args]
|
'''
|
||||||
except KeyError:
|
person_id = self._people_cache.get(args)
|
||||||
|
if not person_id:
|
||||||
person_id = self._get_person(*args)
|
person_id = self._get_person(*args)
|
||||||
self._people_cache[args] = person_id
|
self._people_cache[args] = person_id
|
||||||
return person_id
|
return person_id
|
||||||
|
|
||||||
def add_genres(self, genres, *args):
|
def add_genres(self, genres, *args):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue