Connect to remote PMS
This commit is contained in:
parent
1ab657cd0b
commit
100421ce2d
4 changed files with 26 additions and 18 deletions
|
@ -295,13 +295,13 @@ class PlexAPI():
|
||||||
verify=verify,
|
verify=verify,
|
||||||
timeout=timeout)
|
timeout=timeout)
|
||||||
except requests.exceptions.ConnectionError as e:
|
except requests.exceptions.ConnectionError as e:
|
||||||
self.logMsg("Server is offline or cannot be reached. Url: %s."
|
self.logMsg("Server is offline or cannot be reached. Url: %s. "
|
||||||
"Header: %s. Error message: %s"
|
"Error message: %s"
|
||||||
% (url, header, e), -1)
|
% (url, e), -1)
|
||||||
return False
|
return False
|
||||||
except requests.exceptions.ReadTimeout:
|
except requests.exceptions.ReadTimeout:
|
||||||
self.logMsg("Server timeout reached for Url %s with header %s"
|
self.logMsg("Server timeout reached for Url %s"
|
||||||
% (url, header), -1)
|
% url, -1)
|
||||||
return False
|
return False
|
||||||
# We received an answer from the server, but not as expected.
|
# We received an answer from the server, but not as expected.
|
||||||
if answer.status_code >= 400:
|
if answer.status_code >= 400:
|
||||||
|
|
|
@ -359,7 +359,7 @@ class DownloadUtils():
|
||||||
except requests.exceptions.ConnectionError as e:
|
except requests.exceptions.ConnectionError as e:
|
||||||
# Make the addon aware of status
|
# Make the addon aware of status
|
||||||
if utils.window('emby_online') != "false":
|
if utils.window('emby_online') != "false":
|
||||||
self.logMsg("Server unreachable at: %s" % url, 0)
|
self.logMsg("Server unreachable at: %s" % url, -1)
|
||||||
self.logMsg(e, 2)
|
self.logMsg(e, 2)
|
||||||
utils.window('emby_online', value="false")
|
utils.window('emby_online', value="false")
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ class InitialSetup():
|
||||||
plexLogin = plexdict['plexLogin']
|
plexLogin = plexdict['plexLogin']
|
||||||
plexToken = plexdict['plexToken']
|
plexToken = plexdict['plexToken']
|
||||||
plexid = plexdict['plexid']
|
plexid = plexdict['plexid']
|
||||||
self.logMsg('Plex info retrieved from settings: %s' % plexdict, 1)
|
self.logMsg('Plex info retrieved from settings', 1)
|
||||||
|
|
||||||
dialog = xbmcgui.Dialog()
|
dialog = xbmcgui.Dialog()
|
||||||
|
|
||||||
|
@ -120,8 +120,13 @@ class InitialSetup():
|
||||||
resp = dialog.select(string(39012), dialoglist)
|
resp = dialog.select(string(39012), dialoglist)
|
||||||
server = serverlist[resp]
|
server = serverlist[resp]
|
||||||
activeServer = server['machineIdentifier']
|
activeServer = server['machineIdentifier']
|
||||||
url = server['scheme'] + '://' + server['ip'] + ':' + \
|
# Re-direct via plex if remote - will lead to the correct SSL
|
||||||
server['port']
|
# certificate
|
||||||
|
if server['local'] == '1':
|
||||||
|
url = server['scheme'] + '://' + server['ip'] + ':' \
|
||||||
|
+ server['port']
|
||||||
|
else:
|
||||||
|
url = server['baseURL']
|
||||||
# Deactive SSL verification if the server is local!
|
# Deactive SSL verification if the server is local!
|
||||||
if server['local'] == '1':
|
if server['local'] == '1':
|
||||||
utils.settings('sslverify', 'false')
|
utils.settings('sslverify', 'false')
|
||||||
|
@ -166,18 +171,21 @@ class InitialSetup():
|
||||||
break
|
break
|
||||||
if not isconnected:
|
if not isconnected:
|
||||||
# Enter Kodi settings instead
|
# Enter Kodi settings instead
|
||||||
if dialog.yesno(
|
|
||||||
heading=self.addonName,
|
|
||||||
line1=string(39016)):
|
|
||||||
self.logMsg("User opted to disable Plex music library.", 1)
|
|
||||||
utils.settings('enableMusic', value="false")
|
|
||||||
xbmc.executebuiltin('Addon.OpenSettings(%s)' % self.addonId)
|
xbmc.executebuiltin('Addon.OpenSettings(%s)' % self.addonId)
|
||||||
return
|
return
|
||||||
# Write to Kodi settings file
|
# Write to Kodi settings file
|
||||||
utils.settings('plex_machineIdentifier', activeServer)
|
utils.settings('plex_machineIdentifier', activeServer)
|
||||||
utils.settings('ipaddress', server['ip'])
|
if server['local'] == '1':
|
||||||
utils.settings('port', server['port'])
|
scheme = server['scheme']
|
||||||
if server['scheme'] == 'https':
|
utils.settings('ipaddress', server['ip'])
|
||||||
|
utils.settings('port', server['port'])
|
||||||
|
else:
|
||||||
|
baseURL = server['baseURL'].split(':')
|
||||||
|
scheme = baseURL[0]
|
||||||
|
utils.settings('ipaddress', baseURL[1].replace('//', ''))
|
||||||
|
utils.settings('port', baseURL[2])
|
||||||
|
|
||||||
|
if scheme == 'https':
|
||||||
utils.settings('https', 'true')
|
utils.settings('https', 'true')
|
||||||
else:
|
else:
|
||||||
utils.settings('https', 'false')
|
utils.settings('https', 'false')
|
||||||
|
|
|
@ -381,7 +381,7 @@ class UserClient(threading.Thread):
|
||||||
settings('userId', value="")
|
settings('userId', value="")
|
||||||
|
|
||||||
# Give attempts at entering password / selecting user
|
# Give attempts at entering password / selecting user
|
||||||
if self.retry >= 3:
|
if self.retry >= 2:
|
||||||
log("Too many retries to login.", -1)
|
log("Too many retries to login.", -1)
|
||||||
window('emby_serverStatus', value="Stop")
|
window('emby_serverStatus', value="Stop")
|
||||||
dialog.ok(lang(33001),
|
dialog.ok(lang(33001),
|
||||||
|
|
Loading…
Add table
Reference in a new issue