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