Krypton: add ratings and IMDB id for movies
This commit is contained in:
parent
a45af3d253
commit
8acf07c607
2 changed files with 95 additions and 0 deletions
|
@ -268,6 +268,22 @@ class Movies(Items):
|
|||
|
||||
# Update the movie entry
|
||||
if KODIVERSION > 16:
|
||||
# update new ratings Kodi 17
|
||||
ratingid = self.kodi_db.get_ratingid(movieid)
|
||||
self.kodi_db.update_ratings(movieid,
|
||||
PF.KODI_TYPE_MOVIE,
|
||||
"default",
|
||||
rating,
|
||||
votecount,
|
||||
ratingid)
|
||||
# update new uniqueid Kodi 17
|
||||
uniqueid = self.kodi_db.get_uniqueid(movieid)
|
||||
self.kodi_db.update_uniqueid(movieid,
|
||||
PF.KODI_TYPE_MOVIE,
|
||||
imdb,
|
||||
"imdb",
|
||||
uniqueid)
|
||||
|
||||
query = ' '.join((
|
||||
"UPDATE movie",
|
||||
"SET c00 = ?, c01 = ?, c02 = ?, c03 = ?, c04 = ?, c05 = ?,"
|
||||
|
@ -299,6 +315,22 @@ class Movies(Items):
|
|||
else:
|
||||
log.info("ADD movie itemid: %s - Title: %s" % (itemid, title))
|
||||
if KODIVERSION > 16:
|
||||
# add new ratings Kodi 17
|
||||
ratingid = self.kodi_db.create_entry_rating()
|
||||
self.kodi_db.add_ratings(ratingid,
|
||||
movieid,
|
||||
PF.KODI_TYPE_MOVIE,
|
||||
"default",
|
||||
rating,
|
||||
votecount)
|
||||
# add new uniqueid Kodi 17
|
||||
uniqueid = self.kodi_db.create_entry_uniqueid()
|
||||
self.kodi_db.add_uniqueid(uniqueid,
|
||||
movieid,
|
||||
PF.KODI_TYPE_MOVIE,
|
||||
imdb,
|
||||
"imdb")
|
||||
|
||||
query = (
|
||||
'''
|
||||
INSERT INTO movie( idMovie, idFile, c00, c01, c02, c03,
|
||||
|
|
|
@ -1399,6 +1399,69 @@ class Kodidb_Functions():
|
|||
query = "INSERT OR REPLACE INTO song_genre(idGenre, idSong) values(?, ?)"
|
||||
self.cursor.execute(query, (genreid, kodiid))
|
||||
|
||||
# Krypton only stuff ##############################
|
||||
|
||||
def create_entry_uniqueid(self):
|
||||
self.cursor.execute(
|
||||
"select coalesce(max(uniqueid_id),0) from uniqueid")
|
||||
return self.cursor.fetchone()[0] + 1
|
||||
|
||||
def add_uniqueid(self, *args):
|
||||
"""
|
||||
Feed with:
|
||||
uniqueid_id, media_id, media_type, value, type
|
||||
|
||||
type: e.g. 'imdb'
|
||||
"""
|
||||
query = '''
|
||||
INSERT INTO uniqueid(
|
||||
uniqueid_id, media_id, media_type, value, type)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
'''
|
||||
self.cursor.execute(query, (args))
|
||||
|
||||
def create_entry_rating(self):
|
||||
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,))
|
||||
try:
|
||||
ratingid = self.cursor.fetchone()[0]
|
||||
except TypeError:
|
||||
ratingid = None
|
||||
return ratingid
|
||||
|
||||
def update_ratings(self, *args):
|
||||
"""
|
||||
Feed with media_id, media_type, rating_type, rating, votes, rating_id
|
||||
"""
|
||||
query = '''
|
||||
UPDATE rating
|
||||
SET media_id = ?,
|
||||
media_type = ?,
|
||||
rating_type = ?,
|
||||
rating = ?,
|
||||
votes = ?
|
||||
WHERE rating_id = ?
|
||||
'''
|
||||
self.cursor.execute(query, (args))
|
||||
|
||||
def add_ratings(self, *args):
|
||||
"""
|
||||
feed with:
|
||||
rating_id, media_id, media_type, rating_type, rating, votes
|
||||
|
||||
rating_type = 'default'
|
||||
"""
|
||||
query = '''
|
||||
INSERT INTO rating(
|
||||
rating_id, media_id, media_type, rating_type, rating, votes)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
'''
|
||||
self.cursor.execute(query, (args))
|
||||
|
||||
|
||||
def get_kodiid_from_filename(file):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue