diff --git a/README.md b/README.md index c060918..4917cde 100644 --- a/README.md +++ b/README.md @@ -45,9 +45,19 @@ # 2. 版本号 -1.4.3 +1.5.0 ## 2.1 更新内容 +- [1.5.0] + - 课程资源同步后有新的资源时会提示是否开启资源所在目录,简便查看文件操作,如下 + ![](img/1.5.0-1.png) + - 允许添加不希望被同步的课程内容:在同步所有的时候有一门课的资源并没什么卵用,但为了一门而去一个个同步其他的又略显麻烦, + 因此添加了一个`FILTER_LIST`,存放不想被同步的课程目录。打开`settings.py`,找到`FILTER_LIST`, + 将不像被同步的课程全名(如`没啥用课19-20春季`),添加到列表当中,如下: + ![](img/1.5.0-2.png) + + - 新版本在同步更新完成后会自动退出,不需要再手动退出程序 + - [1.4.3] > 修复了当同时存在多个文件夹和文件时不会下载与文件夹同目录的文件的问题,如下图所示: ![](img/fix_1.4.3-1.png) diff --git a/core/main.py b/core/main.py index a4c33d3..14c39a0 100644 --- a/core/main.py +++ b/core/main.py @@ -94,7 +94,8 @@ def main(): wifi_loginer = WifiLoginer(accounts_path=settings.ACCOUNTS_PATH) downloader = Downloader(user_info=settings.USER_INFO, urls=settings.URLS, - source_dir=settings.SOURCE_DIR) + source_dir=settings.SOURCE_DIR, + filter_list = settings.FILTER_LIST) assesser = Assesser(settings.USER_INFO, settings.URLS,settings.ASSESS_MSG) init = Init(WELCOME_MESSAGE, wifi_loginer, downloader,assesser) init.run() diff --git a/core/source.py b/core/source.py index 9c54593..91797fa 100644 --- a/core/source.py +++ b/core/source.py @@ -58,10 +58,11 @@ def _login(self): class Downloader(Loginer): - def __init__(self, user_info, urls, source_dir): + def __init__(self, user_info, urls, source_dir,filter_list): super().__init__(user_info, urls) self._logger = logging.getLogger("Downloader") self._source_dir = source_dir + self._filter_list = filter_list self._update_sources = [] self._l_course_info = [] self._d_source_info = {} @@ -228,8 +229,9 @@ def _download_course(self, course_info): def _download_all(self): for course_info in self._l_course_info: - self._set_source_info(course_info) - self._download_course(course_info) + if course_info['name'] not in self._filter_list: + self._set_source_info(course_info) + self._download_course(course_info) if self._update_sources: self._logger.info("[同步完成] 本次更新资源列表如下:") for source in self._update_sources: @@ -237,15 +239,38 @@ def _download_all(self): else: self._logger.info("[同步完成] 本次无更新内容!") + def __open_dir(self): + ''' + 当同步完成的时候,打开对应的目录 + :return: + ''' + if sys.platform.startswith('win'): + result = os.system('start ' + self._source_dir) + elif sys.platform.startswith('linux'): + result = os.system('nautilus ' + self._source_dir) + else: + result = os.system('open ' + self._source_dir) + if result == 0: + print("已为您打开资源目录,请根据更新资源列表查询对应文件!") + else: + print("打开资源目录失败,请手动开启!") + def _download_course_by_season(self,season): for course_info in self._l_course_info: - if season in course_info['name']: + if season in course_info['name'] and course_info['name'] not in self._filter_list: 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') + + is_open = input("是否打开资源所在目录(默认n)?(y/n)") + if is_open: + self.__open_dir() + exit(200) + else: self._logger.info("[同步完成] 本次无更新内容!") diff --git a/img/1.5.0-1.png b/img/1.5.0-1.png new file mode 100644 index 0000000..154d51e Binary files /dev/null and b/img/1.5.0-1.png differ diff --git a/img/1.5.0-2.png b/img/1.5.0-2.png new file mode 100644 index 0000000..f7a6788 Binary files /dev/null and b/img/1.5.0-2.png differ diff --git a/settings.py b/settings.py index 5e1806e..e86233e 100644 --- a/settings.py +++ b/settings.py @@ -40,3 +40,10 @@ 'item_43': '我觉得这个老师讲课十分有趣,课堂氛围十分活跃,是我喜欢的地方!', # 这位老师的教学,你最喜欢什么? 'item_44': '老师简直完美,我对老师的敬仰犹如滔滔江水,连绵不绝!!!!' # 您对老师有哪些意见和建议? } + + +# Do not download list +FILTER_LIST = [ + '没啥卵用课-1 19-20春季', + '有点卵用课-2 19-20春季', # 多个之间逗号隔开,务必输入课程全称! +] \ No newline at end of file