Skip to content

Commit

Permalink
新增升级提示
Browse files Browse the repository at this point in the history
  • Loading branch information
youqingxiaozhua committed Feb 14, 2020
1 parent 40e7981 commit ad0eaf3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# @Date : 2016/9/9
# @Author : hrwhisper
import codecs
import json
import re
import os
import multiprocessing
Expand All @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ private中,各行表示意义如下:
- **觉得好用点个star吧~**

## 更新说明
- 2020-2-14 新增升级提示
- 2020-2-14 适配课程网站升级为HTTPS
- 更新适配到2019年秋季
- 新增登陆网址,不用验证码
- 修复因为微软CMD下编码不一致导致程序crash
Expand Down

0 comments on commit ad0eaf3

Please sign in to comment.