diff --git a/resources/lib/cinema_mode.py b/resources/lib/cinema_mode.py index 794e949..6da8a55 100644 --- a/resources/lib/cinema_mode.py +++ b/resources/lib/cinema_mode.py @@ -48,7 +48,7 @@ def run(self): trailer_rating = str(round(trailer['rating'], 1)) trailer_thumb = trailer['art'].get('landscape') or trailer['art'].get('fanart') or trailer['art'].get('poster', '') - listitem = xbmcgui.ListItem(trailer_title) + listitem = xbmcgui.ListItem(trailer_title, offscreen=True) listitem.setInfo('video', {'Title': trailer_title, 'mediatype': 'video', 'plot': trailer.get('plot', ''), @@ -69,7 +69,7 @@ def run(self): if self.intro_path: intro = self.get_intros() if intro: - listitem = xbmcgui.ListItem('Intro') + listitem = xbmcgui.ListItem('Intro', offscreen=True) listitem.setInfo('video', {'Title': 'Intro', 'mediatype': 'video'} ) diff --git a/resources/lib/helper.py b/resources/lib/helper.py index 21d39df..da839ae 100644 --- a/resources/lib/helper.py +++ b/resources/lib/helper.py @@ -20,9 +20,9 @@ ADDON = xbmcaddon.Addon() ADDON_ID = ADDON.getAddonInfo('id') -ADDON_DATA_PATH = os.path.join(xbmc.translatePath("special://profile/addon_data/%s" % ADDON_ID)) -ADDON_DATA_IMG_PATH = os.path.join(xbmc.translatePath("special://profile/addon_data/%s/img" % ADDON_ID)) -ADDON_DATA_IMG_TEMP_PATH = os.path.join(xbmc.translatePath("special://profile/addon_data/%s/img/tmp" % ADDON_ID)) +ADDON_DATA_PATH = os.path.join(xbmcvfs.translatePath("special://profile/addon_data/%s" % ADDON_ID)) +ADDON_DATA_IMG_PATH = os.path.join(xbmcvfs.translatePath("special://profile/addon_data/%s/img" % ADDON_ID)) +ADDON_DATA_IMG_TEMP_PATH = os.path.join(xbmcvfs.translatePath("special://profile/addon_data/%s/img/tmp" % ADDON_ID)) INFO = xbmc.LOGINFO WARNING = xbmc.LOGWARNING diff --git a/resources/lib/image.py b/resources/lib/image.py index d3fb83a..368db88 100644 --- a/resources/lib/image.py +++ b/resources/lib/image.py @@ -9,7 +9,7 @@ import xbmcaddon import xbmcvfs import os -from PIL import ImageFilter,Image,ImageOps +from PIL import ImageFilter,Image,ImageOps,ImageEnhance from resources.lib.helper import * @@ -17,6 +17,7 @@ BLUR_CONTAINER = xbmc.getInfoLabel('Skin.String(BlurContainer)') or 100000 BLUR_RADIUS = xbmc.getInfoLabel('Skin.String(BlurRadius)') or ADDON.getSetting('blur_radius') +BLUR_SATURATION = xbmc.getInfoLabel('Skin.String(BlurSaturation)') or '1.0' OLD_IMAGE = '' ################################################################################################# @@ -39,16 +40,14 @@ ''' blur image and store result in addon data folder ''' class ImageBlur(): - def __init__(self,prop='listitem',file=None,radius=None): + def __init__(self,prop='listitem',file=None,radius=None,saturation=None): global OLD_IMAGE self.image = file if file is not None else xbmc.getInfoLabel('Control.GetLabel(%s)' % BLUR_CONTAINER) self.radius = int(radius) if radius is not None else int(BLUR_RADIUS) + self.saturation = float(saturation) if saturation is not None else float(BLUR_SATURATION) if self.image: - if self.image == OLD_IMAGE: - log('Image blurring: Image has not changed. Skip %s.' % self.image, DEBUG) - - else: + if self.image != OLD_IMAGE: log('Image blurring: Image changed. Blur %s.' % self.image, DEBUG) OLD_IMAGE = self.image @@ -63,7 +62,7 @@ def __str__(self): return self.filepath, self.avgcolor def blur(self): - filename = md5hash(self.image) + str(self.radius) + '.png' + filename = md5hash(self.image) + str(self.radius) + str(self.saturation) + '.png' targetfile = os.path.join(ADDON_DATA_IMG_PATH, filename) try: @@ -74,6 +73,11 @@ def blur(self): img.thumbnail((200, 200), Image.ANTIALIAS) img = img.convert('RGB') img = img.filter(ImageFilter.GaussianBlur(self.radius)) + + if self.saturation: + converter = ImageEnhance.Color(img) + img = converter.enhance(self.saturation) + img.save(targetfile) return targetfile @@ -92,7 +96,7 @@ def color(self): col = imgResize.getpixel((0,0)) imagecolor = 'FF%s%s%s' % (format(col[0], '02x'), format(col[1], '02x'), format(col[2], '02x')) log('Average color: ' + imagecolor, DEBUG) - + except: log('Use fallback average color: ' + imagecolor, DEBUG) pass @@ -206,7 +210,7 @@ def _openimage(image,targetpath,filename): for cache in cached_files: if xbmcvfs.exists(cache): try: - img = Image.open(xbmc.translatePath(cache)) + img = Image.open(xbmcvfs.translatePath(cache)) return img except Exception as error: @@ -220,7 +224,7 @@ def _openimage(image,targetpath,filename): image = os.path.join('special://skin/media/', image) try: # in case image is packed in textures.xbt - img = Image.open(xbmc.translatePath(image)) + img = Image.open(xbmcvfs.translatePath(image)) return img except Exception: diff --git a/resources/lib/library.py b/resources/lib/library.py index 7fe8c74..37ac5db 100644 --- a/resources/lib/library.py +++ b/resources/lib/library.py @@ -34,7 +34,7 @@ def handle_movies(li,item,searchstring=None): director = item.get('director', '') writer = item.get('writer', '') - li_item = xbmcgui.ListItem(item['title']) + li_item = xbmcgui.ListItem(item['title'], offscreen=True) li_item.setInfo(type='Video', infoLabels={'title': item['title'], 'originaltitle': item['originaltitle'], 'sorttitle': item['sorttitle'], @@ -118,7 +118,7 @@ def handle_tvshows(li,item,searchstring=None): folder = False item['file'] = 'plugin://script.embuary.helper/?action=folderjump&type=tvshow&dbid=%s' % dbid - li_item = xbmcgui.ListItem(item['title']) + li_item = xbmcgui.ListItem(item['title'], offscreen=True) li_item.setInfo(type='Video', infoLabels={'title': item['title'], 'year': item['year'], 'tvshowtitle': item['title'], @@ -190,7 +190,7 @@ def handle_seasons(li,item): folder = False file = 'plugin://script.embuary.helper/?action=folderjump&type=season&dbid=%s&season=%s' % (tvshowdbid, season) - li_item = xbmcgui.ListItem(title) + li_item = xbmcgui.ListItem(title, offscreen=True) li_item.setInfo(type='Video', infoLabels={'title': title, 'season': season, 'episode': episode, @@ -227,7 +227,7 @@ def handle_episodes(li,item): else: label = '%sx%s' % (item['season'], label) - li_item = xbmcgui.ListItem(label) + li_item = xbmcgui.ListItem(label, offscreen=True) li_item.setInfo(type='Video', infoLabels={'title': item['title'], 'episode': item['episode'], 'season': item['season'], @@ -290,7 +290,7 @@ def handle_episodes(li,item): def handle_cast(li,item): - li_item = xbmcgui.ListItem(item['name']) + li_item = xbmcgui.ListItem(item['name'], offscreen=True) li_item.setLabel(item['name']) li_item.setLabel2(item['role']) li_item.setProperty('role', item['role']) @@ -303,7 +303,7 @@ def handle_cast(li,item): def handle_genre(li,item): - li_item = xbmcgui.ListItem(item['label']) + li_item = xbmcgui.ListItem(item['label'], offscreen=True) li_item.setInfo(type='Video', infoLabels={'title': item['label'], 'dbid': str(item['genreid']), 'path': item['url'] diff --git a/resources/lib/plugin_content.py b/resources/lib/plugin_content.py index 7efd5f7..d581e90 100644 --- a/resources/lib/plugin_content.py +++ b/resources/lib/plugin_content.py @@ -149,7 +149,7 @@ def getbyargs(self): ''' def getresourceimages(self): resource_addon = self.params.get('addon') - resource_dir = xbmc.translatePath('resource://%s/' % resource_addon) + resource_dir = xbmcvfs.translatePath('resource://%s/' % resource_addon) string = remove_quotes(self.params.get('string')) separator = remove_quotes(self.params.get('separator')) @@ -163,7 +163,7 @@ def getresourceimages(self): for filename in ['%s.jpg' % item, '%s.png' % item]: filepath = resource_dir + filename if xbmcvfs.exists(filepath): - list_item = xbmcgui.ListItem(label=item) + list_item = xbmcgui.ListItem(label=item, offscreen=True) list_item.setArt({'icon': filepath}) self.li.append(('', list_item, False)) break @@ -1025,7 +1025,7 @@ def jumptoletter(self): return for letter in alphabet: - li_item = xbmcgui.ListItem(label=letter) + li_item = xbmcgui.ListItem(label=letter, offscreen=True) if letter == '#' and first_number: li_path = 'plugin://script.embuary.helper/?action=smsjump&letter=0' @@ -1065,7 +1065,7 @@ def getfanartsbypath(self): if not arts.get('fanart'): continue - li_item = xbmcgui.ListItem(label=item.get('title')) + li_item = xbmcgui.ListItem(label=item.get('title'), offscreen=True) li_item.setArt(arts) self.li.append(('', li_item, False)) diff --git a/resources/lib/plugin_listing.py b/resources/lib/plugin_listing.py index 2a7afe1..cf344c3 100644 --- a/resources/lib/plugin_listing.py +++ b/resources/lib/plugin_listing.py @@ -191,7 +191,7 @@ def _encode_url(self,**kwargs): def _add_item(self,label,url): icon = 'special://home/addons/' + ADDON_ID + '/resources/icon.png' - list_item = xbmcgui.ListItem(label=label) + list_item = xbmcgui.ListItem(label=label, offscreen=True) list_item.setInfo('video', {'title': label, 'mediatype': 'video'}) list_item.setArt({'icon': 'DefaultFolder.png','thumb': icon}) self.li.append((url, list_item, True)) diff --git a/resources/lib/service_monitor.py b/resources/lib/service_monitor.py index 39e2516..92022fe 100644 --- a/resources/lib/service_monitor.py +++ b/resources/lib/service_monitor.py @@ -134,7 +134,8 @@ def start(self): ''' if condition('Skin.HasSetting(BlurEnabled)'): radius = xbmc.getInfoLabel('Skin.String(BlurRadius)') or ADDON.getSetting('blur_radius') - ImageBlur(radius=radius) + saturation = xbmc.getInfoLabel('Skin.String(BlurSaturation)') + ImageBlur(radius=radius, saturation=saturation) ''' Refresh widgets ''' diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 8c42961..13677cc 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -568,7 +568,7 @@ def details_by_season(params): def txtfile(params): prop = params.get('prop') - path = xbmc.translatePath(remove_quotes(params.get('path'))) + path = xbmcvfs.translatePath(remove_quotes(params.get('path'))) if os.path.isfile(path): log('Reading file %s' % path)