add episodes/tvshows uniqueid/rating

This commit is contained in:
im85288 2016-12-31 12:47:12 +00:00
parent 87501eedea
commit aceecdfe5e
3 changed files with 82 additions and 1 deletions

View file

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

View file

@ -21,6 +21,19 @@ class KodiTVShows(KodiItems):
KodiItems.__init__(self)
def create_entry_uniqueid(self):
self.cursor.execute("select coalesce(max(uniqueid_id),0) from uniqueid")
kodi_id = self.cursor.fetchone()[0] + 1
return kodi_id
def create_entry_rating(self):
self.cursor.execute("select coalesce(max(rating_id),0) from rating")
kodi_id = self.cursor.fetchone()[0] + 1
return kodi_id
def create_entry(self):
self.cursor.execute("select coalesce(max(idShow),0) from tvshow")
kodi_id = self.cursor.fetchone()[0] + 1
@ -61,6 +74,46 @@ class KodiTVShows(KodiItems):
return kodi_id
def add_ratings(self, *args):
query = (
'''
INSERT INTO rating(
rating_id, media_id, media_type, rating_type, rating, votes)
VALUES (?, ?, ?, ?, ?, ?)
'''
)
self.cursor.execute(query, (args))
def update_ratings(self, *args):
query = ' '.join((
"UPDATE rating",
"SET media_id = ?, media_type = ?, rating_type = ?, rating = ?, votes = ?",
"WHERE rating_id = ?"
))
self.cursor.execute(query, (args))
def add_uniqueid(self, *args):
query = (
'''
INSERT INTO uniqueid(
uniqueid_id, media_id, media_type, value, type)
VALUES (?, ?, ?, ?, ?)
'''
)
self.cursor.execute(query, (args))
def update_uniqueid(self, *args):
query = ' '.join((
"UPDATE uniqueid",
"SET media_id = ?, media_type = ?, value = ?, type = ?",
"WHERE uniqueid_id = ?"
))
self.cursor.execute(query, (args))
def add_tvshow(self, *args):
query = (

View file

@ -281,6 +281,7 @@ class TVShows(Items):
title = item['Name']
plot = API.get_overview()
rating = item.get('CommunityRating')
votecount = item.get('VoteCount')
premieredate = API.get_premiere_date()
tvdb = API.get_provider('Tvdb')
sorttitle = item['SortName']
@ -403,6 +404,18 @@ class TVShows(Items):
all_episodes = emby.getEpisodesbyShow(itemid)
self.add_episodes(all_episodes['Items'], None)
# 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", tvdb, "tvdb")
return True
def add_updateSeason(self, item, showid=None):
@ -489,6 +502,9 @@ class TVShows(Items):
runtime = API.get_runtime()
premieredate = API.get_premiere_date()
votecount = item.get('VoteCount')
tvdb = API.get_provider('Tvdb')
# episode details
try:
seriesId = item['SeriesId']
@ -636,6 +652,18 @@ class TVShows(Items):
self.kodi_db.update_file(tempfileid, filename, temppathid, dateadded)
self.kodi_db.add_playstate(tempfileid, resume, total, playcount, dateplayed)
# 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")
return True
def updateUserdata(self, item):