Skip to content

Commit

Permalink
support all platform
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinkle23897 committed Feb 25, 2020
1 parent cd561a3 commit 7d1696d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 32 deletions.
41 changes: 22 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@ name: PyInstaller
on: [push]
jobs:
build:
runs-on: windows-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: build with pyinstaller
run: |
pyinstaller --onefile learn-stdio.py
- name : Upload artifact
uses: actions/upload-artifact@master
with:
name: learn-stdio
path: dist/learn-stdio.exe
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: build with pyinstaller
run: |
pyinstaller --onefile learn-stdio.py -n learn-stdio-${{ matrix.os }}
- name : Upload artifact
uses: actions/upload-artifact@master
with:
name: learn-stdio
path: dist/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Features

0. Windows支持双击运行[详情点击](https://github.com/Trinkle23897/learn2018-autodown/releases),Mac和Linux可在安装完python3和依赖之后直接运行脚本
0. 跨平台支持:Windows/Mac/Linux支持双击运行[详情点击](https://github.com/Trinkle23897/learn2018-autodown/releases)
1. 下载所有课程公告
2. 下载所有课件
3. 下载所有作业文件及其批阅情况
Expand Down Expand Up @@ -61,14 +61,6 @@ pip3 install -r requirements.txt --user -U

### 登录选项(learn-stdio中禁用)

使用Cookie登录而不是输入info密码:

```bash
./leearn.py --cookie your_cookie_filename
```

其中cookie文件格式可参考 `example_cookie.txt`

懒得每次输入info账号密码?创建文件`.pass`,写入info账号和密码之后可以自动登录,或者是:

```bash
Expand All @@ -82,6 +74,14 @@ info账号
info密码
```

使用Cookie登录而不是输入info密码:

```bash
./learn.py --cookie your_cookie_filename
```

其中cookie文件格式可参考 `example_cookie.txt`

## Common Issues

- 卡在login:网络原因,看看pulse-secure关了没,重跑试试看
Expand Down
11 changes: 7 additions & 4 deletions learn.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def download(uri, name):
with TqdmUpTo(ascii=True, dynamic_ncols=True, unit='B', unit_scale=True, miniters=1, desc=filename) as t:
urllib.request.urlretrieve(url+uri, filename=filename, reporthook=t.update_to, data=None)
except:
print('Could not download %s due to networking ... removing broken file' % filename)
print('Could not download file %s ... removing broken file' % filename)
if os.path.exists(filename):
os.remove(filename)
return
Expand Down Expand Up @@ -213,10 +213,13 @@ def sync_hw(c):
if c['_type'] == 'student':
append_hw_csv(os.path.join(path, 'info_%s.csv' % c['wlkcid']), hw)
page = bs(get_page('/f/wlxt/kczy/zy/student/viewCj?wlkcid=%s&zyid=%s&xszyid=%s' % (hw['wlkcid'], hw['zyid'], hw['xszyid'])), 'html.parser')
files = page.findAll(class_='wdhere')
for f in files:
files = page.findAll(class_='fujian')
for i, f in enumerate(files):
if len(f.findAll('a')) == 0:
continue
os.chdir(path) # to avoid filename too long
download('/b/wlxt/kczy/zy/%s/downloadFile/%s/%s' % (c['_type'], hw['wlkcid'], f.findAll('a')[-1].attrs['onclick'].split("ZyFile('")[-1][:-2]), name=hw['xh']+'_'+f.findAll('a')[0].text)
name = (hw['xh']+'_'+f.findAll('a')[0].text) if i >= 2 else f.findAll('a')[0].text
download('/b/wlxt/kczy/zy/%s/downloadFile/%s/%s' % (c['_type'], hw['wlkcid'], f.findAll('a')[-1].attrs['onclick'].split("ZyFile('")[-1][:-2]), name=name)
os.chdir(now)
else:
print(hw['bt'])
Expand Down

0 comments on commit 7d1696d

Please sign in to comment.