Variety of string and bytes fixes

This commit is contained in:
croneter 2020-12-19 08:10:32 +01:00
parent e32fa567bc
commit 382411bff0
4 changed files with 13 additions and 16 deletions

View file

@ -10,7 +10,7 @@ from xbmcgui import Window
def _get_kodi_type():
kodi_type = listitem.getVideoInfoTag().getMediaType().decode('utf-8')
kodi_type = listitem.getVideoInfoTag().getMediaType()
if not kodi_type:
if getCondVisibility('Container.Content(albums)'):
kodi_type = "album"

View file

@ -47,10 +47,9 @@ class Artwork(object):
except ValueError:
# e.g. playlists
pass
artwork = '%s?width=%s&height=%s' % (artwork, width, height)
artwork = ('%s/photo/:/transcode?width=1920&height=1920&'
'minSize=1&upscale=0&url=%s'
% (app.CONN.server, utils.quote(artwork)))
artwork = f'{artwork}?width={width}&height={height}'
artwork = (f'{app.CONN.server}/photo/:/transcode?width=1920&height=1920&'
f'minSize=1&upscale=0&url={utils.quote(artwork)}')
artwork = self.attach_plex_token_to_url(artwork)
return artwork

View file

@ -731,7 +731,7 @@ class WebSocket(object):
def _send(self, data):
try:
return self.sock.send(data)
return self.sock.send(data.encode('utf-8'))
except socket.timeout as e:
raise WebSocketTimeoutException(e.args[0])
except Exception as e:

View file

@ -32,25 +32,23 @@ def get_clean_image(image):
Pass in either unicode or str; returns unicode
'''
if not image:
return ""
if not isinstance(image, str):
image = image.encode('utf-8')
if b"music@" in image:
return ''
if 'music@' in image:
# fix for embedded images
thumbcache = xbmc.getCacheThumbName(image)
thumbcache = thumbcache.replace(b".tbn", b".jpg")
thumbcache = b"special://thumbnails/%s/%s" % (thumbcache[0], thumbcache)
thumbcache = thumbcache.replace('.tbn', '.jpg')
thumbcache = 'special://thumbnails/%s/%s' % (thumbcache[0], thumbcache)
if not xbmcvfs.exists(thumbcache):
xbmcvfs.copy(image, thumbcache)
image = thumbcache
if image and b"image://" in image:
image = image.replace(b"image://", b"")
if image and 'image://' in image:
image = image.replace('image://', '')
image = utils.unquote(image)
if image.endswith("/"):
if image.endswith('/'):
image = image[:-1]
return image
else:
return image.decode('utf-8')
return image
def generate_item(api):