diff --git a/resources/lib/itemtypes/movies.py b/resources/lib/itemtypes/movies.py index 7b635e18..2c9655a9 100644 --- a/resources/lib/itemtypes/movies.py +++ b/resources/lib/itemtypes/movies.py @@ -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, diff --git a/resources/lib/kodi_db/video.py b/resources/lib/kodi_db/video.py index 87f34168..bb7abe33 100644 --- a/resources/lib/kodi_db/video.py +++ b/resources/lib/kodi_db/video.py @@ -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): """