From 1ffd6c0ea13dd68065b4a0640a4eb3075574df35 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Mon, 30 Mar 2020 13:55:17 -0700 Subject: [PATCH] Encode API XML output to UTF-8 --- plexpy/api2.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plexpy/api2.py b/plexpy/api2.py index c7b612c1..7a50f803 100644 --- a/plexpy/api2.py +++ b/plexpy/api2.py @@ -619,9 +619,9 @@ General optional parameters: cherrypy.response.headers['Content-Type'] = 'application/json;charset=UTF-8' try: if self._api_debug: - out = json.dumps(out, indent=4, sort_keys=True, ensure_ascii=False).encode('utf-8') + out = json.dumps(out, indent=4, sort_keys=True, ensure_ascii=False) else: - out = json.dumps(out, ensure_ascii=False).encode('utf-8') + out = json.dumps(out, ensure_ascii=False) if self._api_callback is not None: cherrypy.response.headers['Content-Type'] = 'application/javascript' # wrap with JSONP call if requested @@ -634,7 +634,7 @@ General optional parameters: out['result'] = 'error' elif self._api_out_type == 'xml': - cherrypy.response.headers['Content-Type'] = 'application/xml' + cherrypy.response.headers['Content-Type'] = 'application/xml;charset=UTF-8' try: out = xmltodict.unparse(out, pretty=True) except Exception as e: @@ -655,7 +655,7 @@ General optional parameters: ''' % e - return out + return out.encode('utf-8') def _api_run(self, *args, **kwargs): """ handles the stuff from the handler """