Skip to content

Commit

Permalink
feature:允许仅同步某一个学期的课程
Browse files Browse the repository at this point in the history
  • Loading branch information
GentleCP committed Mar 2, 2020
1 parent 18a86d4 commit 4c2341b
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 6 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
我都要登录课程网站一个个点,真的心累。要是有个脚本可以直接将我本地的课程资源,
与课程网站一键同步就好了。所以就写了一个可用自动同步所有课程资源到本地的项目。

> 现在可以按照学期同步自己需要的资源,而不用将之前学期的一并同步
### 关于wifi登录
提供了自动登录的功能,且允许添加多个账号,当一个账号流量使用完后,可用下一个账号自动登录,
每月自动更新。出于隐私保护,项目不直接提供爆破的账号密码信息(以防被外来人员利用),在校学生可通过执行`python manage.py hack`命令,
Expand All @@ -28,7 +30,7 @@
因为会用脚本评估的大多是怕麻烦的人,如果有个别老师或课程让你觉得十分不靠谱,
根本无益,建议还是手动去修改下对应的评估,虽然不知道是否真的对教改有用,
起码得让那课程老师心里有点数呀~
> 评估之前请进入`settings.py`修改一下主管评估的内容,别都和我评估一样了喂~
> 评估之前请进入`settings.py`修改一下主观评估的内容,别都和我评估一样了喂~
![](img/5-2.png)

Expand All @@ -38,8 +40,12 @@
后续看是否有需要再添加吧。
## 版本号

1.3.1
1.4.1

### 更新内容
- [1.4.1]
> 在课程资源选项中可以选择仅同步某个学期(春季,夏季,秋季)课程
## 作者
- name: 董超鹏
- nickname: GentleCP
Expand Down
2 changes: 1 addition & 1 deletion core/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _cmd(self):
option = input("输入你的操作:")
if option == 'q':
print("欢迎使用,下次再会~")
exit(1)
exit(200)

elif not (option.isdigit() and 1<=int(option)<=5) :
self._logger.warning("非法操作,请重新输入")
Expand Down
49 changes: 46 additions & 3 deletions core/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,18 @@ def _download_all(self):
else:
self._logger.info("[同步完成] 本次无更新内容!")

def _download_course_by_season(self,season):
for course_info in self._l_course_info:
if season in course_info['name']:
self._set_source_info(course_info)
self._download_course(course_info)
if self._update_sources:
self._logger.info("[同步完成] 本次更新资源列表如下:")
for source in self._update_sources:
print('\033[1;41m' + source + '\033[0m')
else:
self._logger.info("[同步完成] 本次无更新内容!")

def _show(self, infos):
if infos:
for info in infos:
Expand All @@ -182,7 +194,8 @@ def _show(self, infos):

def __check_option(self, option):
if option == 'q':
raise BackToMain
print("欢迎使用,下次再会~")
exit(200)

elif option == 'b' and self._cur_course_info:
self._cur_course_info = None # 清空
Expand All @@ -192,6 +205,18 @@ def __check_option(self, option):
self._download_all()
return False

elif option == 's' and not self._cur_course_info:
self._download_course_by_season('春季')
return False

elif option == 'm' and not self._cur_course_info:
self._download_course_by_season('夏季')
return False

elif option == 'f' and not self._cur_course_info:
self._download_course_by_season('秋季')
return False

elif option == 'a' and self._cur_course_info:
self._download_course(course_info=self._cur_course_info)

Expand Down Expand Up @@ -222,14 +247,32 @@ def _cmd(self):
while True:
print("\033[1;45m>课程列表:\033[0m", flush=True)
self._show(self._l_course_info)
option = input("请输入你的操作(id:显示对应课程的所有资源;d:一键同步所有资源;q:回到主界面):")
print("""
***************************************
* id:显示对应课程的所有资源 *
* d:一键同步所有资源 *
* s:同步春季课程资源 *
* m:同步夏季课程资源 *
* f:同步秋季课程资源 *
* q:退出 *
***************************************
""")
option = input("请输入你的操作:")
if not self.__check_option(option):
# 不进入下一级界面
continue
while True:
print("\033[1;45m>课程列表>{}:\033[0m".format(self._cur_course_info["name"]))
self._show(self._d_source_info[self._cur_course_info["name"]])
option = input("请输入你的操作(id:下载对应id资源;a:下载所有;b:返回上一级;q:回到主界面):")
print("""
*********************************
* id:下载对应id资源 *
* a:下载所有 *
* b:返回上一级 *
* q:退出 *
********************************
""")
option = input("请输入你的操作:")
if self.__check_option(option):
# 接收到返回上级界面信息
break
Expand Down

0 comments on commit 4c2341b

Please sign in to comment.