code reduce

This commit is contained in:
SpootDev 2016-03-31 14:39:32 -05:00
parent 44d0af0ad8
commit d915c4539e
2 changed files with 567 additions and 584 deletions

View file

@ -316,7 +316,7 @@ class UserClient(threading.Thread):
elif self.getToken(): elif self.getToken():
result = self.loadCurrUser() result = self.loadCurrUser()
if result == False: if result is False:
pass pass
else: else:
self.logMsg("Current user: %s" % self.currUser, 1) self.logMsg("Current user: %s" % self.currUser, 1)
@ -355,11 +355,10 @@ class UserClient(threading.Thread):
sha1 = sha1.hexdigest() sha1 = sha1.hexdigest()
# Authenticate username and password # Authenticate username and password
url = "%s/emby/Users/AuthenticateByName?format=json" % server
data = {'username': username, 'password': sha1} data = {'username': username, 'password': sha1}
self.logMsg(data, 2) self.logMsg(data, 2)
result = self.doUtils.downloadUrl(url, postBody=data, type="POST", authenticate=False) result = self.doUtils.downloadUrl("%s/emby/Users/AuthenticateByName?format=json" % server, postBody=data, type="POST", authenticate=False)
try: try:
self.logMsg("Auth response: %s" % result, 1) self.logMsg("Auth response: %s" % result, 1)
@ -373,9 +372,8 @@ class UserClient(threading.Thread):
self.currUser = username self.currUser = username
dialog.notification("Emby for Kodi", dialog.notification("Emby for Kodi",
"%s %s!" % (lang(33000), self.currUser.decode('utf-8'))) "%s %s!" % (lang(33000), self.currUser.decode('utf-8')))
userId = result['User']['Id']
settings('accessToken', value=accessToken) settings('accessToken', value=accessToken)
settings('userId%s' % username, value=userId) settings('userId%s' % username, value=result['User']['Id'])
self.logMsg("User Authenticated: %s" % accessToken, 1) self.logMsg("User Authenticated: %s" % accessToken, 1)
self.loadCurrUser(authenticated=True) self.loadCurrUser(authenticated=True)
window('emby_serverStatus', clear=True) window('emby_serverStatus', clear=True)
@ -399,12 +397,10 @@ class UserClient(threading.Thread):
def resetClient(self): def resetClient(self):
self.logMsg("Reset UserClient authentication.", 1) self.logMsg("Reset UserClient authentication.", 1)
userId = self.getUserId()
if self.currToken is not None: if self.currToken is not None:
# In case of 401, removed saved token # In case of 401, removed saved token
utils.settings('accessToken', value="") utils.settings('accessToken', value="")
utils.window('emby_accessToken%s' % userId, clear=True) utils.window('emby_accessToken%s' % self.getUserId(), clear=True)
self.currToken = None self.currToken = None
self.logMsg("User token has been removed.", 1) self.logMsg("User token has been removed.", 1)

File diff suppressed because it is too large Load diff