cqooc_time/defs/api_url.py
2022-06-01 19:06:17 +08:00

91 lines
3.0 KiB
Python

# -*- coding: utf-8 -*-
import time
class ApiUrl:
@staticmethod
def __get_ts() -> int:
return int(time.time() * 1000)
def id_api(self, xsid: str) -> str:
return f"http://www.cqooc.com/user/session?xsid={xsid}&ts={self.__get_ts()}"
def info_api(self) -> str:
return f"http://www.cqooc.com/account/session/api/profile/get?ts={self.__get_ts()}"
def get_nonce_api(self):
return f"http://www.cqooc.com/user/login?ts={self.__get_ts()}"
@staticmethod
def login_api(username: str, hash_str: str, nonce: str, cn: str) -> str:
return (
"http://www.cqooc.com/user/login"
+ f"?username={username}&password={hash_str}"
+ f"&nonce={nonce}&cnonce={cn}"
)
def course_api(self, ownerId: str, limit: int) -> str:
return (
"http://www.cqooc.com/json/mcs?sortby=id&reverse=true&del=2"
+ f"&courseType=2&ownerId={ownerId}&limit={limit}"
+ f"&ts={self.__get_ts()}"
)
def lessons_api(
self, course_id: str, start: int = 0, limit: int = 100
) -> str:
return (
"http://www.cqooc.com/json/mooc/lessons"
+ f"?limit={limit}&start={start}&sortby=selfId&reverse=false"
+ f"&courseId={course_id}&ts={self.__get_ts()}"
)
def lessons_status_api(
self, course_id: str, username: str, start: int = 0, limit: int = 100
) -> str:
return (
"http://www.cqooc.com/json/learnLogs"
+ f"?limit={limit}&start={start}&courseId={course_id}"
+ f"&select=sectionId&username={username}&ts={self.__get_ts()}"
)
def mcs_id_api(self, owner_id: str, course_id: str) -> str:
return (
"http://www.cqooc.com/json/mcs"
+ f"?ownerId={owner_id}&courseId={course_id}"
+ f"&ts={self.__get_ts()}"
)
def learn_log_api(self, section_id: str, username: str) -> str:
return (
"http://www.cqooc.com/json/learnLogs"
+ f"?sectionId={section_id}&username={username}"
+ f"&ts={self.__get_ts()}"
)
def exam_list_api(self, course_id: str) -> str:
return (
"http://www.cqooc.com/json/exam/papers"
+ f"?limit=200&start=1&courseId={course_id}&select=id,title,parentId,submitEnd"
f"&ts={self.__get_ts()}"
)
def task_list_api(self, course_id: str) -> str:
return (
"http://www.cqooc.com/json/tasks"
+ f"?limit=200&start=1&isPublish=1&courseId={course_id}&select=id,title,pubClass,submitEnd"
+ f"&ts={self.__get_ts()}"
)
def chapters_api(self, course_id: str) -> str:
return (
"http://www.cqooc.com/json/chapters"
+ f"?limit=200&start=1&isPublish=1&courseId={course_id}&select=id,title,parentId"
+ f"&ts={self.__get_ts()}"
)
@staticmethod
def skip_section_api() -> str:
return "http://www.cqooc.com/learnLog/api/add"