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(): def _get_kodi_type():
kodi_type = listitem.getVideoInfoTag().getMediaType().decode('utf-8') kodi_type = listitem.getVideoInfoTag().getMediaType()
if not kodi_type: if not kodi_type:
if getCondVisibility('Container.Content(albums)'): if getCondVisibility('Container.Content(albums)'):
kodi_type = "album" kodi_type = "album"

View file

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

View file

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

View file

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