Fix getting the rating id

This commit is contained in:
tomkat83 2017-02-13 20:23:02 +01:00
parent aa5cb37a8f
commit 9612ee78ab
2 changed files with 11 additions and 6 deletions

View file

@ -314,7 +314,8 @@ class Movies(Items):
# Update the movie entry
if v.KODIVERSION >= 17:
# update new ratings Kodi 17
ratingid = self.kodi_db.get_ratingid(movieid)
ratingid = self.kodi_db.get_ratingid(movieid,
v.KODI_TYPE_MOVIE)
self.kodi_db.update_ratings(movieid,
v.KODI_TYPE_MOVIE,
"default",
@ -596,7 +597,7 @@ class TVShows(Items):
% (itemid, title))
if v.KODIVERSION >= 17:
# update new ratings Kodi 17
ratingid = self.kodi_db.get_ratingid(showid)
ratingid = self.kodi_db.get_ratingid(showid, v.KODI_TYPE_SHOW)
self.kodi_db.update_ratings(showid,
v.KODI_TYPE_SHOW,
"default",
@ -917,7 +918,8 @@ class TVShows(Items):
# Update the movie entry
if v.KODIVERSION >= 17:
# update new ratings Kodi 17
ratingid = self.kodi_db.get_ratingid(episodeid)
ratingid = self.kodi_db.get_ratingid(episodeid,
v.KODI_TYPE_EPISODE)
self.kodi_db.update_ratings(episodeid,
v.KODI_TYPE_EPISODE,
"default",

View file

@ -1465,9 +1465,12 @@ class Kodidb_Functions():
self.cursor.execute("select coalesce(max(rating_id),0) from rating")
return self.cursor.fetchone()[0] + 1
def get_ratingid(self, media_id):
query = "SELECT rating_id FROM rating WHERE media_id = ?"
self.cursor.execute(query, (media_id,))
def get_ratingid(self, kodi_id, kodi_type):
query = '''
SELECT rating_id FROM rating
WHERE media_id = ? AND media_type = ?
'''
self.cursor.execute(query, (kodi_id, kodi_type))
try:
ratingid = self.cursor.fetchone()[0]
except TypeError: