From a3ead4199084bbe4f22d7cceaaae0a3472ede530 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Thu, 28 Jun 2018 18:37:07 -0700 Subject: [PATCH] Handle unicode script arguments --- plexpy/notification_handler.py | 2 +- plexpy/notifiers.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 7040e7fe..ed1a6545 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -1028,7 +1028,7 @@ def build_notify_text(subject='', body='', notify_action=None, parameters=None, if agent_id == 15: try: - script_args = [custom_formatter.format(unicode(arg), **parameters) for arg in shlex.split(subject)] + script_args = [custom_formatter.format(arg.decode('utf-8'), **parameters) for arg in shlex.split(subject.encode('utf-8'))] except LookupError as e: logger.error(u"Tautulli NotificationHandler :: Unable to parse parameter %s in script argument. Using fallback." % e) script_args = [] diff --git a/plexpy/notifiers.py b/plexpy/notifiers.py index 56af4831..49d69e21 100644 --- a/plexpy/notifiers.py +++ b/plexpy/notifiers.py @@ -3085,12 +3085,12 @@ class SCRIPTS(Notifier): # For manual notifications if script_args and isinstance(script_args, basestring): # attemps for format it for the user - script_args = shlex.split(script_args) + script_args = [arg.decode('utf-8') for arg in shlex.split(script_args.encode('utf-8'))] # Windows handles unicode very badly. # https://bugs.python.org/issue19264 if script_args and os.name == 'nt': - script_args = [s.encode(plexpy.SYS_ENCODING, 'ignore') for s in script_args] + script_args = [arg.encode(plexpy.SYS_ENCODING, 'ignore') for arg in script_args] # Allow overrides for shitty systems if prefix and script_args: