auto sign

This commit is contained in:
2024-07-18 20:09:38 +08:00
parent 8291421943
commit bb2ab536cd
11 changed files with 408 additions and 1 deletions
+27 -1
View File
@@ -4,8 +4,21 @@ import os
from pathlib import Path
project_path = Path(__file__).parent.parent.absolute()
project_path = Path(__file__).parent.parent.parent.absolute()
data_path = os.path.join(project_path, 'data')
config_path = os.path.join(project_path, 'config')
def load_user_config():
if os.path.exists(os.path.join(config_path, 'user_info_local.json')):
config_file_path = os.path.join(config_path, 'user_info_local.json')
elif os.path.exists(os.path.join(config_path, 'user_info.json')):
config_file_path = os.path.join(config_path, 'user_info.json')
else:
raise FileNotFoundError('user_info_local.json or user_info.json not exist in config dir!')
with open(config_file_path, 'r', encoding='utf-8') as f:
user_config = json.load(f)
return user_config
def hg_get_new_user_token(username, password):
@@ -38,3 +51,16 @@ def hg_login(username, password, token_path=None):
if gacha_response == '{"code":3000,"msg":"登录失效"}':
print('用户名/密码错误')
raise ValueError
def validate_token(token):
get_gacha_url = f'https://ak.hypergryph.com/user/api/inquiry/gacha?page=1&token={token}&channelId=1'
gacha_response = requests.get(get_gacha_url).text
if gacha_response == '{"code":3000,"msg":"登录失效"}':
return False
else:
return True
if __name__ == '__main__':
print(load_user_config())