Merge pull request #303 from mcarlton00/more-unicode-hell

Allow the device name to have unicode characters
This commit is contained in:
Odd Stråbø 2020-05-23 16:55:37 +02:00 committed by GitHub
commit 66ef0a5100
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View file

@ -7,6 +7,7 @@ import requests
from helper.utils import settings from helper.utils import settings
from helper import LazyLogger from helper import LazyLogger
from six import ensure_str
LOG = LazyLogger(__name__) LOG = LazyLogger(__name__)
@ -374,7 +375,7 @@ class API(object):
"Accept-Charset": "UTF-8,*", "Accept-Charset": "UTF-8,*",
"Accept-encoding": "gzip", "Accept-encoding": "gzip",
"User-Agent": self.config.data['http.user_agent'] or "%s/%s" % (self.config.data['app.name'], self.config.data['app.version']), "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, 'utf-8')
} }
def send_request(self, url, path, method="get", timeout=None, headers=None, data=None): def send_request(self, url, path, method="get", timeout=None, headers=None, data=None):

View file

@ -6,7 +6,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera
import time import time
import requests import requests
from six import string_types from six import string_types, ensure_str
from helper.utils import JsonDebugPrinter from helper.utils import JsonDebugPrinter
from helper import LazyLogger from helper import LazyLogger
@ -216,12 +216,14 @@ class HTTP(object):
auth += "DeviceId=%s, " % self.config.data.get('app.device_id', 'Unknown Device id') 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') 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, 'utf-8')})
if self.config.data.get('auth.token') and self.config.data.get('auth.user_id'): 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') 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, 'utf-8'),
'X-MediaBrowser-Token': self.config.data.get('auth.token')})
return data return data