From 35e34caa3511e316306921c5f5cfdf35333a51a4 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sun, 10 Sep 2023 23:01:55 +0800 Subject: [PATCH] :bug: Fix authserver https --- cqwu/client.py | 2 +- cqwu/methods/webvpn/login_webvpn.py | 4 ++-- cqwu/types/calendar.py | 14 +++++++++++++- setup.py | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/cqwu/client.py b/cqwu/client.py index b5704bb..fd790b1 100644 --- a/cqwu/client.py +++ b/cqwu/client.py @@ -22,7 +22,7 @@ class Client(Methods): self.cookie = cookie self.cookie_file_path = cookie_file_path self.host = "http://ehall.cqwu.edu.cn" - self.auth_host = "http://authserver.cqwu.edu.cn" + self.auth_host = "https://authserver.cqwu.edu.cn" self.web_ehall_path = "" self.cookies = Cookies() self.request = AsyncClient(timeout=timeout) diff --git a/cqwu/methods/webvpn/login_webvpn.py b/cqwu/methods/webvpn/login_webvpn.py index 9aa3cde..554fdf5 100644 --- a/cqwu/methods/webvpn/login_webvpn.py +++ b/cqwu/methods/webvpn/login_webvpn.py @@ -13,9 +13,9 @@ class LoginWebVPN: url = "https://webvpn.cqwu.edu.cn" ehall_html = await self.request.get(url, follow_redirects=True) self.web_ehall_path = self.get_web_vpn_host(ehall_html.url) # noqa - await self.oauth("http://authserver.cqwu.edu.cn/authserver/login?service=https://clientvpn.cqwu.edu.cn/enlink/api/client/callback/cas") + await self.oauth("https://authserver.cqwu.edu.cn/authserver/login?service=https://clientvpn.cqwu.edu.cn/enlink/api/client/callback/cas") auth_html = await self.request.get( f"{self.web_ehall_path}/login", follow_redirects=True ) - if web_auth_path := self.get_web_vpn_host(auth_html.url): + if web_auth_path := self.get_web_vpn_host(auth_html.url, https=True): await self.login_with_password(auth_host=web_auth_path) diff --git a/cqwu/types/calendar.py b/cqwu/types/calendar.py index 669fa3e..3e4aea1 100644 --- a/cqwu/types/calendar.py +++ b/cqwu/types/calendar.py @@ -1,4 +1,4 @@ -from typing import List +from typing import List, Dict from pydantic import BaseModel @@ -19,3 +19,15 @@ class AiCourse(BaseModel): @property def second_key(self): return f"{self.day}_{self.sections}" + + @property + def ai(self) -> Dict: + return { + "name": self.name, + "position": self.position, + "teacher": self.teacher, + "weeks": ",".join(list(map(str, self.weeks))), + "day": self.day, + "style": "", + "sections": ",".join(list(map(str, list(range(self.start_num, self.start_num + self.sections))))) + } diff --git a/setup.py b/setup.py index 49e1e77..2faa281 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh: setuptools.setup( name="cqwu", # 用自己的名替换其中的YOUR_USERNAME_ - version="0.0.15", # 包版本号,便于维护版本 + version="0.0.16", # 包版本号,便于维护版本 author="omg-xtao", # 作者,可以写自己的姓名 author_email="xtao@xtaolink.cn", # 作者联系方式,可写自己的邮箱地址 description="A cqwu ehall client.", # 包的简述