optimization in setartwork --> now sets all artwork at once
This commit is contained in:
parent
b2bf2c55c4
commit
7f7127b3bc
1 changed files with 52 additions and 52 deletions
|
@ -93,14 +93,8 @@ class WriteKodiDB():
|
||||||
|
|
||||||
changes = False
|
changes = False
|
||||||
|
|
||||||
#update artwork
|
#update/check all artwork
|
||||||
changes |= self.updateArtWork(KodiItem,"poster", API().getArtwork(MBitem, "poster"),"movie")
|
changes |= self.updateArtWork(KodiItem,MBitem)
|
||||||
changes |= self.updateArtWork(KodiItem,"clearlogo", API().getArtwork(MBitem, "Logo"),"movie")
|
|
||||||
changes |= self.updateArtWork(KodiItem,"clearart", API().getArtwork(MBitem, "Art"),"movie")
|
|
||||||
changes |= self.updateArtWork(KodiItem,"banner", API().getArtwork(MBitem, "Banner"),"movie")
|
|
||||||
changes |= self.updateArtWork(KodiItem,"landscape", API().getArtwork(MBitem, "Thumb"),"movie")
|
|
||||||
changes |= self.updateArtWork(KodiItem,"discart", API().getArtwork(MBitem, "Disc"),"movie")
|
|
||||||
changes |= self.updateArtWork(KodiItem,"fanart", API().getArtwork(MBitem, "Backdrop"),"movie")
|
|
||||||
|
|
||||||
#update common properties
|
#update common properties
|
||||||
duration = (int(timeInfo.get('Duration'))*60)
|
duration = (int(timeInfo.get('Duration'))*60)
|
||||||
|
@ -175,14 +169,8 @@ class WriteKodiDB():
|
||||||
|
|
||||||
changes = False
|
changes = False
|
||||||
|
|
||||||
#update artwork
|
#update/check all artwork
|
||||||
changes |= self.updateArtWork(KodiItem,"poster", API().getArtwork(MBitem, "Primary"),"tvshow")
|
changes |= self.updateArtWork(KodiItem,MBitem)
|
||||||
changes |= self.updateArtWork(KodiItem,"clearlogo", API().getArtwork(MBitem, "Logo"),"tvshow")
|
|
||||||
changes |= self.updateArtWork(KodiItem,"clearart", API().getArtwork(MBitem, "Art"),"tvshow")
|
|
||||||
changes |= self.updateArtWork(KodiItem,"banner", API().getArtwork(MBitem, "Banner"),"tvshow")
|
|
||||||
changes |= self.updateArtWork(KodiItem,"landscape", API().getArtwork(MBitem, "Thumb"),"tvshow")
|
|
||||||
changes |= self.updateArtWork(KodiItem,"discart", API().getArtwork(MBitem, "Disc"),"tvshow")
|
|
||||||
changes |= self.updateArtWork(KodiItem,"fanart", API().getArtwork(MBitem, "Backdrop"),"tvshow")
|
|
||||||
|
|
||||||
#update common properties
|
#update common properties
|
||||||
if MBitem.get("PremiereDate") != None:
|
if MBitem.get("PremiereDate") != None:
|
||||||
|
@ -218,8 +206,7 @@ class WriteKodiDB():
|
||||||
|
|
||||||
if changes:
|
if changes:
|
||||||
utils.logMsg("Updated item to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"])
|
utils.logMsg("Updated item to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"])
|
||||||
|
|
||||||
|
|
||||||
def updateEpisodeToKodiLibrary( self, MBitem, KodiItem ):
|
def updateEpisodeToKodiLibrary( self, MBitem, KodiItem ):
|
||||||
|
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.mb3sync')
|
addon = xbmcaddon.Addon(id='plugin.video.mb3sync')
|
||||||
|
@ -240,14 +227,8 @@ class WriteKodiDB():
|
||||||
|
|
||||||
changes = False
|
changes = False
|
||||||
|
|
||||||
# TODO --> set season poster instead of show poster ?
|
#update/check all artwork
|
||||||
changes |= self.updateArtWork(KodiItem,"poster", API().getArtwork(MBitem, "tvshow.poster"),"episode")
|
changes |= self.updateArtWork(KodiItem,MBitem)
|
||||||
changes |= self.updateArtWork(KodiItem,"fanart", API().getArtwork(MBitem, "Backdrop"),"episode")
|
|
||||||
changes |= self.updateArtWork(KodiItem,"clearlogo", API().getArtwork(MBitem, "Logo"),"episode")
|
|
||||||
changes |= self.updateArtWork(KodiItem,"clearart", API().getArtwork(MBitem, "Art"),"episode")
|
|
||||||
changes |= self.updateArtWork(KodiItem,"banner", API().getArtwork(MBitem, "Banner"),"episode")
|
|
||||||
changes |= self.updateArtWork(KodiItem,"landscape", API().getArtwork(MBitem, "Thumb"),"episode")
|
|
||||||
changes |= self.updateArtWork(KodiItem,"discart", API().getArtwork(MBitem, "Disc"),"episode")
|
|
||||||
|
|
||||||
|
|
||||||
#update common properties
|
#update common properties
|
||||||
|
@ -279,34 +260,54 @@ class WriteKodiDB():
|
||||||
utils.logMsg("Updated item to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"])
|
utils.logMsg("Updated item to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"])
|
||||||
|
|
||||||
# adds or updates artwork to the given Kodi file in database
|
# adds or updates artwork to the given Kodi file in database
|
||||||
def updateArtWork(self,KodiItem,artWorkName,artworkValue, fileType):
|
def updateArtWork(self,KodiItem,MBitem):
|
||||||
if fileType == "tvshow":
|
|
||||||
id = KodiItem['tvshowid']
|
|
||||||
jsoncommand = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetTVShowDetails", "params": { "tvshowid": %i, "art": { "%s": "%s" }}, "id": 1 }'
|
|
||||||
elif fileType == "episode":
|
|
||||||
id = KodiItem['episodeid']
|
|
||||||
jsoncommand = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetEpisodeDetails", "params": { "episodeid": %i, "art": { "%s": "%s" }}, "id": 1 }'
|
|
||||||
elif fileType == "musicvideo":
|
|
||||||
id = KodiItem['musicvideoid']
|
|
||||||
jsoncommand = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetMusicVideoDetails", "params": { musicvideoid": %i, "art": { "%s": "%s" }}, "id": 1 }'
|
|
||||||
elif fileType == "movie":
|
|
||||||
id = KodiItem['movieid']
|
|
||||||
jsoncommand = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": { "movieid": %i, "art": { "%s": "%s" }}, "id": 1 }'
|
|
||||||
|
|
||||||
|
item_type=str(MBitem.get("Type"))
|
||||||
|
|
||||||
|
if item_type == "Series":
|
||||||
|
id = KodiItem['tvshowid']
|
||||||
|
jsoncommand = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetTVShowDetails", "params": { "tvshowid": %i, "art": %s}, "id": 1 }'
|
||||||
|
elif item_type == "Episode":
|
||||||
|
id = KodiItem['episodeid']
|
||||||
|
jsoncommand = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetEpisodeDetails", "params": { "episodeid": %i, "art": %s}, "id": 1 }'
|
||||||
|
elif item_type == "MusicVideo":
|
||||||
|
id = KodiItem['musicvideoid']
|
||||||
|
jsoncommand = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetMusicVideoDetails", "params": { musicvideoid": %i, "art": %s}, "id": 1 }'
|
||||||
|
elif item_type == "Movie":
|
||||||
|
id = KodiItem['movieid']
|
||||||
|
jsoncommand = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": { "movieid": %i, "art": %s}, "id": 1 }'
|
||||||
|
|
||||||
|
|
||||||
|
#update artwork
|
||||||
changes = False
|
changes = False
|
||||||
if KodiItem['art'].has_key(artWorkName):
|
|
||||||
curValue = urllib.unquote(KodiItem['art'][artWorkName]).decode('utf8')
|
artwork = {}
|
||||||
if not artworkValue in curValue:
|
artwork["poster"] = API().getArtwork(MBitem, "Primary")
|
||||||
xbmc.sleep(sleepVal)
|
artwork["clearlogo"] = API().getArtwork(MBitem, "Logo")
|
||||||
utils.logMsg("MB3 Syncer", "updating artwork..." + str(artworkValue) + " - " + str(curValue))
|
artwork["clearart"] = API().getArtwork(MBitem, "Art")
|
||||||
xbmc.executeJSONRPC(jsoncommand %(id, artWorkName, artworkValue))
|
artwork["banner"] = API().getArtwork(MBitem, "Banner")
|
||||||
changes = True
|
artwork["landscape"] = API().getArtwork(MBitem, "Thumb")
|
||||||
elif artworkValue != None and artworkValue != "":
|
artwork["discart"] = API().getArtwork(MBitem, "Disc")
|
||||||
xbmc.sleep(sleepVal)
|
artwork["fanart"] = API().getArtwork(MBitem, "Backdrop")
|
||||||
utils.logMsg("MB3 Syncer", "updating artwork..." + str(artworkValue) + " - " + str(artWorkName))
|
|
||||||
xbmc.executeJSONRPC(jsoncommand %(id, artWorkName, artworkValue))
|
|
||||||
changes = True
|
|
||||||
|
|
||||||
|
|
||||||
|
for art in artwork:
|
||||||
|
if artwork.get(art) != None:
|
||||||
|
if KodiItem["art"].has_key(art):
|
||||||
|
if KodiItem["art"][art] != artwork.get(art):
|
||||||
|
KodiItem["art"][art] = artwork.get(art)
|
||||||
|
changes = True
|
||||||
|
else:
|
||||||
|
KodiItem["art"][art] = artwork.get(art)
|
||||||
|
changes = True
|
||||||
|
|
||||||
|
if len(KodiItem["art"]) == 0:
|
||||||
|
changes = False
|
||||||
|
|
||||||
|
if changes:
|
||||||
|
json_array = json.dumps(KodiItem["art"])
|
||||||
|
result = xbmc.executeJSONRPC(jsoncommand %(id, json_array))
|
||||||
|
print result
|
||||||
return changes
|
return changes
|
||||||
|
|
||||||
# adds or updates the given property on the videofile in Kodi database
|
# adds or updates the given property on the videofile in Kodi database
|
||||||
|
@ -364,7 +365,6 @@ class WriteKodiDB():
|
||||||
pendingChanges = False
|
pendingChanges = False
|
||||||
if propertyCollection != None:
|
if propertyCollection != None:
|
||||||
currentvalues = set(KodiItem[propertyName])
|
currentvalues = set(KodiItem[propertyName])
|
||||||
genrestring = ""
|
|
||||||
for item in propertyCollection:
|
for item in propertyCollection:
|
||||||
if not item in currentvalues:
|
if not item in currentvalues:
|
||||||
pendingChanges = True
|
pendingChanges = True
|
||||||
|
|
Loading…
Reference in a new issue