Improvements to PMS connection checks
This commit is contained in:
parent
04bcaafdb4
commit
67755d6a23
3 changed files with 8 additions and 11 deletions
|
@ -291,18 +291,22 @@ class PlexAPI():
|
||||||
authenticate=False,
|
authenticate=False,
|
||||||
headerOptions=headerOptions,
|
headerOptions=headerOptions,
|
||||||
verifySSL=verifySSL)
|
verifySSL=verifySSL)
|
||||||
if answer is False:
|
if answer is None:
|
||||||
self.logMsg("Could not connect to %s" % url, 0)
|
self.logMsg("Could not connect to %s" % url, 0)
|
||||||
count += 1
|
count += 1
|
||||||
xbmc.sleep(500)
|
xbmc.sleep(500)
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
|
# xml received?
|
||||||
answer.attrib
|
answer.attrib
|
||||||
except:
|
except:
|
||||||
pass
|
if answer is True:
|
||||||
|
# Maybe no xml but connection was successful nevertheless
|
||||||
|
answer = 200
|
||||||
else:
|
else:
|
||||||
# Success - we downloaded an xml!
|
# Success - we downloaded an xml!
|
||||||
answer = 200
|
answer = 200
|
||||||
|
# We could connect but maybe were not authenticated. No worries
|
||||||
self.logMsg("Checking connection successfull. Answer: %s"
|
self.logMsg("Checking connection successfull. Answer: %s"
|
||||||
% answer, 1)
|
% answer, 1)
|
||||||
return answer
|
return answer
|
||||||
|
|
|
@ -165,7 +165,7 @@ class DownloadUtils():
|
||||||
Otherwise, 'empty' request will be made
|
Otherwise, 'empty' request will be made
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
False If an error occured
|
None If an error occured
|
||||||
True If connection worked but no body was received
|
True If connection worked but no body was received
|
||||||
401, ... integer if PMS answered with HTTP error 401
|
401, ... integer if PMS answered with HTTP error 401
|
||||||
(unauthorized) or other http error codes
|
(unauthorized) or other http error codes
|
||||||
|
|
|
@ -53,15 +53,8 @@ class InitialSetup():
|
||||||
if (plexToken and myplexlogin == 'true' and forcePlexTV is False
|
if (plexToken and myplexlogin == 'true' and forcePlexTV is False
|
||||||
and chooseServer is False):
|
and chooseServer is False):
|
||||||
chk = self.plx.CheckConnection('plex.tv', plexToken)
|
chk = self.plx.CheckConnection('plex.tv', plexToken)
|
||||||
try:
|
|
||||||
chk.attrib
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
# Success - we downloaded an xml!
|
|
||||||
chk = 200
|
|
||||||
# HTTP Error: unauthorized. Token is no longer valid
|
|
||||||
if chk in (401, 403):
|
if chk in (401, 403):
|
||||||
|
# HTTP Error: unauthorized. Token is no longer valid
|
||||||
self.logMsg('plex.tv connection returned HTTP %s' % chk, 0)
|
self.logMsg('plex.tv connection returned HTTP %s' % chk, 0)
|
||||||
# Delete token in the settings
|
# Delete token in the settings
|
||||||
utils.settings('plexToken', value='')
|
utils.settings('plexToken', value='')
|
||||||
|
|
Loading…
Reference in a new issue