for manual and detect server correctly parse user:passowrd@ url tokens
This commit is contained in:
@@ -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 ""
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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 == "<none>" or host == "" or port == "":
|
||||
return return_data
|
||||
'''
|
||||
|
||||
if not host_name or host_name == "<none>":
|
||||
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:
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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()")
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
<setting label="30388" type="lsep"/>
|
||||
<setting label="30011" type="action" action="RunScript(plugin.video.embycon,0,?mode=DETECT_SERVER_USER)" option="close"/>
|
||||
<setting id="protocol" type="select" label="30390" lvalues="30391|30392" default="0" />
|
||||
<setting id="ipaddress" type="text" label="30000" default="<none>" visible="true" enable="true" />
|
||||
<setting id="port" type="text" label="30001" default="8096" visible="true" enable="true" />
|
||||
<setting id="use_https" type="bool" label="30002" default="false" visible="true" enable="true" />
|
||||
<setting id="verify_cert" type="bool" label="30003" default="false" visible="true" enable="true" />
|
||||
|
||||
<setting label="30389" type="lsep"/>
|
||||
|
||||
Reference in New Issue
Block a user