From 28862b309c6973f0db865ccde2a501a08dddd4c3 Mon Sep 17 00:00:00 2001 From: im85288 Date: Wed, 25 Mar 2015 14:00:08 +0000 Subject: [PATCH] added extra fanart sync --- resources/lib/CreateFiles.py | 26 ++++++++++++++++++++++++++ resources/lib/ReadEmbyDB.py | 17 +++++++++++++++++ resources/lib/WriteKodiDB.py | 12 ++++++++++++ resources/settings.xml | 2 +- 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/resources/lib/CreateFiles.py b/resources/lib/CreateFiles.py index fdb8f9fd..63a6239d 100644 --- a/resources/lib/CreateFiles.py +++ b/resources/lib/CreateFiles.py @@ -299,6 +299,32 @@ class CreateFiles(): if mediasources[0]["Container"] == "mp3": themeUrl = PlayUtils().getPlayUrl(server,themeItems[0]["Id"],themeItems[0]) xbmcvfs.copy(themeUrl,themeFile) + + def copyExtraFanart(self,item): + downloadUtils = DownloadUtils() + userid = downloadUtils.getUserId() + port = addon.getSetting('port') + host = addon.getSetting('ipaddress') + server = host + ":" + port + item_type=str(item.get("Type")) + + if item_type == "Movie": + itemPath = os.path.join(movieLibrary,item["Id"]) + fanartDir = os.path.join(itemPath,"extrafanart" + os.sep) + if item_type == "Series": + itemPath = os.path.join(tvLibrary,item["Id"]) + fanartDir = os.path.join(itemPath,"extrafanart" + os.sep) + + if not xbmcvfs.exists(fanartDir): + utils.logMsg("MB3 Syncer","creating extrafanart directory ",2) + xbmcvfs.mkdir(fanartDir) + fullItem = ReadEmbyDB().getFullItem(item["Id"]) + if(fullItem != None and fullItem["BackdropImageTags"] != None and len(fullItem["BackdropImageTags"]) > 1): + totalbackdrops = len(fullItem["BackdropImageTags"]) + for index in range(1,totalbackdrops): + backgroundUrl = API().getArtwork(fullItem, "Backdrop",str(index)) + fanartFile = os.path.join(fanartDir,"fanart" + str(index) + ".jpg") + xbmcvfs.copy(backgroundUrl,fanartFile) def CleanName(self, filename): validFilenameChars = "-_.() %s%s" % (string.ascii_letters, string.digits) diff --git a/resources/lib/ReadEmbyDB.py b/resources/lib/ReadEmbyDB.py index efc54838..232f3242 100644 --- a/resources/lib/ReadEmbyDB.py +++ b/resources/lib/ReadEmbyDB.py @@ -87,6 +87,23 @@ class ReadEmbyDB(): return result + def getFullItem(self, id): + result = None + + addon = xbmcaddon.Addon(id='plugin.video.mb3sync') + port = addon.getSetting('port') + host = addon.getSetting('ipaddress') + server = host + ":" + port + + downloadUtils = DownloadUtils() + userid = downloadUtils.getUserId() + + jsonData = downloadUtils.downloadUrl("http://" + server + "/mediabrowser/Users/" + userid + "/Items/" + id + "?format=json", suppress=False, popup=1 ) + if jsonData != None and jsonData != "": + result = json.loads(jsonData) + + return result + def getTVShows(self, fullinfo = False, fullSync = False): result = None diff --git a/resources/lib/WriteKodiDB.py b/resources/lib/WriteKodiDB.py index 143cdb2d..fee8406c 100644 --- a/resources/lib/WriteKodiDB.py +++ b/resources/lib/WriteKodiDB.py @@ -171,6 +171,10 @@ class WriteKodiDB(): #add theme music if addon.getSetting("syncThemeMusic") == "true": CreateFiles().copyThemeMusic(MBitem) + + #add extra fanart + if addon.getSetting("syncExtraFanart") == "true": + CreateFiles().copyExtraFanart(MBitem) if(changes): utils.logMsg("Updated item to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"], level=0) @@ -314,6 +318,10 @@ class WriteKodiDB(): #add theme music if addon.getSetting("syncThemeMusic") == "true": CreateFiles().copyThemeMusic(MBitem) + + #add extra fanart + if addon.getSetting("syncExtraFanart") == "true": + CreateFiles().copyExtraFanart(MBitem) if changes: utils.logMsg("Updated item to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"]) @@ -380,6 +388,10 @@ class WriteKodiDB(): if addon.getSetting("syncThemeMusic") == "true": CreateFiles().copyThemeMusic(MBitem) + #add extra fanart + if addon.getSetting("syncExtraFanart") == "true": + CreateFiles().copyExtraFanart(MBitem) + if changes: utils.logMsg("Updated item to Kodi Library", MBitem["Id"] + " - " + MBitem["Name"]) diff --git a/resources/settings.xml b/resources/settings.xml index db460547..805b0cce 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -27,7 +27,7 @@ - +