diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 05a1fee..22f50c5 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -18,10 +18,6 @@ msgctxt "#30001" msgid "Port" msgstr "" -msgctxt "#30002" -msgid "Use HTTPS" -msgstr "" - msgctxt "#30003" msgid "Verify HTTPS certificate" msgstr "" @@ -342,12 +338,8 @@ msgctxt "#30252" msgid "Movies (A-Z)" msgstr "" -msgctxt "#30253" -msgid "Change User" -msgstr "" - msgctxt "#30254" -msgid "Show Settings" +msgid "Show add-on settings" msgstr "" msgctxt "#30255" @@ -503,7 +495,7 @@ msgid "Select Subtitle Stream" msgstr "" msgctxt "#30293" -msgid "Cache Artwork" +msgid "Cache images" msgstr "" msgctxt "#30294" @@ -807,7 +799,7 @@ msgid "Do you want to manually enter a server url?" msgstr "" msgctxt "#30371" -msgid "The server url you entered is not valid, do you want to try again?" +msgid "Could not connect to the URL you entered, do you want to try again?" msgstr "" msgctxt "#30372" @@ -881,3 +873,15 @@ msgstr "" msgctxt "#30389" msgid "User details" msgstr "" + +msgctxt "#30390" +msgid "Protocol" +msgstr "" + +msgctxt "#30391" +msgid "HTTP" +msgstr "" + +msgctxt "#30392" +msgid "HTTPS" +msgstr "" \ No newline at end of file diff --git a/resources/lib/datamanager.py b/resources/lib/datamanager.py index e4fde19..0616f7e 100644 --- a/resources/lib/datamanager.py +++ b/resources/lib/datamanager.py @@ -60,7 +60,7 @@ class DataManager(): server = download_utils.getServer() m = hashlib.md5() - m.update(user_id + "|" + server + "|" + url) + m.update(user_id + "|" + str(server) + "|" + url) url_hash = m.hexdigest() cache_file = os.path.join(self.addon_dir, "cache_" + url_hash + ".pickle") diff --git a/resources/lib/downloadutils.py b/resources/lib/downloadutils.py index f06b4fe..267e234 100644 --- a/resources/lib/downloadutils.py +++ b/resources/lib/downloadutils.py @@ -81,8 +81,12 @@ class DownloadUtils: def __init__(self, *args): settings = xbmcaddon.Addon() - self.use_https = settings.getSetting('use_https') == 'true' + + self.use_https = False + if settings.getSetting('protocol') == "1": + self.use_https = True log.debug("use_https: {0}", self.use_https) + self.verify_cert = settings.getSetting('verify_cert') == 'true' log.debug("verify_cert: {0}", self.verify_cert) @@ -262,7 +266,7 @@ class DownloadUtils: if not port and self.use_https: port = "443" settings.setSetting("port", port) - elif not port and not self.use_https: + elif not port: port = "80" settings.setSetting("port", port) @@ -272,14 +276,18 @@ class DownloadUtils: url_bits = urlparse(host.strip()) if host.lower().strip().startswith("http://"): - settings.setSetting('use_https', 'false') + settings.setSetting('protocol', '0') self.use_https = False elif host.lower().strip().startswith("https://"): - settings.setSetting('use_https', 'true') + settings.setSetting('protocol', '1') self.use_https = True if url_bits.hostname is not None and len(url_bits.hostname) > 0: host = url_bits.hostname + + if url_bits.username and url_bits.password: + host = "%s:%s@" % (url_bits.username, url_bits.password) + host + settings.setSetting("ipaddress", host) if url_bits.port is not None and url_bits.port > 0: @@ -620,39 +628,20 @@ class DownloadUtils: url_path = url_bits.path url_puery = url_bits.query - ''' - if url.startswith('http'): - serversplit = 2 - urlsplit = 3 - else: - serversplit = 0 - urlsplit = 1 - - server = url.split('/')[serversplit] - urlPath = "/" + "/".join(url.split('/')[urlsplit:]) - - log.debug("DOWNLOAD_URL: {0}", url) - log.debug("server: {0}", server) - log.debug("urlPath: {0}", urlPath) - - # check the server details - tokens = server.split(':') - host = tokens[0] - port = tokens[1] - if host == "" or host == "" or port == "": - return return_data - ''' - if not host_name or host_name == "": return return_data + local_use_https = False + if protocol.lower() == "https": + local_use_https = True + server = "%s:%s" % (host_name, port) urlPath = url_path + "?" + url_puery - if self.use_https and self.verify_cert: + if local_use_https and self.verify_cert: log.debug("Connection: HTTPS, Cert checked") conn = httplib.HTTPSConnection(server, timeout=40) - elif self.use_https and not self.verify_cert: + elif local_use_https and not self.verify_cert: log.debug("Connection: HTTPS, Cert NOT checked") conn = httplib.HTTPSConnection(server, timeout=40, context=ssl._create_unverified_context()) else: diff --git a/resources/lib/menu_functions.py b/resources/lib/menu_functions.py index 5b55d26..734bc1e 100644 --- a/resources/lib/menu_functions.py +++ b/resources/lib/menu_functions.py @@ -314,7 +314,7 @@ def displaySections(): addMenuDirectoryItem(string_load(30383) + string_load(30246), "plugin://plugin.video.embycon/?mode=SEARCH") addMenuDirectoryItem(string_load(30383) + string_load(30017), "plugin://plugin.video.embycon/?mode=SHOW_SERVER_SESSIONS") - addMenuDirectoryItem(string_load(30383) + string_load(30253), "plugin://plugin.video.embycon/?mode=CHANGE_USER") + addMenuDirectoryItem(string_load(30383) + string_load(30012), "plugin://plugin.video.embycon/?mode=CHANGE_USER") addMenuDirectoryItem(string_load(30383) + string_load(30011), "plugin://plugin.video.embycon/?mode=DETECT_SERVER_USER") addMenuDirectoryItem(string_load(30383) + string_load(30254), "plugin://plugin.video.embycon/?mode=SHOW_SETTINGS") diff --git a/resources/lib/server_detect.py b/resources/lib/server_detect.py index 3ec33b6..625535f 100644 --- a/resources/lib/server_detect.py +++ b/resources/lib/server_detect.py @@ -21,7 +21,6 @@ log = SimpleLogging(__name__) __addon__ = xbmcaddon.Addon() __addon_name__ = __addon__.getAddonInfo('name') -downloadUtils = DownloadUtils() def getServerDetails(): @@ -76,10 +75,11 @@ def checkServer(force=False, change_user=False, notify=False): settings = xbmcaddon.Addon() server_url = "" something_changed = False + du = DownloadUtils() if force is False: # if not forcing use server details from settings - svr = downloadUtils.getServer() + svr = du.getServer() if svr is not None: server_url = svr @@ -133,13 +133,19 @@ def checkServer(force=False, change_user=False, notify=False): server_address = url_bits.hostname server_port = str(url_bits.port) server_protocol = url_bits.scheme + user_name = url_bits.username + user_password = url_bits.password - temp_url = "%s://%s:%s/emby/Users/Public?format=json" % (server_protocol, server_address, server_port) + if user_name and user_password: + temp_url = "%s://%s:%s@%s:%s/emby/Users/Public?format=json" % (server_protocol, user_name, user_password, server_address, server_port) + else: + temp_url = "%s://%s:%s/emby/Users/Public?format=json" % (server_protocol, server_address, server_port) + log.debug("Testing_Url: {0}", temp_url) progress = xbmcgui.DialogProgress() progress.create(__addon_name__ + " : " + string_load(30376)) progress.update(0, string_load(30377)) - json_data = downloadUtils.downloadUrl(temp_url, authenticate=False) + json_data = du.downloadUrl(temp_url, authenticate=False) progress.close() result = json.loads(json_data) @@ -162,16 +168,22 @@ def checkServer(force=False, change_user=False, notify=False): server_address = url_bits.hostname server_port = str(url_bits.port) server_protocol = url_bits.scheme + user_name = url_bits.username + user_password = url_bits.password log.debug("Detected server info {0} - {1} - {2}", server_protocol, server_address, server_port) # save the server info settings.setSetting("port", server_port) + + if user_name and user_password: + server_address = "%s:%s@%s" % (url_bits.username, url_bits.password, server_address) + settings.setSetting("ipaddress", server_address) if server_protocol == "https": - settings.setSetting("use_https", "true") + settings.setSetting("protocol", "1") else: - settings.setSetting("use_https", "false") + settings.setSetting("protocol", "0") something_changed = True @@ -185,10 +197,11 @@ def checkServer(force=False, change_user=False, notify=False): # stop playback when switching users xbmc.Player().stop() + du = DownloadUtils() # get a list of users log.debug("Getting user list") - json_data = downloadUtils.downloadUrl(server_url + "/emby/Users/Public?format=json", authenticate=False) + json_data = du.downloadUrl(server_url + "/emby/Users/Public?format=json", authenticate=False) log.debug("jsonData: {0}", json_data) try: @@ -236,7 +249,7 @@ def checkServer(force=False, change_user=False, notify=False): log.debug("LastActivityDate: {0}", time_ago) user_item = xbmcgui.ListItem(name) - user_image = downloadUtils.get_user_artwork(user, 'Primary') + user_image = du.get_user_artwork(user, 'Primary') if not user_image: user_image = "DefaultUser.png" art = {"Thumb": user_image} @@ -357,8 +370,8 @@ def checkServer(force=False, change_user=False, notify=False): home_window.clearProperty("AccessToken") home_window.clearProperty("userimage") home_window.setProperty("embycon_widget_reload", str(time.time())) - download_utils = DownloadUtils() - download_utils.authenticate() - download_utils.getUserId() + du = DownloadUtils() + du.authenticate() + du.getUserId() xbmc.executebuiltin("ActivateWindow(Home)") xbmc.executebuiltin("ReloadSkin()") diff --git a/resources/lib/utils.py b/resources/lib/utils.py index fd3317a..ca763a1 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -35,7 +35,9 @@ class PlayUtils(): addonSettings = xbmcaddon.Addon() playback_type = addonSettings.getSetting("playback_type") server = downloadUtils.getServer() - use_https = addonSettings.getSetting('use_https') == 'true' + use_https = False + if addonSettings.getSetting('protocol') == "1": + use_https = True log.debug("use_https: {0}", use_https) verify_cert = addonSettings.getSetting('verify_cert') == 'true' log.debug("verify_cert: {0}", verify_cert) diff --git a/resources/settings.xml b/resources/settings.xml index 9e882ba..8d524d1 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -4,9 +4,9 @@ + -