From 70a6ee5ed68be072a97e6d7fd27f7449c14de799 Mon Sep 17 00:00:00 2001 From: croneter Date: Tue, 20 Nov 2018 18:18:52 +0100 Subject: [PATCH] Dedicated DB method to add video rating_id --- resources/lib/itemtypes/movies.py | 3 +-- resources/lib/kodi_db/video.py | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) 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): """