From 0f740b1a02981da850e9156d28848aedd24c2024 Mon Sep 17 00:00:00 2001 From: croneter Date: Tue, 20 Nov 2018 18:24:43 +0100 Subject: [PATCH] Dedicated DB method to add video uniqueid --- 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 2c9655a9..1a49da2f 100644 --- a/resources/lib/itemtypes/movies.py +++ b/resources/lib/itemtypes/movies.py @@ -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, diff --git a/resources/lib/kodi_db/video.py b/resources/lib/kodi_db/video.py index bb7abe33..19257e54 100644 --- a/resources/lib/kodi_db/video.py +++ b/resources/lib/kodi_db/video.py @@ -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): """