Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
fix: Update login
fix: Fix ETA progress
docs: Update readme
chore: Add requirements.txt
  • Loading branch information
chettoy committed May 28, 2022
1 parent 8f5b591 commit d48afa4
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 20 deletions.
38 changes: 24 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ API基于网页端新版页面协议和安卓端超星SDK协议,目前实现



*注:FxxkStar只含有测试版客户端功能,另有基于专有API的学习版客户端*
*注:FxxkStar含有测试版客户端功能*

| | 测试版 | 学习版 |
| -------- | ---------------------------------------------- | ------------------------------------------------------------ |
Expand All @@ -66,36 +66,46 @@ API基于网页端新版页面协议和安卓端超星SDK协议,目前实现

## Installation

You can download FxxkStar by cloning the [Git](https://github.com/chettoy/FxxkStar) repository:
You can download FxxkStar by cloning [the Git repository](https://github.com/chettoy/FxxkStar):

```shell
git clone --depth 1 https://github.com/chettoy/FxxkStar.git FxxkStar-dev
```

FxxkStar works with [Python](https://www.python.org/download/) version 3.10 or above on any platform.

**requirements**

- `requests`, `brotli`, `lxml`, `beautifulsoup4`, `zstandard`, `fonttools`
- `pytesseract` (Only required when using OCR)

You can install the requirements (using the TUNA mirror) with the following command via `pip`.

```shell
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
```

Optional: Additional steps are required to install `pytesseract` data, check the [pytesseract package page](https://pypi.python.org/pypi/pytesseract) for more information. (Required only when OCR is enabled)



**ArchLinux**

install the requirements with:

```shell
sudo pacman -S python-beautifulsoup4 python-brotli python-cryptography python-fonttools \
python-lxml python-pycryptodome python-requests python-zstandard
```



You can install requirements with the following command (using TUNA mirror):
## Usage

```shell
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple requests
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple brotli
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple lxml
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple beautifulsoup4
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple zstandard
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple fonttools
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pytesseract
python fxxkstar.py
```

For **Windows** users, run with *Windows Terminal* to get better experience.


Note: Additional steps are required to install `pytesseract`, check the [pytesseract package page](https://pypi.python.org/pypi/pytesseract) for more information.

## Contributing

Expand Down
26 changes: 20 additions & 6 deletions fxxkstar.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
from typing import List
from collections import Counter
from fontTools.ttLib import TTFont
from Crypto.Cipher import DES
from cryptography.hazmat.primitives import padding


VERSION_NAME = "FxxkStar 0.9"
Expand Down Expand Up @@ -290,20 +292,32 @@ def check_login(self) -> bool:
return False
return True

@staticmethod
def encrypt_by_DES(message: str, key: str) -> str:
key_bytes = key.encode('utf-8')
des = DES.new(key_bytes, DES.MODE_ECB)

data = message.encode('utf-8')
padder = padding.PKCS7(64).padder()
padded_data = padder.update(data) + padder.finalize()

ciphertext = des.encrypt(padded_data)
return ciphertext.hex()

def sign_in(self, uname: str, password: str):
url = "https://passport2.chaoxing.com/fanyalogin"
data = "fid=314&uname={0}&password={1}&refer=http%3A%2F%2Fi.chaoxing.com&t=true&forbidotherlogin=0".format(
uname, base64.b64encode(password.encode("utf-8")).decode("utf-8"))
data = "fid=-1&uname={0}&password={1}&refer=https%3A%2F%2Fi.chaoxing.com&t=true&forbidotherlogin=0&validate=".format(
uname, self.encrypt_by_DES(password, "u2oh6Vu^"))
headers = self.agent.build_headers_based_on({
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Cookie': 'fanyamoocs=11401F839C536D9E; fid=314; isfyportal=1; ptrmooc=t',
'Host': 'passport2.chaoxing.com',
'Cookie': 'source=""',
'Origin': 'https://passport2.chaoxing.com',
'Referer': 'https://passport2.chaoxing.com/login?loginType=4&fid=314&newversion=true&refer=http://i.mooc.chaoxing.com',
'Referer': 'https://passport2.chaoxing.com/login?fid=&newversion=true&refer=https%3A%2F%2Fi.chaoxing.com',
}, self.agent.headers_additional_xhr)
sign_in_rsp = requests.post(url=url, data=data, headers=headers)
sign_in_json = sign_in_rsp.json()

if sign_in_json['status']:
self.uid = sign_in_rsp.cookies['_uid']
for item in sign_in_rsp.cookies:
Expand Down Expand Up @@ -2752,7 +2766,7 @@ def sync_video_progress(self, thread_count=3) -> None:

def print_eta(i: int, total: int) -> None:
if i > total:
i = total
total = i
print()
print(f"{G_STRINGS['tag_total_progress']}: {i}/{total}")
# [####------] 100.0%
Expand Down
9 changes: 9 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
beautifulsoup4==4.10.0
Brotli==1.0.9
cryptography==37.0.0
fonttools==4.33.3
lxml==4.8.0
pycryptodome==3.14.1
requests==2.27.1
urllib3==1.26.9
zstandard==0.17.0

0 comments on commit d48afa4

Please sign in to comment.