From 5cbc798cadcb565aa66b91929aa8bec4c5d62cab Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 22 May 2020 20:46:35 -0400 Subject: [PATCH] Allow the device name to have unicode characters --- jellyfin_kodi/jellyfin/api.py | 5 +++-- jellyfin_kodi/jellyfin/http.py | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/jellyfin_kodi/jellyfin/api.py b/jellyfin_kodi/jellyfin/api.py index 48c8f023..1ae8174d 100644 --- a/jellyfin_kodi/jellyfin/api.py +++ b/jellyfin_kodi/jellyfin/api.py @@ -6,7 +6,8 @@ import json import requests from helper.utils import settings -from helper import LazyLogger +from helper import LazyLogger, get_filesystem_encoding +from six import ensure_str LOG = LazyLogger(__name__) @@ -374,7 +375,7 @@ class API(object): "Accept-Charset": "UTF-8,*", "Accept-encoding": "gzip", "User-Agent": self.config.data['http.user_agent'] or "%s/%s" % (self.config.data['app.name'], self.config.data['app.version']), - "x-emby-authorization": auth + "x-emby-authorization": ensure_str(auth, get_filesystem_encoding()) } def send_request(self, url, path, method="get", timeout=None, headers=None, data=None): diff --git a/jellyfin_kodi/jellyfin/http.py b/jellyfin_kodi/jellyfin/http.py index 067d0e41..273718be 100644 --- a/jellyfin_kodi/jellyfin/http.py +++ b/jellyfin_kodi/jellyfin/http.py @@ -6,10 +6,10 @@ from __future__ import division, absolute_import, print_function, unicode_litera import time import requests -from six import string_types +from six import string_types, ensure_str from helper.utils import JsonDebugPrinter -from helper import LazyLogger +from helper import LazyLogger, get_filesystem_encoding from .exceptions import HTTPException @@ -216,12 +216,14 @@ class HTTP(object): auth += "DeviceId=%s, " % self.config.data.get('app.device_id', 'Unknown Device id') auth += "Version=%s" % self.config.data.get('app.version', '0.0.0') - data['headers'].update({'x-emby-authorization': auth}) + data['headers'].update({'x-emby-authorization': ensure_str(auth, get_filesystem_encoding())}) if self.config.data.get('auth.token') and self.config.data.get('auth.user_id'): auth += ', UserId=%s' % self.config.data.get('auth.user_id') - data['headers'].update({'x-emby-authorization': auth, 'X-MediaBrowser-Token': self.config.data.get('auth.token')}) + data['headers'].update({ + 'x-emby-authorization': ensure_str(auth, get_filesystem_encoding()), + 'X-MediaBrowser-Token': self.config.data.get('auth.token')}) return data