def JsonArtwork(self, mediapath, type, arttype, media='video'): self.log("JsonArtwork") arttype = arttype.replace('folder', 'poster').replace( 'character', 'characterart').replace('logo', 'clearlogo').replace( 'disc', 'discart') #correct search names arttype = ((type + '.' + arttype if type == 'tvshow' else arttype)) fletype = '' file_detail = [] try: chanlist = ChannelList() json_query = uni( '{"jsonrpc":"2.0","method":"Files.GetDirectory","params":{"directory":"%s","media":"%s","properties":["art"]},"id":10}' % (chanlist.escapeDirJSON(mediapath), media)) json_folder_detail = chanlist.sendJSON(json_query) file_detail = re.compile("{(.*?)}", re.DOTALL).findall(json_folder_detail) for f in file_detail: arttypes = re.search(('"%s" *: *"(.*?)"' % arttype), f) if arttypes != None and len(arttypes.group(1)) > 0: fletype = (unquote( (arttypes.group(1).split(','))[0])).replace( 'image://', '').replace('.jpg/', '.jpg').replace('.png/', '.png') break except Exception: buggalo.onExceptionRaised() self.log("JsonArtwork, fletype = " + fletype) return fletype
def JsonArtwork(self, mpath, media='video'): print('JsonArtwork') file_detail = [] try: chanlist = ChannelList() json_query = uni( '{"jsonrpc":"2.0","method":"Files.GetDirectory","params":{"directory":"%s","media":"%s","properties":["art"]},"id":10}' % (chanlist.escapeDirJSON(mpath), media)) json_folder_detail = chanlist.sendJSON(json_query) file_detail = re.compile("{(.*?)}", re.DOTALL).findall(json_folder_detail) print('JsonArtwork - return') except: pass return file_detail
def JsonThumb(self, mediapath, media='video'): self.log("JsonThumb") file_detail = [] thumbnail = '' try: chanlist = ChannelList() json_query = ( '{jsonrpc":"2.0","method":"Files.GetDirectory","params":{"directory":"%s","properties":["thumbnail"]}, "id": 1}' % (chanlist.escapeDirJSON(mediapath))) json_folder_detail = chanlist.sendJSON(json_query) file_detail = re.compile("{(.*?)}", re.DOTALL).findall(json_folder_detail) for f in file_detail: thumbnails = re.search('"thumbnail" *: *"(.*?)"', f) if thumbnails != None and len(thumbnails.group(1)) > 0: thumbnail = thumbnails.group(1) break except Exception: buggalo.onExceptionRaised() self.log("JsonThumb, thumbnail = " + thumbnail) return thumbnail
def JsonArtwork(self, mpath, media='video'): print ('JsonArtwork') file_detail = [] try: chanlist = ChannelList() json_query = uni('{"jsonrpc":"2.0","method":"Files.GetDirectory","params":{"directory":"%s","media":"%s","properties":["art"]},"id":10}' % (chanlist.escapeDirJSON(mpath), media)) json_folder_detail = chanlist.sendJSON(json_query) file_detail = re.compile( "{(.*?)}", re.DOTALL ).findall(json_folder_detail) print ('JsonArtwork - return') except: pass return file_detail
class Artdownloader: def __init__(self): self.chanlist = ChannelList() def log(self, msg, level=xbmc.LOGDEBUG): log('Artdownloader: ' + msg, level) def logDebug(self, msg, level=xbmc.LOGDEBUG): if DEBUG == 'true': log('Artdownloader: ' + msg, level) def dbidArt(self, type, chname, mpath, dbid, arttypeEXT): self.log("dbidArt") # Set image place-holder thumbnail = self.SetDefaultArt(chname, mpath, arttypeEXT) if type == 'tvshow': json_query = ( '{"jsonrpc":"2.0","method":"VideoLibrary.GetTVShowDetails","params":{"tvshowid":%s,"properties":["art"]},"id":1}' % dbid) elif type == 'movie': json_query = ( '{"jsonrpc":"2.0","method":"VideoLibrary.GetMovieDetails","params":{"movieid":%s,"properties":["art"]},"id":1}' % dbid) else: return thumbnail arttype = (arttypeEXT.split(".")[0]).replace('landscape', 'fanart') json_folder_detail = self.chanlist.sendJSON(json_query) file_detail = re.compile("{(.*?)}", re.DOTALL).findall(json_folder_detail) for f in file_detail: arttypes = re.search(('"%s" *: *"(.*?)"' % arttype), f) if arttypes != None and len(arttypes.group(1)) > 0: thumbnail = (unquote( xbmc.translatePath( (arttypes.group(1).split(','))[0]))).replace( 'image://', '').replace('.jpg/', '.jpg').replace('.png/', '.png') break self.log("dbidArt, thumbnail = " + thumbnail) return thumbnail def JsonThumb(self, chname, arttypeEXT, mediapath, media='video'): self.log("JsonThumb") file_detail = [] # Set image place-holder thumbnail = self.SetDefaultArt(chname, mpath, arttypeEXT) json_query = ( '{jsonrpc":"2.0","method":"Files.GetDirectory","params":{"directory":"%s","properties":["thumbnail"]}, "id": 1}' % (self.chanlist.escapeDirJSON(mediapath))) json_folder_detail = self.chanlist.sendJSON(json_query) file_detail = re.compile("{(.*?)}", re.DOTALL).findall(json_folder_detail) for f in file_detail: thumbnails = re.search('"thumbnail" *: *"(.*?)"', f) if thumbnails != None and len(thumbnails.group(1)) > 0: thumbnail = (unquote( xbmc.translatePath( (thumbnails.group(1).split(','))[0]))).replace( 'image://', '').replace('.jpg/', '.jpg').replace('.png/', '.png') break self.log("JsonThumb, thumbnail = " + thumbnail) return thumbnail def AlphaLogo(self, org, mod): self.log("AlphaLogo") img = Image.open(org) img = img.convert("RGBA") datas = img.getdata() newData = [] for item in datas: if item[0] == 255 and item[1] == 255 and item[2] == 255: newData.append((255, 255, 255, 0)) else: newData.append(item) img.putdata(newData) img.save(mod, "PNG") #Covert to transparent logo def ConvertBug(self, org, mod): self.log("ConvertBug") drive, path = os.path.splitdrive(mod) path, filename = os.path.split(path) try: if not FileAccess.exists(path): FileAccess.makedirs(path) org = xbmc.translatePath(org) original = Image.open(org) converted_img = original.convert('LA') img_bright = ImageEnhance.Brightness(converted_img) converted_img = img_bright.enhance(1.0) converted_img.save(mod) return mod except Exception, e: self.log("ConvertBug Failed! " + str(e)) pass
class Artdownloader: def __init__(self): self.chanlist = ChannelList() self.fanarttv = fanarttv() self.tvdbAPI = tvdb.TVDB(TVDB_API_KEY) self.tmdbAPI = tmdb.TMDB(TMDB_API_KEY) def log(self, msg, level = xbmc.LOGDEBUG): log('Artdownloader: ' + msg, level) def logDebug(self, msg, level = xbmc.LOGDEBUG): if DEBUG == 'true': log('Artdownloader: ' + msg, level) def dbidArt(self, type, chname, mpath, dbid, arttypeEXT): self.log("dbidArt") # Set image place-holder thumbnail = self.SetDefaultArt(chname, mpath, arttypeEXT) if type == 'tvshow': json_query = ('{"jsonrpc":"2.0","method":"VideoLibrary.GetTVShowDetails","params":{"tvshowid":%s,"properties":["art"]},"id":1}' % dbid) elif type == 'movie': json_query = ('{"jsonrpc":"2.0","method":"VideoLibrary.GetMovieDetails","params":{"movieid":%s,"properties":["art"]},"id":1}' % dbid) else: return thumbnail arttype = (arttypeEXT.split(".")[0]).replace('landscape','fanart') json_folder_detail = self.chanlist.sendJSON(json_query) file_detail = re.compile( "{(.*?)}", re.DOTALL ).findall(json_folder_detail) for f in file_detail: arttypes = re.search(('"%s" *: *"(.*?)"' % arttype), f) if arttypes != None and len(arttypes.group(1)) > 0: thumbnail = (unquote(xbmc.translatePath((arttypes.group(1).split(','))[0]))).replace('image://','').replace('.jpg/','.jpg').replace('.png/','.png') break self.log("dbidArt, thumbnail = " + thumbnail) return thumbnail def JsonThumb(self, chname, arttypeEXT, mediapath, media='video'): self.log("JsonThumb") file_detail = [] # Set image place-holder thumbnail = self.SetDefaultArt(chname, mpath, arttypeEXT) json_query = ('{jsonrpc":"2.0","method":"Files.GetDirectory","params":{"directory":"%s","properties":["thumbnail"]}, "id": 1}' % (self.chanlist.escapeDirJSON(mediapath))) json_folder_detail = self.chanlist.sendJSON(json_query) file_detail = re.compile( "{(.*?)}", re.DOTALL ).findall(json_folder_detail) for f in file_detail: thumbnails = re.search('"thumbnail" *: *"(.*?)"', f) if thumbnails != None and len(thumbnails.group(1)) > 0: thumbnail = (unquote(xbmc.translatePath((thumbnails.group(1).split(','))[0]))).replace('image://','').replace('.jpg/','.jpg').replace('.png/','.png') break self.log("JsonThumb, thumbnail = " + thumbnail) return thumbnail def AlphaLogo(self, org, mod): self.log("AlphaLogo") img = Image.open(org) img = img.convert("RGBA") datas = img.getdata() newData = [] for item in datas: if item[0] == 255 and item[1] == 255 and item[2] == 255: newData.append((255, 255, 255, 0)) else: newData.append(item) img.putdata(newData) img.save(mod, "PNG") #Covert to transparent logo def ConvertBug(self, org, mod): self.log("ConvertBug") drive, path = os.path.splitdrive(mod) path, filename = os.path.split(path) try: if not FileAccess.exists(path): FileAccess.makedirs(path) org = xbmc.translatePath(org) original = Image.open(org) converted_img = original.convert('LA') img_bright = ImageEnhance.Brightness(converted_img) converted_img = img_bright.enhance(1.0) converted_img.save(mod) return mod except Exception,e: self.log("ConvertBug Failed! " + str(e)) pass