Improvements to PMS connection checks

This commit is contained in:
tomkat83 2016-05-18 20:10:20 +02:00
parent 04bcaafdb4
commit 67755d6a23
3 changed files with 8 additions and 11 deletions

View file

@ -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

View file

@ -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

View file

@ -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='')