Commit de7a9911 authored by echel0n's avatar echel0n
Browse files

fixed "ReadTimeout" and "ConnectionError" issues when attempting to refresh SiCKRAGE oauth2 token

fixed "'NoneType' object is not iterable" when retrieving languages from series provider
added retry count of 3 for SiCKRAGE oauth2 token refreshes
parent 82101ad9
......@@ -163,15 +163,23 @@ class API(object):
pass
def refresh_token(self):
try:
if not self._token:
return self.login()
retries = 3
for i in range(retries):
try:
if not self._token:
return self.login()
self._token = sickrage.app.auth_server.refresh_token(self._token.get('refresh_token'))
except KeycloakClientError:
return self.login()
self._token = sickrage.app.auth_server.refresh_token(self._token.get('refresh_token'))
except KeycloakClientError:
return self.login()
except (requests.exceptions.ReadTimeout, requests.exceptions.ConnectionError):
if i > retries:
return False
time.sleep(0.2)
continue
return True
return True
def allowed_usernames(self):
return self.request('GET', 'allowed-usernames')
......
......@@ -186,6 +186,7 @@ class TheTVDB(SeriesProvider):
resp = sickrage.app.api.series_provider.languages(provider=self.slug)
if resp:
return sorted(resp, key=lambda i: i['name'])
return {}
def __repr__(self):
return repr(self.cache)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment