Skip to content

Commit 8e35739

Browse files
committed
PreRev 5.1 - 0526 后端重构,添加Pica源
1 parent 3e79702 commit 8e35739

28 files changed

+1434
-1069
lines changed

.github/workflows/python-app.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Python application
5+
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build:
17+
name: Test on ${{ matrix.os }} / Python ${{ matrix.python-version }}
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
os: [ubuntu-20.04, ubuntu-latest]
23+
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
24+
steps:
25+
- uses: actions/checkout@v3
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v3
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
username: ${{ secrets.USERNAME }}
31+
password: ${{ secrets.PASSWORD }}
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install pytest
36+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
37+
- name: Start the Remote Server
38+
run: |
39+
nohup uvicorn main:app --port 8000 &
40+
- name: Run the test
41+
run: |
42+
pytest
43+
44+

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,4 @@ dmypy.json
130130

131131
.vscode
132132

133+
config/*

Manual.md

-188
This file was deleted.

README.md

+40-16
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,43 @@
2121

2222
|平台|状态|
2323
|:-------:|:------------:|
24-
| 禁漫天堂 | 🔨Working |
25-
| 哔咔漫画 | 📑Intend |
26-
27-
## 运行方法
28-
29-
安装 `FastAPI``BeautifulSoup4``requests` 库。
30-
31-
```bash
32-
pip install FastAPI BeautifulSoup4 requests
33-
```
34-
35-
运行项目根目录下 `main.py` 文件。
36-
37-
```bash
38-
uvicorn main:app --host 0.0.0.0 --port 19190 --reload
39-
```
24+
| 禁漫天堂 | 🔨Working |
25+
| 哔咔漫画 | 🔨Working |
26+
27+
## 计划接口清单
28+
29+
- 禁漫天堂
30+
- 账户登录
31+
- 账户注册
32+
- 漫画搜索
33+
- 关键字搜索
34+
- 高级搜索
35+
- 收藏夹
36+
- 展示收藏夹
37+
- 收藏夹管理
38+
- 漫画收藏管理
39+
- 漫画阅读
40+
- 漫画章节列表
41+
- 漫画图片列表
42+
- 哔咔漫画
43+
- 账户登录
44+
- 账户注册
45+
- 漫画搜索
46+
- 关键字搜索
47+
- 高级搜索
48+
- 收藏
49+
- 展示收藏
50+
- 漫画收藏管理
51+
- 漫画阅读
52+
- 漫画章节列表
53+
- 漫画图片列表
54+
- Friendship Cloud
55+
- 用户登录
56+
- 用户注册
57+
- 用户信息
58+
- 用户标签
59+
- 用户兴趣推荐
60+
- 用户分享
61+
- 用户收藏
62+
- 用户阅读记录
63+
- 用户阅读记录分析

comiknet_test.py

-19
This file was deleted.

core/AsyncRequests.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from typing import List, Optional
2+
import aiohttp
3+
4+
from fastapi.responses import Response
5+
6+
7+
class AsyncRequests:
8+
"""
9+
AsyncRequests Class
10+
~~~~~~~~~~~~~~~~~~~~~
11+
AsyncRequests is a packaged web requests class which based on aiohttp.
12+
13+
This class does not contain any request methods, it only provide some session control utilities.
14+
"""
15+
16+
def __init__(self, base_url: str, cookies: Optional[dict] = None, conn_timeout: int = 15, read_timeout: int = 45) -> None:
17+
self.base_url = base_url
18+
self.session = aiohttp.ClientSession(
19+
base_url=f"https://{base_url}",
20+
cookies=cookies,
21+
conn_timeout=conn_timeout,
22+
read_timeout=read_timeout,
23+
connector=aiohttp.TCPConnector(verify_ssl=False, force_close=True)
24+
)
25+
26+
async def close(self) -> None:
27+
await self.session.close()
28+
29+
def setCookies(self, res: Response, append_cookies: Optional[dict] = None, except_cookies: Optional[List[str]] = None) -> None:
30+
if append_cookies is not None:
31+
for cookie in append_cookies:
32+
res.set_cookie(key=cookie, value=append_cookies[cookie])
33+
34+
if dict(
35+
self.session.cookie_jar._cookies[self.base_url]) != {}: # type: ignore
36+
cookies_dict = dict(
37+
self.session.cookie_jar._cookies[self.base_url]) # type: ignore
38+
else:
39+
cookies_dict = dict(
40+
self.session.cookie_jar._cookies[(self.base_url, "/")]) # type: ignore
41+
for cookie in cookies_dict:
42+
if except_cookies is not None and cookie in except_cookies:
43+
continue
44+
res.set_cookie(key=cookie, value=cookies_dict[cookie].value,
45+
expires=cookies_dict[cookie]["expires"],
46+
path=cookies_dict[cookie]["path"])
47+
48+
def getCookies(self) -> dict:
49+
cookies_dict = dict(
50+
self.session.cookie_jar._cookies[f"{self.base_url}"]) # type: ignore
51+
cookies = {}
52+
for cookie in cookies_dict:
53+
cookies[cookie] = cookies_dict[cookie].value
54+
return cookies

0 commit comments

Comments
 (0)