Skip to content

Commit

Permalink
Merge branch 'wip' into matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
sualfred committed Apr 12, 2021
2 parents 6f57fc3 + 14b2499 commit b571bac
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 28 deletions.
4 changes: 2 additions & 2 deletions resources/lib/cinema_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', ''),
Expand All @@ -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'}
)
Expand Down
6 changes: 3 additions & 3 deletions resources/lib/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 14 additions & 10 deletions resources/lib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
import xbmcaddon
import xbmcvfs
import os
from PIL import ImageFilter,Image,ImageOps
from PIL import ImageFilter,Image,ImageOps,ImageEnhance

from resources.lib.helper import *

#################################################################################################

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 = ''

#################################################################################################
Expand All @@ -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

Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions resources/lib/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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'])
Expand All @@ -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']
Expand Down
8 changes: 4 additions & 4 deletions resources/lib/plugin_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand All @@ -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
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion resources/lib/plugin_listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion resources/lib/service_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
'''
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b571bac

Please sign in to comment.