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, rating,
api.votecount()) api.votecount())
if api.provider('imdb') is not None: if api.provider('imdb') is not None:
uniqueid = self.kodidb.get_uniqueid(kodi_id, uniqueid = self.kodidb.add_uniqueid()
v.KODI_TYPE_MOVIE)
self.kodidb.add_uniqueid(uniqueid, self.kodidb.add_uniqueid(uniqueid,
kodi_id, kodi_id,
v.KODI_TYPE_MOVIE, v.KODI_TYPE_MOVIE,

View file

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