Skip to content

Commit

Permalink
202204130001
Browse files Browse the repository at this point in the history
  • Loading branch information
Samueli924 committed Apr 13, 2022
1 parent fb64e92 commit 1ffb627
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/chaoxing.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, usernm, passwd):
def init_explorer(self):
self.session = requests.session()
self.session.headers = {
'User-Agent': f'Dalvik/2.1.0 (Linux; U; Android {random.randint(10, 13)}.0.1; MI {random.randint(10, 13)} Build/Xiaomi) com.chaoxing.mobile/ChaoXingStudy_3_{random.randint(3, 5)}.{random.randint(1, 8)}_android_phone_{random.randint(111, 799)}_{random.randint(11, 99)}',
'User-Agent': f'Dalvik/2.1.0 (Linux; U; Android {random.randint(10, 13)}.0.1; MI {random.randint(10, 13)} Build/Xiaomi) com.chaoxing.mobile/ChaoXingStudy_3_4.8_android_phone_598_56',
'X-Requested-With': 'com.chaoxing.mobile'
}

Expand Down
22 changes: 9 additions & 13 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ def do_work(chaoxingAPI):
for mission in chaoxingAPI.missions:
# logger.info("开始读取章节信息")
knowledge_raw = chaoxingAPI.get_mission(mission['id'], chaoxingAPI.selected_course['key']) # 读取章节信息
if "data" not in knowledge_raw:
print("课程信息中不存在data键\n请截图以下内容,在Github或Telegram中向作者提交反馈,谢谢")
print(knowledge_raw)
input("点击回车键退出")
if "data" not in knowledge_raw and "error" in knowledge_raw:
input("当前课程需要认证,请在学习通客户端中验证码认证后再运行本课程\n点击回车键退出程序")
exit()
tabs = len(knowledge_raw['data'][0]['card']['data'])
for tab_index in range(tabs):
Expand All @@ -34,21 +32,20 @@ def do_work(chaoxingAPI):
print(f'\n当前章节:{mission["label"]}:{mission["name"]}')
for attachment in attachments['attachments']: # 非视频任务跳过
if attachment.get('type') != 'video':
# print(f"\n当前任务:{attachment['property']['name']}非视频任务")
print("跳过非视频任务")
continue
# if attachment['jobid'] in done:
# print(f"\n当前视频:{attachment['property']['name']}存在历史记录")
# continue
print(f"\n当前视频:{attachment['property']['name']}")
if attachment.get('isPassed'):
print("当前视频任务过去已完成")
ft.show_progress(attachment['property']['name'], 1, 1)
# done.append(attachment['jobid'])
# ft.save_finished(chaoxingAPI.usernm, done)
continue
video_info = chaoxingAPI.get_d_token(
attachment['objectId'],
attachments['defaults']['fid']
)
if "jobid" not in attachments['attachments'][0]:
print("当前Attachment不存在jobid,已跳过")
continue
chaoxingAPI.pass_video(
video_info['duration'],
attachments['defaults']['cpi'],
Expand All @@ -61,9 +58,8 @@ def do_work(chaoxingAPI):
attachment['property']['name'],
chaoxingAPI.speed
)
# done.append(attachment['jobid'])
# ft.save_finished(chaoxingAPI.usernm, done)
time.sleep(random.randint(1, 3))
ft.pause(1, 5)
ft.pause(3, 7)


if __name__ == '__main__':
Expand Down
7 changes: 6 additions & 1 deletion utils/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from hashlib import md5
from os import mkdir
from os.path import exists

import random
from natsort import natsorted


Expand Down Expand Up @@ -203,3 +203,8 @@ def show_progress(name, current, total):
print("\r" + f"当前任务: {name} |{progress}| {percent}% {sec2time(current)}/{sec2time(total)}", end="", flush=True)


def pause(start: int, end: int):
__temp = random.randint(start, end)
print(f"等待{__temp}秒")
time.sleep(__temp)
return True

0 comments on commit 1ffb627

Please sign in to comment.