diff --git a/jellyfin_kodi/helper/utils.py b/jellyfin_kodi/helper/utils.py index 67d4ecd2..ea93d27f 100644 --- a/jellyfin_kodi/helper/utils.py +++ b/jellyfin_kodi/helper/utils.py @@ -263,7 +263,7 @@ def values(item, keys): ''' Grab the values in the item for a list of keys {key},{key1}.... If the key has no brackets, the key will be passed as is. ''' - return (item[key.replace('{', "").replace('}', "")] if type(key) == str and key.startswith('{') else key for key in keys) + return (item[key.replace('{', "").replace('}', "")] if isinstance(key, text_type) and key.startswith('{') else key for key in keys) def indent(elem, level=0): diff --git a/jellyfin_kodi/jellyfin/http.py b/jellyfin_kodi/jellyfin/http.py index f4cae0d3..e324676c 100644 --- a/jellyfin_kodi/jellyfin/http.py +++ b/jellyfin_kodi/jellyfin/http.py @@ -8,6 +8,7 @@ import logging import time import requests +from six import string_types from .exceptions import HTTPException @@ -188,7 +189,7 @@ class HTTP(object): if isinstance(value, dict): self._process_params(value) - if isinstance(value, str): + if isinstance(value, string_types): params[key] = self._replace_user_info(value) def _get_header(self, data): diff --git a/jellyfin_kodi/jellyfin/websocket.py b/jellyfin_kodi/jellyfin/websocket.py index 2c6a706f..63d471ab 100644 --- a/jellyfin_kodi/jellyfin/websocket.py +++ b/jellyfin_kodi/jellyfin/websocket.py @@ -344,7 +344,7 @@ class ABNF(object): def _get_masked(self, mask_key): s = ABNF.mask(mask_key, self.data) - return mask_key + "".join(s) + return mask_key + b"".join(s) @staticmethod def mask(mask_key, data): @@ -602,7 +602,7 @@ class WebSocket(object): def send_binary(self, payload): return self.send(payload, ABNF.OPCODE_BINARY) - def ping(self, payload=""): + def ping(self, payload=b""): """ send ping data. @@ -784,7 +784,7 @@ class WebSocket(object): _bytes = self._recv(shortage) self._recv_buffer.append(_bytes) shortage -= len(_bytes) - unified = "".join(self._recv_buffer) + unified = b"".join(self._recv_buffer) if shortage == 0: self._recv_buffer = [] return unified @@ -799,7 +799,7 @@ class WebSocket(object): line.append(c) if c == "\n": break - return "".join(line) + return b"".join(line) class WebSocketApp(object): diff --git a/jellyfin_kodi/objects/movies.py b/jellyfin_kodi/objects/movies.py index 5cd8f3ab..99808f9f 100644 --- a/jellyfin_kodi/objects/movies.py +++ b/jellyfin_kodi/objects/movies.py @@ -5,6 +5,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera import logging from six.moves.urllib.parse import urlencode +from kodi_six.utils import py2_encode import downloader as server from .obj import Objects @@ -178,7 +179,7 @@ class Movies(KodiDb): else: obj['Path'] = "plugin://plugin.video.jellyfin/%s/" % obj['LibraryId'] params = { - 'filename': obj['Filename'], + 'filename': py2_encode(obj['Filename'], 'utf-8'), 'id': obj['Id'], 'dbid': obj['MovieId'], 'mode': "play" diff --git a/jellyfin_kodi/objects/musicvideos.py b/jellyfin_kodi/objects/musicvideos.py index b4cca7b2..c106c8a1 100644 --- a/jellyfin_kodi/objects/musicvideos.py +++ b/jellyfin_kodi/objects/musicvideos.py @@ -7,6 +7,7 @@ import datetime import logging import re from six.moves.urllib.parse import urlencode +from kodi_six.utils import py2_encode from .obj import Objects from .kodi import MusicVideos as KodiDb, queries as QU @@ -166,7 +167,7 @@ class MusicVideos(KodiDb): else: obj['Path'] = "plugin://plugin.video.jellyfin/%s/" % obj['LibraryId'] params = { - 'filename': obj['Filename'], + 'filename': py2_encode(obj['Filename'], 'utf-8'), 'id': obj['Id'], 'dbid': obj['MvideoId'], 'mode': "play" diff --git a/jellyfin_kodi/objects/tvshows.py b/jellyfin_kodi/objects/tvshows.py index 9eedf007..0e67c131 100644 --- a/jellyfin_kodi/objects/tvshows.py +++ b/jellyfin_kodi/objects/tvshows.py @@ -8,6 +8,7 @@ import sqlite3 from ntpath import dirname from six.moves.urllib.parse import urlencode +from kodi_six.utils import py2_encode from .obj import Objects from .kodi import TVShows as KodiDb, queries as QU @@ -394,7 +395,7 @@ class TVShows(KodiDb): else: obj['Path'] = "plugin://plugin.video.jellyfin/%s/" % obj['SeriesId'] params = { - 'filename': obj['Filename'], + 'filename': py2_encode(obj['Filename'], 'utf-8'), 'id': obj['Id'], 'dbid': obj['EpisodeId'], 'mode': "play"