Skip to content

Commit

Permalink
20220409
Browse files Browse the repository at this point in the history
  • Loading branch information
Samueli924 committed Apr 9, 2022
1 parent 5154613 commit 703fca7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
Binary file added api/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added api/__pycache__/chaoxing.cpython-39.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion api/chaoxing.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def login(self):
save_users(usernm=self.usernm, passwd=self.passwd)
return True
else:
self.logger.error("登录失败:" + resp.json())
self.logger.error("登录失败:" + str(resp.json()))
return False

def status(self):
Expand Down
42 changes: 24 additions & 18 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,27 @@ def do_work(chaoxingAPI):


if __name__ == '__main__':
ft.init_all_path(["saves", "logs"]) # 检查文件夹
logger = ft.Logger("main") # 初始化日志类
ft.title_show() # 显示头
logger.info("正在获取用户数据...")
usernm, passwd = ft.load_users() # 获取账号密码
chaoxing = Chaoxing(usernm, passwd) # 实例化超星API
chaoxing.init_explorer() # 实例化浏览Explorer
logger.info("开始登录")
if chaoxing.login(): # 登录
logger.info("开始读取所有课程")
if chaoxing.get_all_courses(): # 读取所有的课程
logger.info("开始选课")
if chaoxing.select_course(): # 选择要学习的课程
chaoxing.speed = int(input("当前倍速: 1 倍速 \n在不紧急的情况下建议使用 1 倍速,因使用不合理的多倍速造成的一切风险与作者无关\n请输入您想要的整数学习倍速:"))
logger.info("开始学习")
do_work(chaoxing) # 开始学习
input("任务已结束,请点击回车键退出程序")

try:
ft.init_all_path(["saves", "logs"]) # 检查文件夹
logger = ft.Logger("main") # 初始化日志类
ft.title_show() # 显示头
logger.info("正在获取用户数据...")
usernm, passwd = ft.load_users() # 获取账号密码
chaoxing = Chaoxing(usernm, passwd) # 实例化超星API
chaoxing.init_explorer() # 实例化浏览Explorer
logger.info("开始登录")
if chaoxing.login(): # 登录
logger.info("开始读取所有课程")
if chaoxing.get_all_courses(): # 读取所有的课程
logger.info("开始选课")
if chaoxing.select_course(): # 选择要学习的课程
chaoxing.speed = int(input("当前倍速: 1 倍速 \n在不紧急的情况下建议使用 1 倍速,因使用不合理的多倍速造成的一切风险与作者无关\n请输入您想要的整数学习倍速:"))
logger.info("开始学习")
do_work(chaoxing) # 开始学习
input("任务已结束,请点击回车键退出程序")
except Exception as e:
print(f"出现报错{e.__class__}")
print(f"错误文件名:{e.__traceback__.tb_frame.f_globals['__file__']}")
print(f"错误行数:{e.__traceback__.tb_lineno}")
print(f"错误原因:{e}")
input("请截图提交至Github或Telegram供作者修改代码\n点击回车键退出程序")

0 comments on commit 703fca7

Please sign in to comment.