From ad0eaf3d18d4f97b82c799e01dcf86a462baeb2a Mon Sep 17 00:00:00 2001 From: YouqingXiaozhua <843213558@qq.com> Date: Fri, 14 Feb 2020 16:59:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8D=87=E7=BA=A7=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 16 +++++++++++++++- readme.md | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 8166030..10b6860 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,7 @@ # @Date : 2016/9/9 # @Author : hrwhisper import codecs +import json import re import os import multiprocessing @@ -14,7 +15,7 @@ class UCASCourse(object): - def __init__(self, time_out=5): + def __init__(self, time_out=5, check_version=True): self.__BEAUTIFULSOUPPARSE = 'html.parser' # or use 'lxml' self.semester = None self.save_base_path, self.semester = UCASCourse._read_info_from_file() @@ -25,6 +26,17 @@ def __init__(self, time_out=5): self.to_download = [] self.lock = multiprocessing.Lock() self._time_out = time_out + self.version = '1.4' + self.check_version = check_version + + def _check_version(self): + r = requests.get('https://api.github.com/repos/youqingxiaozhua/Ucas_course_ppt_auto_download/releases/latest') + github_latest = json.loads(r.text) + version = github_latest['name'] + version_note = github_latest['body'] + if version != self.version: + print('\nA new version (v%s: %s) have been released, please download from this link:' % (github_latest, version_note)) + print('https://github.com/youqingxiaozhua/Ucas_course_ppt_auto_download/releases\n') def _init_session(self): t = LoginUCAS().login_sep() @@ -137,6 +149,8 @@ def _download_file(self, param): print('{dic_name} >> {sub_directory} Download a file'.format(**locals())) def start(self): + if self.check_version: + self._check_version() self._parse_course_list() self._get_all_resource_url() self._start_download() diff --git a/readme.md b/readme.md index fadcdf1..9c0277e 100644 --- a/readme.md +++ b/readme.md @@ -65,6 +65,8 @@ private中,各行表示意义如下: - **觉得好用点个star吧~** ## 更新说明 +- 2020-2-14 新增升级提示 +- 2020-2-14 适配课程网站升级为HTTPS - 更新适配到2019年秋季 - 新增登陆网址,不用验证码 - 修复因为微软CMD下编码不一致导致程序crash