Testing login feature on app

This commit is contained in:
RemixDev 2020-04-11 21:55:12 +02:00
parent 497186dba9
commit f1f47cb005
2 changed files with 10 additions and 23 deletions

View File

@ -125,7 +125,7 @@ class Deezer:
user_data = self.gw_api_call("deezer.getUserData") user_data = self.gw_api_call("deezer.getUserData")
if user_data["results"]["USER"]["USER_ID"] == 0: if user_data["results"]["USER"]["USER_ID"] == 0:
self.logged_in = False self.logged_in = False
return False return 0
self.user = { self.user = {
'id': user_data["results"]["USER"]["USER_ID"], 'id': user_data["results"]["USER"]["USER_ID"],
'name': user_data["results"]["USER"]["BLOG_NAME"], 'name': user_data["results"]["USER"]["BLOG_NAME"],
@ -133,7 +133,7 @@ class Deezer:
"USER"] else "" "USER"] else ""
} }
self.logged_in = True self.logged_in = True
return True return 1
def get_track_gw(self, sng_id): def get_track_gw(self, sng_id):
if int(sng_id) < 0: if int(sng_id) < 0:

View File

@ -9,32 +9,19 @@ from os import mkdir, rmdir
dz = Deezer() dz = Deezer()
settings = {} settings = {}
def requestValidArl(): def login(arl):
while True: if not dz.logged_in:
arl = input("Paste here your arl:") return dz.login_via_arl(arl)
if dz.login_via_arl(arl):
break
return arl
def login():
configFolder = localpaths.getConfigFolder()
if not path.isdir(configFolder):
mkdir(configFolder)
if path.isfile(path.join(configFolder, '.arl')):
with open(path.join(configFolder, '.arl'), 'r') as f:
arl = f.read()
if not dz.login_via_arl(arl):
arl = requestValidArl()
else: else:
arl = requestValidArl() return 2
with open(path.join(configFolder, '.arl'), 'w') as f:
f.write(arl) def getUser():
return dz.user
def initialize(): def initialize():
global settings global settings
settings = initSettings() settings = initSettings()
login() return {'settings': settings}
return True
def shutdown(socket=None): def shutdown(socket=None):
print(getQueue()) print(getQueue())