Skip to content

Commit

Permalink
perf: Optimize interaction experience
Browse files Browse the repository at this point in the history
  • Loading branch information
chettoy committed Apr 21, 2022
1 parent d4a142f commit 3bf0be3
Showing 1 changed file with 35 additions and 20 deletions.
55 changes: 35 additions & 20 deletions fxxkstar.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,7 @@ def load_profile(self) -> dict:

url1 = "https://i.chaoxing.com/base/verify"
parms1 = {"_t": self.format_date_like_javascript()}
if G_VERBOSE:
print("[INFO] load_profile verify")
print("[INFO] load_profile verify")
result1 = self.request_xhr(url1, {
"Origin": "https://i.chaoxing.com",
"Referer": homepage_url,
Expand All @@ -423,17 +422,15 @@ def load_profile(self) -> dict:
": url=" + url1 + "\n" + str(result1))

url2 = "https://i.chaoxing.com/base/settings"
if G_VERBOSE:
print("[INFO] load_profile settings")
print("[INFO] load_profile settings")
self.request_iframe(url2, {
"Referer": homepage_url,
})

self.sleep(50, 200)

url3 = "https://passport2.chaoxing.com/mooc/accountManage"
if G_VERBOSE:
print("[INFO] load_profile accountManage")
print("[INFO] load_profile account")
account_page_html = self.request_iframe(url3, {
"Referer": "https://i.chaoxing.com/",
}).text
Expand Down Expand Up @@ -892,15 +889,21 @@ def medias_deal(self, card_info: dict, course_id, clazz_id, chapter_id) -> None:
else:
if G_VERBOSE:
print("attachment_item", attachment_item)
return

if 'property' in attachment_item:
attachment_property = attachment_item['property']
if 'module' in attachment_property:
module_type = attachment_property['module']
print(module_type)
if module_type == "insertbook":
print("[InsertBook]",
attachment_property['bookname'])
print("[InsertBook]",
attachment_property['readurl'])
else:
print(module_type)
else:
print("attachment_item", attachment_item)
if not G_VERBOSE:
print("attachment_item", attachment_item)

def deal_chapter(self, chapter_meta: dict) -> None:
chapter_info = self.fxxkstar.load_chapter(chapter_meta)
Expand Down Expand Up @@ -1737,7 +1740,7 @@ def prepare() -> FxxkStar:
helper.login_if_need()
helper.show_profile()
print()
time.sleep(2.5)
time.sleep(1.5)

helper.load_courses_if_need()

Expand Down Expand Up @@ -1771,18 +1774,30 @@ def prepare() -> FxxkStar:
if choose_chapter == "n" or choose_chapter == "next" or choose_chapter == '':
choose_chapter = chose_chapter_index + 1
else:
choose_chapter = int(choose_chapter) - 1
if choose_chapter.isdigit():
choose_chapter = int(choose_chapter) - 1

print()
if 0 <= choose_chapter < unfinished_chapters.__len__():
current_chapter = unfinished_chapters[choose_chapter]
print()
print(
f"🔴 {current_chapter['chapterNumber']} {current_chapter['chapterTitle']}")
helper.deal_chapter(current_chapter)
print()
chose_chapter_index = choose_chapter
current_chapter = None
if isinstance(choose_chapter, int):
if 0 <= choose_chapter < unfinished_chapters.__len__():
current_chapter = unfinished_chapters[choose_chapter]
chose_chapter_index = choose_chapter
else:
break
else:
break
for chapter in chapters:
if chapter['chapterNumber'] == choose_chapter:
current_chapter = chapter
break
if current_chapter is None:
break

print()
print(
f"🔴 {current_chapter['chapterNumber']} {current_chapter['chapterTitle']}")
helper.deal_chapter(current_chapter)
print()

if input(G_STRINGS['input_if_sync_video_progress']) == 'y':
helper.sync_video_progress()
Expand Down

0 comments on commit 3bf0be3

Please sign in to comment.