Skip to content

Commit

Permalink
Fix: remove course record function. Not working.
Browse files Browse the repository at this point in the history
  • Loading branch information
Samueli924 committed Nov 20, 2024
1 parent 2729a3c commit 42f026d
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
from urllib3 import disable_warnings,exceptions
import os

# 定义全局变量,用于存储配置文件路径
textPath = './resource/BookID.txt'
# # 定义全局变量,用于存储配置文件路径
# textPath = './resource/BookID.txt'

# 获取文本 -> 用于查看学习过的课程ID
def getText():
try:
if not os.path.exists(textPath):
with open(textPath, 'x') as file: pass
return []
with open(textPath, 'r', encoding='utf-8') as file: content = file.read().split(',')
content = {int(item.strip()) for item in content if item.strip()}
return list(content)
except Exception as e: logger.error(f"获取文本失败: {e}"); return []
# # 获取文本 -> 用于查看学习过的课程ID
# def getText():
# try:
# if not os.path.exists(textPath):
# with open(textPath, 'x') as file: pass
# return []
# with open(textPath, 'r', encoding='utf-8') as file: content = file.read().split(',')
# content = {int(item.strip()) for item in content if item.strip()}
# return list(content)
# except Exception as e: logger.error(f"获取文本失败: {e}"); return []

# 追加文本 -> 用于记录学习过的课程ID
def appendText(text):
if not os.path.exists(textPath): return
with open(textPath, 'a', encoding='utf-8') as file: file.write(f'{text}, ')
# # 追加文本 -> 用于记录学习过的课程ID
# def appendText(text):
# if not os.path.exists(textPath): return
# with open(textPath, 'a', encoding='utf-8') as file: file.write(f'{text}, ')


# 关闭警告
Expand Down Expand Up @@ -153,12 +153,12 @@ def add_times(self,id:str) -> None:
for job in jobs:
# 视频任务
if job["type"] == "video":

TextBookID = getText() # 获取学习过的课程ID
if TextBookID.count(bookID) > 0:
logger.info(f"课程: {course['title']} 章节: {point['title']} 任务: {job['title']} 已学习过或在学习中,跳过") # 如果已经学习过该课程,则跳过
break # 如果已经学习过该课程,则跳过
appendText(bookID) # 记录正在学习的课程ID
# TODO: 目前这个记录功能还不够完善,中途退出的课程ID也会被记录
# TextBookID = getText() # 获取学习过的课程ID
# if TextBookID.count(bookID) > 0:
# logger.info(f"课程: {course['title']} 章节: {point['title']} 任务: {job['title']} 已学习过或在学习中,跳过") # 如果已经学习过该课程,则跳过
# break # 如果已经学习过该课程,则跳过
# appendText(bookID) # 记录正在学习的课程ID

logger.trace(f"识别到视频任务, 任务章节: {course['title']} 任务ID: {job['jobid']}")
# 超星的接口没有返回当前任务是否为Audio音频任务
Expand Down

0 comments on commit 42f026d

Please sign in to comment.