added genres to the properties

This commit is contained in:
Marcel van der Veldt 2015-03-14 14:32:50 +01:00
parent 2d3f81a059
commit 7b45de29e1

View file

@ -169,16 +169,13 @@ class LibrarySync():
trailerUrl = "plugin://plugin.video.mb3sync/?id=" + trailerItem[0].get("Id") + '&mode=play' trailerUrl = "plugin://plugin.video.mb3sync/?id=" + trailerItem[0].get("Id") + '&mode=play'
self.updateProperty(KodiItem,"trailer",trailerUrl,"movie") self.updateProperty(KodiItem,"trailer",trailerUrl,"movie")
#update genres
#update genre self.updateGenres(KodiItem,MBitem.get("Genres"),"movie")
if KodiItem['genre'] != MBitem.get("Genres") and MBitem.get("Genres") != None:
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": { "movieid": %i, "genre": %s}, "id": 1 }' %(KodiItem['movieid'], "\"{koekoek,pannekoek} \""))
#update strm file - TODO: only update strm when path has changed #update strm file - TODO: only update strm when path has changed
self.createSTRM(MBitem["Id"]) self.createSTRM(MBitem["Id"])
#update nfo file - needed for testing #create nfo file if not exists
nfoFile = os.path.join(movieLibrary,MBitem["Id"],MBitem["Id"] + ".nfo") nfoFile = os.path.join(movieLibrary,MBitem["Id"],MBitem["Id"] + ".nfo")
if not xbmcvfs.exists(nfoFile): if not xbmcvfs.exists(nfoFile):
self.createNFO(MBitem) self.createNFO(MBitem)
@ -217,12 +214,35 @@ class LibrarySync():
else: else:
method = "VideoLibrary.SetMovieDetails" method = "VideoLibrary.SetMovieDetails"
if not propertyValue in KodiItem[propertyName]: if propertyValue != KodiItem[propertyName]:
if type(propertyValue) is int: if type(propertyValue) is int:
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "%s", "params": { "movieid": %i, "%s": %i}, "id": 1 }' %(method,KodiItem['movieid'], propertyName, propertyValue)) xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "%s", "params": { "movieid": %i, "%s": %i}, "id": 1 }' %(method,KodiItem['movieid'], propertyName, propertyValue))
else: else:
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "%s", "params": { "movieid": %i, "%s": "%s"}, "id": 1 }' %(method,KodiItem['movieid'], propertyName, propertyValue)) xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "%s", "params": { "movieid": %i, "%s": "%s"}, "id": 1 }' %(method,KodiItem['movieid'], propertyName, propertyValue))
# adds or updates the genres on the videofile in Kodi database
def updateGenres(self,KodiItem,genreCollection,fileType="movie"):
if fileType == "tvshow":
method = "VideoLibrary.SetTVShowDetails"
elif fileType == "episode":
method = "VideoLibrary.SetEpisodeDetails"
elif fileType == "musicvideo":
method = "VideoLibrary.SetMusicVideoDetails"
else:
method = "VideoLibrary.SetMovieDetails"
pendingChanges = False
if genreCollection != None:
currentgenres = set(KodiItem["genre"])
genrestring = ""
for genre in genreCollection:
if not genre in currentgenres:
pendingChanges = True
json_genres = json.dumps(genreCollection)
if pendingChanges:
print genreCollection
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "%s", "params": { "movieid": %i, "genre": %s}, "id": 1 }' %(method,KodiItem['movieid'],json_genres))
def createSTRM(self,id): def createSTRM(self,id):