Krypton: update userratings on startup&user change
This commit is contained in:
parent
1343edc0d0
commit
56d5e84f72
2 changed files with 21 additions and 2 deletions
|
@ -134,9 +134,10 @@ class Items(object):
|
||||||
for mediaitem in xml:
|
for mediaitem in xml:
|
||||||
API = PlexAPI.API(mediaitem)
|
API = PlexAPI.API(mediaitem)
|
||||||
# Get key and db entry on the Kodi db side
|
# Get key and db entry on the Kodi db side
|
||||||
|
db_item = self.plex_db.getItem_byId(API.getRatingKey())
|
||||||
try:
|
try:
|
||||||
fileid = self.plex_db.getItem_byId(API.getRatingKey())[1]
|
fileid = db_item[1]
|
||||||
except:
|
except TypeError:
|
||||||
continue
|
continue
|
||||||
# Grab the user's viewcount, resume points etc. from PMS' answer
|
# Grab the user's viewcount, resume points etc. from PMS' answer
|
||||||
userdata = API.getUserData()
|
userdata = API.getUserData()
|
||||||
|
@ -146,6 +147,10 @@ class Items(object):
|
||||||
userdata['Runtime'],
|
userdata['Runtime'],
|
||||||
userdata['PlayCount'],
|
userdata['PlayCount'],
|
||||||
userdata['LastPlayedDate'])
|
userdata['LastPlayedDate'])
|
||||||
|
if v.KODIVERSION >= 17:
|
||||||
|
self.kodi_db.update_userrating(db_item[0],
|
||||||
|
db_item[4],
|
||||||
|
userdata['UserRating'])
|
||||||
|
|
||||||
def updatePlaystate(self, item):
|
def updatePlaystate(self, item):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1401,6 +1401,20 @@ class Kodidb_Functions():
|
||||||
|
|
||||||
# Krypton only stuff ##############################
|
# Krypton only stuff ##############################
|
||||||
|
|
||||||
|
def update_userrating(self, kodi_id, kodi_type, userrating):
|
||||||
|
"""
|
||||||
|
Updates userrating for >=Krypton
|
||||||
|
"""
|
||||||
|
if kodi_type == v.KODI_TYPE_MOVIE:
|
||||||
|
ID = 'idMovie'
|
||||||
|
elif kodi_type == v.KODI_TYPE_EPISODE:
|
||||||
|
ID = 'idEpisode'
|
||||||
|
elif kodi_type == v.KODI_TYPE_SONG:
|
||||||
|
ID = 'idSong'
|
||||||
|
query = ('''UPDATE %s SET userrating = ? WHERE %s = ?'''
|
||||||
|
% (kodi_type, ID))
|
||||||
|
self.cursor.execute(query, (userrating, kodi_id))
|
||||||
|
|
||||||
def create_entry_uniqueid(self):
|
def create_entry_uniqueid(self):
|
||||||
self.cursor.execute(
|
self.cursor.execute(
|
||||||
"select coalesce(max(uniqueid_id),0) from uniqueid")
|
"select coalesce(max(uniqueid_id),0) from uniqueid")
|
||||||
|
|
Loading…
Reference in a new issue