mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 02:36:10 +00:00
Adjust userclient exceptions
This commit is contained in:
parent
c1c0ad6d56
commit
71d3cb3c2d
1 changed files with 13 additions and 12 deletions
|
@ -38,7 +38,6 @@ class UserClient(threading.Thread):
|
||||||
self.__dict__ = self._shared_state
|
self.__dict__ = self._shared_state
|
||||||
|
|
||||||
self.doutils = downloadutils.DownloadUtils()
|
self.doutils = downloadutils.DownloadUtils()
|
||||||
self.download = self.doutils.downloadUrl
|
|
||||||
self.emby = embyserver.Read_EmbyServer()
|
self.emby = embyserver.Read_EmbyServer()
|
||||||
self.connectmanager = connectmanager.ConnectManager()
|
self.connectmanager = connectmanager.ConnectManager()
|
||||||
|
|
||||||
|
@ -79,10 +78,11 @@ class UserClient(threading.Thread):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
url = "%s/emby/Users/Public?format=json" % self.get_server()
|
url = "%s/emby/Users/Public?format=json" % self.get_server()
|
||||||
self.download(url, authenticate=False)
|
self.doutils.downloadUrl(url, authenticate=False)
|
||||||
return True
|
return True
|
||||||
except:
|
except Exception as error:
|
||||||
# Server connection failed
|
# Server connection failed
|
||||||
|
log.error(error)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -108,8 +108,8 @@ class UserClient(threading.Thread):
|
||||||
def _set_access(self):
|
def _set_access(self):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.download("{server}/emby/Users?format=json")
|
self.doutils.downloadUrl("{server}/emby/Users?format=json")
|
||||||
except Warning as error:
|
except Exception as error:
|
||||||
if self._has_access and "restricted" in error:
|
if self._has_access and "restricted" in error:
|
||||||
self._has_access = False
|
self._has_access = False
|
||||||
log.info("access is restricted")
|
log.info("access is restricted")
|
||||||
|
@ -144,7 +144,7 @@ class UserClient(threading.Thread):
|
||||||
|
|
||||||
def _set_user_server(self):
|
def _set_user_server(self):
|
||||||
|
|
||||||
user = self.download("{server}/emby/Users/{UserId}?format=json")
|
user = self.doutils.downloadUrl("{server}/emby/Users/{UserId}?format=json")
|
||||||
settings('username', value=user['Name'])
|
settings('username', value=user['Name'])
|
||||||
self._user = user
|
self._user = user
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ class UserClient(threading.Thread):
|
||||||
window('EmbyUserImage',
|
window('EmbyUserImage',
|
||||||
value=artwork.Artwork().get_user_artwork(self._user['Id'], 'Primary'))
|
value=artwork.Artwork().get_user_artwork(self._user['Id'], 'Primary'))
|
||||||
|
|
||||||
self._server = self.download("{server}/emby/System/Configuration?format=json")
|
self._server = self.doutils.downloadUrl("{server}/emby/System/Configuration?format=json")
|
||||||
settings('markPlayed', value=str(self._server['MaxResumePct']))
|
settings('markPlayed', value=str(self._server['MaxResumePct']))
|
||||||
|
|
||||||
def _authenticate(self):
|
def _authenticate(self):
|
||||||
|
@ -164,7 +164,8 @@ class UserClient(threading.Thread):
|
||||||
elif self.get_token():
|
elif self.get_token():
|
||||||
try:
|
try:
|
||||||
self._load_user()
|
self._load_user()
|
||||||
except Warning:
|
except Exception as error:
|
||||||
|
if "401" in error:
|
||||||
log.info("token is invalid")
|
log.info("token is invalid")
|
||||||
self._reset_client()
|
self._reset_client()
|
||||||
else:
|
else:
|
||||||
|
@ -220,8 +221,8 @@ class UserClient(threading.Thread):
|
||||||
# Test the validity of the current token
|
# Test the validity of the current token
|
||||||
if not authenticated:
|
if not authenticated:
|
||||||
try:
|
try:
|
||||||
self.download("{server}/emby/Users/{UserId}?format=json")
|
self.doutils.downloadUrl("{server}/emby/Users/{UserId}?format=json")
|
||||||
except Warning as error:
|
except Exception as error:
|
||||||
if "401" in error:
|
if "401" in error:
|
||||||
# Token is not longer valid
|
# Token is not longer valid
|
||||||
raise
|
raise
|
||||||
|
|
Loading…
Reference in a new issue