Ratings default to 0, not None
This commit is contained in:
parent
d191500552
commit
47d480eafd
2 changed files with 20 additions and 14 deletions
|
@ -1553,12 +1553,8 @@ class API():
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
item = self.item.attrib
|
item = self.item.attrib
|
||||||
# Default
|
# Default - attributes not found with Plex
|
||||||
favorite = False
|
favorite = False
|
||||||
played = False
|
|
||||||
lastPlayedDate = None
|
|
||||||
resume = 0
|
|
||||||
rating = 0
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
playcount = int(item['viewCount'])
|
playcount = int(item['viewCount'])
|
||||||
|
@ -1567,13 +1563,26 @@ class API():
|
||||||
|
|
||||||
if playcount:
|
if playcount:
|
||||||
played = True
|
played = True
|
||||||
|
else:
|
||||||
|
played = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
lastPlayedDate = utils.DateToKodi(int(item['lastViewedAt']))
|
lastPlayedDate = utils.DateToKodi(int(item['lastViewedAt']))
|
||||||
except:
|
except:
|
||||||
lastPlayedDate = None
|
lastPlayedDate = None
|
||||||
|
|
||||||
userrating = int(float(item.get('userRating', 0)))
|
try:
|
||||||
|
userrating = float(item['userRating'])
|
||||||
|
except:
|
||||||
|
userrating = 0.0
|
||||||
|
|
||||||
|
try:
|
||||||
|
rating = float(item['audienceRating'])
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
rating = float(item['rating'])
|
||||||
|
except:
|
||||||
|
rating = 0.0
|
||||||
|
|
||||||
resume, runtime = self.getRuntime()
|
resume, runtime = self.getRuntime()
|
||||||
return {
|
return {
|
||||||
|
@ -1734,11 +1743,12 @@ class API():
|
||||||
|
|
||||||
def getAudienceRating(self):
|
def getAudienceRating(self):
|
||||||
"""
|
"""
|
||||||
Returns the audience rating, 'rating' itself or None
|
Returns the audience rating, 'rating' itself or 0.0
|
||||||
"""
|
"""
|
||||||
res = self.item.attrib.get('audienceRating')
|
res = self.item.attrib.get('audienceRating')
|
||||||
if res is None:
|
if res is None:
|
||||||
res = self.item.attrib.get('rating')
|
res = self.item.attrib.get('rating', 0.0)
|
||||||
|
res = float(res)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def getYear(self):
|
def getYear(self):
|
||||||
|
|
|
@ -388,7 +388,7 @@ class Movies(Items):
|
||||||
votecount = None
|
votecount = None
|
||||||
collections = API.getCollections()
|
collections = API.getCollections()
|
||||||
|
|
||||||
rating = API.getAudienceRating()
|
rating = userdata['Rating']
|
||||||
year = API.getYear()
|
year = API.getYear()
|
||||||
imdb = API.getProvider('imdb')
|
imdb = API.getProvider('imdb')
|
||||||
mpaa = API.getMpaa()
|
mpaa = API.getMpaa()
|
||||||
|
@ -1254,7 +1254,7 @@ class TVShows(Items):
|
||||||
producer = API.joinList(peoples['Producer'])
|
producer = API.joinList(peoples['Producer'])
|
||||||
title, sorttitle = API.getTitle()
|
title, sorttitle = API.getTitle()
|
||||||
plot = API.getPlot()
|
plot = API.getPlot()
|
||||||
rating = API.getAudienceRating()
|
rating = userdata['Rating']
|
||||||
resume, runtime = API.getRuntime()
|
resume, runtime = API.getRuntime()
|
||||||
premieredate = API.getPremiereDate()
|
premieredate = API.getPremiereDate()
|
||||||
|
|
||||||
|
@ -1859,8 +1859,6 @@ class Music(Items):
|
||||||
# Process the album info
|
# Process the album info
|
||||||
if kodiversion == 17:
|
if kodiversion == 17:
|
||||||
# Kodi Krypton
|
# Kodi Krypton
|
||||||
if not rating:
|
|
||||||
rating = 0.0
|
|
||||||
query = ' '.join((
|
query = ' '.join((
|
||||||
|
|
||||||
"UPDATE album",
|
"UPDATE album",
|
||||||
|
@ -2045,8 +2043,6 @@ class Music(Items):
|
||||||
year = API.getYear()
|
year = API.getYear()
|
||||||
resume, duration = API.getRuntime()
|
resume, duration = API.getRuntime()
|
||||||
rating = userdata['UserRating']
|
rating = userdata['UserRating']
|
||||||
if not rating and kodiversion == 17:
|
|
||||||
rating = 0.0
|
|
||||||
|
|
||||||
#if enabled, try to get the rating from file and/or emby
|
#if enabled, try to get the rating from file and/or emby
|
||||||
# if not self.directstream:
|
# if not self.directstream:
|
||||||
|
|
Loading…
Add table
Reference in a new issue