diff --git a/main.py b/main.py index 3bc8800a..c81843fd 100644 --- a/main.py +++ b/main.py @@ -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}, ') # 关闭警告 @@ -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音频任务