Dedicated DB method to add video rating_id

This commit is contained in:
croneter 2018-11-20 18:18:52 +01:00
parent 3acaad5663
commit 70a6ee5ed6
2 changed files with 6 additions and 4 deletions

View file

@ -118,8 +118,7 @@ class Movie(ItemBase):
file_id = self.kodidb.add_file(filename,
kodi_pathid,
api.date_created())
rating_id = self.kodidb.get_ratingid(kodi_id,
v.KODI_TYPE_MOVIE)
rating_id = self.kodidb.add_ratingid()
self.kodidb.add_ratings(rating_id,
kodi_id,
v.KODI_TYPE_MOVIE,

View file

@ -784,6 +784,10 @@ class KodiVideoDB(common.KodiDBBase):
self.cursor.execute('DELETE FROM uniqueid WHERE media_id = ? AND media_type = ?',
(kodi_id, kodi_type))
def add_ratingid(self):
self.cursor.execute('SELECT COALESCE(MAX(rating_id),0) FROM rating')
return self.cursor.fetchone()[0] + 1
def get_ratingid(self, kodi_id, kodi_type):
"""
Create if needed and return the unique rating_id from rating table
@ -793,8 +797,7 @@ class KodiVideoDB(common.KodiDBBase):
try:
return self.cursor.fetchone()[0]
except TypeError:
self.cursor.execute('SELECT COALESCE(MAX(rating_id),0) FROM rating')
return self.cursor.fetchone()[0] + 1
return self.add_ratingid()
def update_ratings(self, *args):
"""