support add/update krypton ratings

This commit is contained in:
im85288 2017-01-01 16:06:40 +00:00
parent e72a3070e3
commit cb30feba46
5 changed files with 116 additions and 36 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.emby" <addon id="plugin.video.emby"
name="Emby" name="Emby"
version="2.3.30" version="2.3.31"
provider-name="Emby.media"> provider-name="Emby.media">
<requires> <requires>
<import addon="xbmc.python" version="2.19.0"/> <import addon="xbmc.python" version="2.19.0"/>

View file

@ -113,6 +113,16 @@ class KodiMovies(KodiItems):
self.cursor.execute("DELETE FROM movie WHERE idMovie = ?", (kodi_id,)) self.cursor.execute("DELETE FROM movie WHERE idMovie = ?", (kodi_id,))
self.cursor.execute("DELETE FROM files WHERE idFile = ?", (file_id,)) self.cursor.execute("DELETE FROM files WHERE idFile = ?", (file_id,))
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 add_ratings(self, *args): def add_ratings(self, *args):
query = ( query = (
@ -134,6 +144,17 @@ class KodiMovies(KodiItems):
)) ))
self.cursor.execute(query, (args)) self.cursor.execute(query, (args))
def get_uniqueid(self, media_id):
query = "SELECT uniqueid_id FROM uniqueid WHERE media_id = ?"
self.cursor.execute(query, (media_id,))
try:
uniqueid = self.cursor.fetchone()[0]
except TypeError:
uniqueid = None
return uniqueid
def add_uniqueid(self, *args): def add_uniqueid(self, *args):
query = ( query = (
''' '''

View file

@ -74,6 +74,17 @@ class KodiTVShows(KodiItems):
return kodi_id return kodi_id
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 add_ratings(self, *args): def add_ratings(self, *args):
query = ( query = (
''' '''
@ -94,6 +105,17 @@ class KodiTVShows(KodiItems):
)) ))
self.cursor.execute(query, (args)) self.cursor.execute(query, (args))
def get_uniqueid(self, media_id):
query = "SELECT uniqueid_id FROM uniqueid WHERE media_id = ?"
self.cursor.execute(query, (media_id,))
try:
uniqueid = self.cursor.fetchone()[0]
except TypeError:
uniqueid = None
return uniqueid
def add_uniqueid(self, *args): def add_uniqueid(self, *args):
query = ( query = (
''' '''

View file

@ -234,23 +234,23 @@ class Movies(Items):
} }
filename = "%s?%s" % (path, urllib.urlencode(params)) filename = "%s?%s" % (path, urllib.urlencode(params))
# update new ratings Kodi 17 - todo get ratingid for updates from embydb
if self.kodi_version > 16:
ratingid = self.kodi_db.create_entry_rating()
self.kodi_db.add_ratings(ratingid, movieid, "movie", "default", rating, votecount)
# update new uniqueid Kodi 17 - todo get uniqueid_id for updates from embydb
if self.kodi_version > 16:
uniqueid = self.kodi_db.create_entry_uniqueid()
self.kodi_db.add_uniqueid(uniqueid, movieid, "movie", imdb, "imdb")
##### UPDATE THE MOVIE ##### ##### UPDATE THE MOVIE #####
if update_item: if update_item:
log.info("UPDATE movie itemid: %s - Title: %s", itemid, title) log.info("UPDATE movie itemid: %s - Title: %s", itemid, title)
# update new ratings Kodi 17
if self.kodi_version > 16:
ratingid = self.kodi_db.get_ratingid(movieid)
self.kodi_db.update_ratings(movieid, "movie", "default", rating, votecount,ratingid)
# update new uniqueid Kodi 17
if self.kodi_version > 16:
uniqueid = self.kodi_db.get_uniqueid(movieid)
self.kodi_db.update_uniqueid(movieid, "movie", imdb, "imdb",uniqueid)
# Update the movie entry # Update the movie entry
if self.kodi_version > 16: if self.kodi_version > 16:
self.kodi_db.update_movie_17(title, plot, shortplot, tagline, votecount, uniqueid, self.kodi_db.update_movie_17(title, plot, shortplot, tagline, votecount, uniqueid,
@ -269,6 +269,18 @@ class Movies(Items):
else: else:
log.info("ADD movie itemid: %s - Title: %s", itemid, title) log.info("ADD movie itemid: %s - Title: %s", itemid, title)
# add new ratings Kodi 17
if self.kodi_version > 16:
ratingid = self.kodi_db.create_entry_rating()
self.kodi_db.add_ratings(ratingid, movieid, "movie", "default", rating, votecount)
# add new uniqueid Kodi 17
if self.kodi_version > 16:
uniqueid = self.kodi_db.create_entry_uniqueid()
self.kodi_db.add_uniqueid(uniqueid, movieid, "movie", imdb, "imdb")
# Add path # Add path
pathid = self.kodi_db.add_path(path) pathid = self.kodi_db.add_path(path)
# Add the file # Add the file

View file

@ -336,22 +336,23 @@ class TVShows(Items):
toplevelpath = "plugin://plugin.video.emby.tvshows/" toplevelpath = "plugin://plugin.video.emby.tvshows/"
path = "%s%s/" % (toplevelpath, itemid) path = "%s%s/" % (toplevelpath, itemid)
# update new ratings Kodi 17 - todo get ratingid for updates from embydb
if self.kodi_version > 16:
ratingid = self.kodi_db.create_entry_rating()
self.kodi_db.add_ratings(ratingid, showid, "tvshow", "default", rating, votecount)
# update new uniqueid Kodi 17 - todo get uniqueid_id for updates from embydb
if self.kodi_version > 16:
uniqueid = self.kodi_db.create_entry_uniqueid()
self.kodi_db.add_uniqueid(uniqueid, showid, "tvshow", imdb, "imdb")
##### UPDATE THE TVSHOW ##### ##### UPDATE THE TVSHOW #####
if update_item: if update_item:
log.info("UPDATE tvshow itemid: %s - Title: %s", itemid, title) log.info("UPDATE tvshow itemid: %s - Title: %s", itemid, title)
# update new ratings Kodi 17
if self.kodi_version > 16:
ratingid = self.kodi_db.get_ratingid(showid)
self.kodi_db.update_ratings(showid, "tvshow", "default", rating, votecount,ratingid)
# update new uniqueid Kodi 17
if self.kodi_version > 16:
uniqueid = self.kodi_db.get_uniqueid(showid)
self.kodi_db.update_uniqueid(showid, "tvshow", imdb, "imdb",uniqueid)
# Update the tvshow entry # Update the tvshow entry
if self.kodi_version > 16: if self.kodi_version > 16:
self.kodi_db.update_tvshow(title, plot, uniqueid, premieredate, genre, title, self.kodi_db.update_tvshow(title, plot, uniqueid, premieredate, genre, title,
@ -366,6 +367,18 @@ class TVShows(Items):
else: else:
log.info("ADD tvshow itemid: %s - Title: %s", itemid, title) log.info("ADD tvshow itemid: %s - Title: %s", itemid, title)
# add new ratings Kodi 17
if self.kodi_version > 16:
ratingid = self.kodi_db.create_entry_rating()
self.kodi_db.add_ratings(ratingid, showid, "tvshow", "default", rating, votecount)
# add new uniqueid Kodi 17
if self.kodi_version > 16:
uniqueid = self.kodi_db.create_entry_uniqueid()
self.kodi_db.add_uniqueid(uniqueid, showid, "tvshow", imdb, "imdb")
# Add top path # Add top path
toppathid = self.kodi_db.add_path(toplevelpath) toppathid = self.kodi_db.add_path(toplevelpath)
self.kodi_db.update_path(toppathid, toplevelpath, "tvshows", "metadata.local") self.kodi_db.update_path(toppathid, toplevelpath, "tvshows", "metadata.local")
@ -589,22 +602,22 @@ class TVShows(Items):
} }
filename = "%s?%s" % (path, urllib.urlencode(params)) filename = "%s?%s" % (path, urllib.urlencode(params))
# update new ratings Kodi 17 - todo get ratingid for updates from embydb
if self.kodi_version > 16:
ratingid = self.kodi_db.create_entry_rating()
self.kodi_db.add_ratings(ratingid, showid, "episode", "default", rating, votecount)
# update new uniqueid Kodi 17 - todo get uniqueid_id for updates from embydb
if self.kodi_version > 16:
uniqueid = self.kodi_db.create_entry_uniqueid()
self.kodi_db.add_uniqueid(uniqueid, showid, "episode", tvdb, "tvdb")
##### UPDATE THE EPISODE ##### ##### UPDATE THE EPISODE #####
if update_item: if update_item:
log.info("UPDATE episode itemid: %s - Title: %s", itemid, title) log.info("UPDATE episode itemid: %s - Title: %s", itemid, title)
# update new ratings Kodi 17
if self.kodi_version > 16:
ratingid = self.kodi_db.get_ratingid(episodeid)
self.kodi_db.update_ratings(episodeid, "episode", "default", rating, votecount,ratingid)
# update new uniqueid Kodi 17
if self.kodi_version > 16:
uniqueid = self.kodi_db.get_uniqueid(episodeid)
self.kodi_db.update_uniqueid(episodeid, "episode", tvdb, "tvdb",uniqueid)
# Update the episode entry # Update the episode entry
if self.kodi_version > 16: if self.kodi_version > 16:
# Kodi Krypton # Kodi Krypton
@ -630,6 +643,18 @@ class TVShows(Items):
else: else:
log.info("ADD episode itemid: %s - Title: %s", itemid, title) log.info("ADD episode itemid: %s - Title: %s", itemid, title)
# add new ratings Kodi 17
if self.kodi_version > 16:
ratingid = self.kodi_db.create_entry_rating()
self.kodi_db.add_ratings(ratingid, showid, "episode", "default", rating, votecount)
# add new uniqueid Kodi 17
if self.kodi_version > 16:
uniqueid = self.kodi_db.create_entry_uniqueid()
self.kodi_db.add_uniqueid(uniqueid, showid, "episode", tvdb, "tvdb")
# Add path # Add path
pathid = self.kodi_db.add_path(path) pathid = self.kodi_db.add_path(path)
# Add the file # Add the file