mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 10:46:11 +00:00
fixed ratings; now using decimals
This commit is contained in:
parent
64d2ff9cab
commit
a464924f6f
1 changed files with 28 additions and 20 deletions
|
@ -11,6 +11,7 @@ import json
|
||||||
import urllib
|
import urllib
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import os
|
import os
|
||||||
|
from decimal import Decimal
|
||||||
|
|
||||||
from DownloadUtils import DownloadUtils
|
from DownloadUtils import DownloadUtils
|
||||||
from PlayUtils import PlayUtils
|
from PlayUtils import PlayUtils
|
||||||
|
@ -80,7 +81,7 @@ class WriteKodiDB():
|
||||||
self.getPropertyParamArray_Batched(KodiItem, "tag", MBitem.get("Tag"), params)
|
self.getPropertyParamArray_Batched(KodiItem, "tag", MBitem.get("Tag"), params)
|
||||||
|
|
||||||
if MBitem.get("CommunityRating") != None:
|
if MBitem.get("CommunityRating") != None:
|
||||||
self.getPropertyParam_Batched(KodiItem, "rating", int(MBitem.get("CommunityRating")), params)
|
self.getPropertyParam_Batched(KodiItem, "rating", Decimal(format(MBitem.get("CommunityRating"),'.1f')), params)
|
||||||
|
|
||||||
#self.getPropertyParam_Batched(KodiItem, "plot", MBitem.get("Overview"), params)
|
#self.getPropertyParam_Batched(KodiItem, "plot", MBitem.get("Overview"), params)
|
||||||
self.getPropertyParam_Batched(KodiItem, "plotoutline", MBitem.get("ShortOverview"), params)
|
self.getPropertyParam_Batched(KodiItem, "plotoutline", MBitem.get("ShortOverview"), params)
|
||||||
|
@ -320,7 +321,7 @@ class WriteKodiDB():
|
||||||
changes |= self.updateProperty(KodiItem,"lastplayed",MBitem.get("LastPlayedDate"),"tvshow")
|
changes |= self.updateProperty(KodiItem,"lastplayed",MBitem.get("LastPlayedDate"),"tvshow")
|
||||||
|
|
||||||
if MBitem.get("CommunityRating") != None:
|
if MBitem.get("CommunityRating") != None:
|
||||||
changes |= self.updateProperty(KodiItem,"rating",int(MBitem.get("CommunityRating")),"tvshow")
|
changes |= self.updateProperty(KodiItem,"rating",Decimal(format(MBitem.get("CommunityRating"),'.1f')),"tvshow")
|
||||||
|
|
||||||
changes |= self.updateProperty(KodiItem,"sorttitle",utils.convertEncoding(MBitem["SortName"]),"tvshow")
|
changes |= self.updateProperty(KodiItem,"sorttitle",utils.convertEncoding(MBitem["SortName"]),"tvshow")
|
||||||
changes |= self.updateProperty(KodiItem,"title",utils.convertEncoding(MBitem["Name"]),"tvshow")
|
changes |= self.updateProperty(KodiItem,"title",utils.convertEncoding(MBitem["Name"]),"tvshow")
|
||||||
|
@ -395,7 +396,7 @@ class WriteKodiDB():
|
||||||
changes |= self.updateProperty(KodiItem,"firstaired",firstaired,"episode")
|
changes |= self.updateProperty(KodiItem,"firstaired",firstaired,"episode")
|
||||||
|
|
||||||
if MBitem.get("CommunityRating") != None:
|
if MBitem.get("CommunityRating") != None:
|
||||||
changes |= self.updateProperty(KodiItem,"rating",int(MBitem.get("CommunityRating")),"episode")
|
changes |= self.updateProperty(KodiItem,"rating",Decimal(format(MBitem.get("CommunityRating"),'.1f')),"episode")
|
||||||
|
|
||||||
if MBitem.get("ParentIndexNumber") != None:
|
if MBitem.get("ParentIndexNumber") != None:
|
||||||
season = int(MBitem.get("ParentIndexNumber"))
|
season = int(MBitem.get("ParentIndexNumber"))
|
||||||
|
@ -558,6 +559,13 @@ class WriteKodiDB():
|
||||||
params.append("\"" + propertyName + "\": " + str(propertyValue))
|
params.append("\"" + propertyName + "\": " + str(propertyValue))
|
||||||
#xbmc.executeJSONRPC(jsoncommand_i %(id, propertyName, propertyValue))
|
#xbmc.executeJSONRPC(jsoncommand_i %(id, propertyName, propertyValue))
|
||||||
changes = True
|
changes = True
|
||||||
|
elif type(propertyValue) is Decimal:
|
||||||
|
#extra compare decimals as int (rounded)
|
||||||
|
if int(propertyValue) != int(KodiItem[propertyName]):
|
||||||
|
utils.logMsg("Emby","updating property..." + str(propertyName))
|
||||||
|
utils.logMsg("Emby","kodi value:" + str(KodiItem[propertyName]) + " MB value: " + str(propertyValue))
|
||||||
|
params.append("\"" + propertyName + "\": " + str(propertyValue))
|
||||||
|
changes = True
|
||||||
else:
|
else:
|
||||||
#xbmc.sleep(sleepVal)
|
#xbmc.sleep(sleepVal)
|
||||||
utils.logMsg("Emby","updating property..." + str(propertyName))
|
utils.logMsg("Emby","updating property..." + str(propertyName))
|
||||||
|
@ -572,19 +580,19 @@ class WriteKodiDB():
|
||||||
def updateProperty(self,KodiItem,propertyName,propertyValue,fileType,forced=False):
|
def updateProperty(self,KodiItem,propertyName,propertyValue,fileType,forced=False):
|
||||||
if fileType == "tvshow":
|
if fileType == "tvshow":
|
||||||
id = KodiItem['tvshowid']
|
id = KodiItem['tvshowid']
|
||||||
jsoncommand_i = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetTVShowDetails", "params": { "tvshowid": %i, "%s": %i}, "id": 1 }'
|
jsoncommand_i = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetTVShowDetails", "params": { "tvshowid": %i, "%s": %s}, "id": 1 }'
|
||||||
jsoncommand_s = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetTVShowDetails", "params": { "tvshowid": %i, "%s": "%s"}, "id": 1 }'
|
jsoncommand_s = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetTVShowDetails", "params": { "tvshowid": %i, "%s": "%s"}, "id": 1 }'
|
||||||
elif fileType == "episode":
|
elif fileType == "episode":
|
||||||
id = KodiItem['episodeid']
|
id = KodiItem['episodeid']
|
||||||
jsoncommand_i = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetEpisodeDetails", "params": { "episodeid": %i, "%s": %i}, "id": 1 }'
|
jsoncommand_i = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetEpisodeDetails", "params": { "episodeid": %i, "%s": %s}, "id": 1 }'
|
||||||
jsoncommand_s = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetEpisodeDetails", "params": { "episodeid": %i, "%s": "%s"}, "id": 1 }'
|
jsoncommand_s = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetEpisodeDetails", "params": { "episodeid": %i, "%s": "%s"}, "id": 1 }'
|
||||||
elif fileType == "musicvideo":
|
elif fileType == "musicvideo":
|
||||||
id = KodiItem['musicvideoid']
|
id = KodiItem['musicvideoid']
|
||||||
jsoncommand_i = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetMusicVideoDetails", "params": { "musicvideoid": %i, "%s": %i}, "id": 1 }'
|
jsoncommand_i = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetMusicVideoDetails", "params": { "musicvideoid": %i, "%s": %s}, "id": 1 }'
|
||||||
jsoncommand_s = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetMusicVideoDetails", "params": { "musicvideoid": %i, "%s": "%s"}, "id": 1 }'
|
jsoncommand_s = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetMusicVideoDetails", "params": { "musicvideoid": %i, "%s": "%s"}, "id": 1 }'
|
||||||
elif fileType == "movie":
|
elif fileType == "movie":
|
||||||
id = KodiItem['movieid']
|
id = KodiItem['movieid']
|
||||||
jsoncommand_i = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": { "movieid": %i, "%s": %i}, "id": 1 }'
|
jsoncommand_i = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": { "movieid": %i, "%s": %s}, "id": 1 }'
|
||||||
jsoncommand_s = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": { "movieid": %i, "%s": "%s"}, "id": 1 }'
|
jsoncommand_s = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": { "movieid": %i, "%s": "%s"}, "id": 1 }'
|
||||||
|
|
||||||
changes = False
|
changes = False
|
||||||
|
@ -596,6 +604,14 @@ class WriteKodiDB():
|
||||||
utils.logMsg("Emby","kodi value:" + str(KodiItem[propertyName]) + " MB value: " + str(propertyValue))
|
utils.logMsg("Emby","kodi value:" + str(KodiItem[propertyName]) + " MB value: " + str(propertyValue))
|
||||||
xbmc.executeJSONRPC(jsoncommand_i %(id, propertyName, propertyValue))
|
xbmc.executeJSONRPC(jsoncommand_i %(id, propertyName, propertyValue))
|
||||||
changes = True
|
changes = True
|
||||||
|
elif type(propertyValue) is Decimal:
|
||||||
|
#extra compare decimals as int (rounded)
|
||||||
|
if int(propertyValue) != int(KodiItem[propertyName]):
|
||||||
|
xbmc.sleep(sleepVal)
|
||||||
|
utils.logMsg("Emby","updating property..." + str(propertyName))
|
||||||
|
utils.logMsg("Emby","kodi value:" + str(KodiItem[propertyName]) + " MB value: " + str(propertyValue))
|
||||||
|
xbmc.executeJSONRPC(jsoncommand_i %(id, propertyName, propertyValue))
|
||||||
|
changes = True
|
||||||
else:
|
else:
|
||||||
xbmc.sleep(sleepVal)
|
xbmc.sleep(sleepVal)
|
||||||
utils.logMsg("Emby","updating property..." + str(propertyName))
|
utils.logMsg("Emby","updating property..." + str(propertyName))
|
||||||
|
@ -742,10 +758,8 @@ class WriteKodiDB():
|
||||||
title = utils.convertEncoding(MBitem["Name"])
|
title = utils.convertEncoding(MBitem["Name"])
|
||||||
sorttitle = utils.convertEncoding(MBitem["SortName"])
|
sorttitle = utils.convertEncoding(MBitem["SortName"])
|
||||||
year = MBitem.get("ProductionYear")
|
year = MBitem.get("ProductionYear")
|
||||||
if MBitem.get("CommunityRating") != None:
|
rating = MBitem.get("CommunityRating")
|
||||||
rating = int(MBitem.get("CommunityRating"))
|
|
||||||
else:
|
|
||||||
rating = None
|
|
||||||
if MBitem.get("ShortOverview") != None:
|
if MBitem.get("ShortOverview") != None:
|
||||||
shortplot = utils.convertEncoding(MBitem.get("ShortOverview"))
|
shortplot = utils.convertEncoding(MBitem.get("ShortOverview"))
|
||||||
else:
|
else:
|
||||||
|
@ -765,7 +779,7 @@ class WriteKodiDB():
|
||||||
cursor.execute("select coalesce(max(idMovie),0) as movieid from movie")
|
cursor.execute("select coalesce(max(idMovie),0) as movieid from movie")
|
||||||
movieid = cursor.fetchone()[0]
|
movieid = cursor.fetchone()[0]
|
||||||
movieid = movieid + 1
|
movieid = movieid + 1
|
||||||
pathsql="insert into movie(idMovie, idFile, c00, c01, c02, c04, c07, c08, c09, c10, c11, c16, c19, c20) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
pathsql="insert into movie(idMovie, idFile, c00, c01, c02, c05, c07, c08, c09, c10, c11, c16, c19, c20) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||||
|
|
||||||
cursor.execute(pathsql, (movieid, fileid, title, plot, shortplot, rating, year, thumb, MBitem["Id"], sorttitle, runtime, title, trailerUrl, fanart))
|
cursor.execute(pathsql, (movieid, fileid, title, plot, shortplot, rating, year, thumb, MBitem["Id"], sorttitle, runtime, title, trailerUrl, fanart))
|
||||||
|
|
||||||
|
@ -961,10 +975,7 @@ class WriteKodiDB():
|
||||||
plot = utils.convertEncoding(API().getOverview(MBitem))
|
plot = utils.convertEncoding(API().getOverview(MBitem))
|
||||||
thumb = "<thumb>" + API().getArtwork(MBitem, "Primary") + "</thumb>"
|
thumb = "<thumb>" + API().getArtwork(MBitem, "Primary") + "</thumb>"
|
||||||
title = utils.convertEncoding(MBitem["Name"])
|
title = utils.convertEncoding(MBitem["Name"])
|
||||||
if MBitem.get("CommunityRating") != None:
|
rating = MBitem.get("CommunityRating")
|
||||||
rating = int(MBitem.get("CommunityRating"))
|
|
||||||
else:
|
|
||||||
rating = None
|
|
||||||
|
|
||||||
#create the episode
|
#create the episode
|
||||||
cursor.execute("select coalesce(max(idEpisode),0) as episodeid from episode")
|
cursor.execute("select coalesce(max(idEpisode),0) as episodeid from episode")
|
||||||
|
@ -1066,10 +1077,7 @@ class WriteKodiDB():
|
||||||
fanart = "<fanart>" + API().getArtwork(MBitem, "Backdrop") + "</fanart>"
|
fanart = "<fanart>" + API().getArtwork(MBitem, "Backdrop") + "</fanart>"
|
||||||
title = utils.convertEncoding(MBitem["Name"])
|
title = utils.convertEncoding(MBitem["Name"])
|
||||||
sorttitle = utils.convertEncoding(MBitem["SortName"])
|
sorttitle = utils.convertEncoding(MBitem["SortName"])
|
||||||
if MBitem.get("CommunityRating") != None:
|
rating = MBitem.get("CommunityRating")
|
||||||
rating = int(MBitem.get("CommunityRating"))
|
|
||||||
else:
|
|
||||||
rating = None
|
|
||||||
|
|
||||||
#create the tvshow
|
#create the tvshow
|
||||||
cursor.execute("select coalesce(max(idShow),0) as showid from tvshow")
|
cursor.execute("select coalesce(max(idShow),0) as showid from tvshow")
|
||||||
|
|
Loading…
Reference in a new issue