From 8d816414b8db04ac8df0d55cac00b7cc9471db99 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Sat, 15 Sep 2018 03:16:37 -0500 Subject: [PATCH] Fix http potential errors Prevent from going further if {server} or {userid} is requested but not filled to avoid 401 errors --- resources/lib/emby/core/http.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/resources/lib/emby/core/http.py b/resources/lib/emby/core/http.py index 64b15641..f76e2301 100644 --- a/resources/lib/emby/core/http.py +++ b/resources/lib/emby/core/http.py @@ -53,11 +53,17 @@ class HTTP(object): def _replace_user_info(self, string): - if self.config['auth.server']: - string = string.decode('utf-8').replace("{server}", self.config['auth.server']) + if '{server}' in string: + if self.config['auth.server']: + string = string.decode('utf-8').replace("{server}", self.config['auth.server']) + else: + raise Exception("Server address not set.") - if self.config['auth.user_id']: - string = string.decode('utf-8').replace("{UserId}", self.config['auth.user_id']) + if '{UserId}'in string: + if self.config['auth.user_id']: + string = string.decode('utf-8').replace("{UserId}", self.config['auth.user_id']) + else: + raise Exception("UserId is not set.") return string