Dedicated DB method to add video uniqueid

This commit is contained in:
croneter 2018-11-20 18:24:43 +01:00
parent 70a6ee5ed6
commit 0f740b1a02
2 changed files with 6 additions and 4 deletions

View file

@ -126,8 +126,7 @@ class Movie(ItemBase):
rating,
api.votecount())
if api.provider('imdb') is not None:
uniqueid = self.kodidb.get_uniqueid(kodi_id,
v.KODI_TYPE_MOVIE)
uniqueid = self.kodidb.add_uniqueid()
self.kodidb.add_uniqueid(uniqueid,
kodi_id,
v.KODI_TYPE_MOVIE,

View file

@ -755,6 +755,10 @@ class KodiVideoDB(common.KodiDBBase):
VALUES (?, ?, ?, ?, ?)
''', (args))
def add_uniqueid(self):
self.cursor.execute('SELECT COALESCE(MAX(uniqueid_id), 0) FROM uniqueid')
return self.cursor.fetchone()[0] + 1
def get_uniqueid(self, kodi_id, kodi_type):
"""
Returns the uniqueid_id
@ -764,8 +768,7 @@ class KodiVideoDB(common.KodiDBBase):
try:
return self.cursor.fetchone()[0]
except TypeError:
self.cursor.execute('SELECT COALESCE(MAX(uniqueid_id),0) FROM uniqueid')
return self.cursor.fetchone()[0] + 1
return self.add_uniqueid()
def update_uniqueid(self, *args):
"""