Ratings default to 0, not None

This commit is contained in:
tomkat83 2016-04-02 10:31:21 +02:00
parent d191500552
commit 47d480eafd
2 changed files with 20 additions and 14 deletions

View file

@ -1553,12 +1553,8 @@ class API():
}
"""
item = self.item.attrib
# Default
# Default - attributes not found with Plex
favorite = False
played = False
lastPlayedDate = None
resume = 0
rating = 0
try:
playcount = int(item['viewCount'])
@ -1567,13 +1563,26 @@ class API():
if playcount:
played = True
else:
played = False
try:
lastPlayedDate = utils.DateToKodi(int(item['lastViewedAt']))
except:
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()
return {
@ -1734,11 +1743,12 @@ class API():
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')
if res is None:
res = self.item.attrib.get('rating')
res = self.item.attrib.get('rating', 0.0)
res = float(res)
return res
def getYear(self):

View file

@ -388,7 +388,7 @@ class Movies(Items):
votecount = None
collections = API.getCollections()
rating = API.getAudienceRating()
rating = userdata['Rating']
year = API.getYear()
imdb = API.getProvider('imdb')
mpaa = API.getMpaa()
@ -1254,7 +1254,7 @@ class TVShows(Items):
producer = API.joinList(peoples['Producer'])
title, sorttitle = API.getTitle()
plot = API.getPlot()
rating = API.getAudienceRating()
rating = userdata['Rating']
resume, runtime = API.getRuntime()
premieredate = API.getPremiereDate()
@ -1859,8 +1859,6 @@ class Music(Items):
# Process the album info
if kodiversion == 17:
# Kodi Krypton
if not rating:
rating = 0.0
query = ' '.join((
"UPDATE album",
@ -2045,8 +2043,6 @@ class Music(Items):
year = API.getYear()
resume, duration = API.getRuntime()
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 not self.directstream: