added genres to the properties
This commit is contained in:
parent
2d3f81a059
commit
7b45de29e1
1 changed files with 29 additions and 9 deletions
|
@ -168,17 +168,14 @@ class LibrarySync():
|
||||||
trailerItem = json.loads(jsonData)
|
trailerItem = json.loads(jsonData)
|
||||||
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,13 +214,36 @@ 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):
|
||||||
|
|
||||||
itemPath = os.path.join(movieLibrary,id)
|
itemPath = os.path.join(movieLibrary,id)
|
||||||
|
|
Loading…
Reference in a new issue