Skip to content

Commit fae393b

Browse files
committed
feat: new conf, i18n and something else
- 完善 Altfe 框架 - 完善 前端设置面板 - 新增 全局配置模块 - 新增 i18n 多语言支持模块 - 新增 中文、英文语言 - 新增 前端 R18 过滤选项
1 parent 831cc0f commit fae393b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+876
-402
lines changed

.github/workflows/pkg.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ jobs:
5252
cp -r ./app/ ./.pkg/code/app/
5353
cp ./main.py ./.pkg/code/
5454
cp -r ./usr/ ./.pkg/public/usr/
55-
cp ./config.yml ./.pkg/public/
55+
cp ./app/config/biu_default.yml ./.pkg/public/
5656
cp ./LICENSE ./.pkg/public/
5757
cp ./README.md ./.pkg/public/
58+
mv ./.pkg/public/biu_default.yml ./.pkg/public/config.yml
5859
5960
- name: Setup Python 3.7
6061
uses: actions/[email protected]

.pkg/py-pkger.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ def run_script(self, pathname):
129129
finder.run_script(x[0])
130130
for name, mod in finder.modules.items():
131131
module = name.split(".")[0] if os.name == "nt" else name
132+
if module[0] == "_" and module[1:] in hiddenImport:
133+
continue
132134
if module not in hiddenImport:
133135
hiddenImport.append(module)
134136
for x in hiddenImport:
@@ -150,7 +152,7 @@ def run_script(self, pathname):
150152
deleteDIR(DIST_PATH)
151153

152154
# 复制 PUBLIC 文件
153-
copyDIR(PUBLIC_PATH, DIST_PATH, True, ["cache", ".token.json", ".DS_Store"])
155+
copyDIR(PUBLIC_PATH, DIST_PATH, True, ["cache", "__pycache__", ".token.json", ".DS_Store"])
154156

155157
# PyInstaller 打包
156158
os.system("pyinstaller%s %s" % (forarg, os.path.join(CODE_PATH, "main.py")))

README.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# PixivBiu
22

3-
PixivBiu 是一款不错的 Pixiv 搜索**辅助**工具。
3+
PixivBiu 是一款不错的 Pixiv **辅助**工具。
4+
5+
English README is [here](./README_EN.md).
46

57
## 基础功能
68

7-
* Pixiv 搜索,可免会员按收藏数排序
9+
* Pixiv 搜索,可免会员按收藏数、人气排序
810
* 下载原始图片,包括插画、漫画、动图
911
* 多种下载模式,单、多线程模式以及 aria2 支持
1012
* 获取用户的作品、收藏夹、关注列表、相关推荐等
@@ -16,13 +18,13 @@ PixivBiu 是一款不错的 Pixiv 搜索**辅助**工具。
1618
### 源码
1719

1820
* 安装依赖,执行 `pip install -r requirements.txt`
19-
+ [flask](https://github.com/pallets/flask)
21+
+ [Flask](https://github.com/pallets/flask)
2022
+ [requests](https://github.com/psf/requests)
2123
+ [PyYAML](https://github.com/yaml/pyyaml)
2224
+ [Pillow](https://github.com/python-pillow/Pillow)
2325
+ [PixivPy](https://github.com/upbit/pixivpy)
2426
+ [PySocks](https://github.com/Anorov/PySocks)
25-
* 修改 `./config.yml` 相关配置选项,具体参见注释
27+
* 修改 `./config.yml` 相关配置选项,具体可参考[默认配置文件](./app/config/biu_default.yml)
2628
* 执行 `python main.py`
2729
* 访问运行地址,默认为 `http://127.0.0.1:4001/`
2830

@@ -32,7 +34,7 @@ PixivBiu 是一款不错的 Pixiv 搜索**辅助**工具。
3234

3335
这里只提供 Windows 和 macOS 的编译版本,如有其他需求请自行编译。
3436

35-
具体可在 [Releases](https://github.com/txperl/PixivBiu/releases) 中下载,或者[在这](https://biu.tls.moe/#/lib/dl)下载。
37+
具体可在 [releases](https://github.com/txperl/PixivBiu/releases) 中下载,或者[在这](https://biu.tls.moe/#/lib/dl)下载。
3638

3739
## 文档
3840

README_EN.md

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# PixivBiu
2+
3+
PixivBiu is a nice Pixiv **assistant** tool.
4+
5+
中文的 README 在[这里](./README.md)
6+
7+
## Features
8+
9+
* Pixiv search, sort by favorites and popularity without membership
10+
* Download original images, including illustrations, comics and motion pictures
11+
* Multiple download modes, single and multi-threaded mode and aria2 support
12+
* Get user's works, favorites, followers, related recommendations, etc.
13+
* Get rankings, including today's, this week's, and this month's rankings, etc.
14+
* Favorite works, followers, etc.
15+
16+
## Usage
17+
18+
### Source Code
19+
20+
* Install dependencies, run `pip install -r requirements.txt`
21+
+ [Flask](https://github.com/pallets/flask)
22+
+ [requirements](https://github.com/psf/requests)
23+
+ [PyYAML](https://github.com/yaml/pyyaml)
24+
+ [Pillow](https://github.com/python-pillow/Pillow)
25+
+ [PixivPy](https://github.com/upbit/pixivpy)
26+
+ [PySocks](https://github.com/Anorov/PySocks)
27+
* Edit `./config.yml` configuration file, refer to the [default configuration file](./app/config/biu_default.yml)
28+
* Run `python main.py`
29+
* Open the running address, the default is `http://127.0.0.1:4001/`
30+
31+
### Executable Binary File
32+
33+
This project is developed by `[email protected](+)` and uses `PyInstaller` to build the executable binary file.
34+
35+
There are only Windows and macOS version available here, so please build yourself if needed.
36+
37+
They can be downloaded in [releases](https://github.com/txperl/PixivBiu/releases), or [here](https://biu.tls.moe/#/lib/dl).
38+
39+
## Documentation
40+
41+
Currently, there is **usage, development** type documentation, please visit [PixivBiu](https://biu.tls.moe/) if you need it.
42+
43+
## Contribution
44+
45+
If you want to participate in the development of this project, you are welcome to check [Development Documentation](https://biu.tls.moe/#/develop/quickin).
46+
47+
## Other
48+
49+
### Thanks to
50+
51+
* [pixivpy](https://github.com/upbit/pixivpy) API support
52+
* [pixiv.cat](https://pixiv.cat/) Anti-generation server support
53+
* [HTML5 UP](https://html5up.net/) Front-end code support
54+
55+
### Terms
56+
57+
* This program (PixivBiu) is for learning and exchange only, please delete it yourself after the initial purpose is achieved
58+
* Any unknowable event after use has nothing to do with the original author, and the original author will not bear any consequences.
59+
* [MIT License](https://choosealicense.com/licenses/mit/)

altfe/bridge.py

+53-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import importlib.util
22
import os
3+
import random
4+
import string
35

46
from altfe.interface.root import classRoot
57

@@ -12,37 +14,67 @@ class bridgeInit(classRoot):
1214
def __init__(self):
1315
self.rootPath = self.getENV("rootPathFrozen")
1416
self.APP_PATH = {
17+
"ins": self.rootPath + "app/lib/ins/",
1518
"static": self.rootPath + "app/lib/static/",
1619
"common": self.rootPath + "app/lib/common/",
1720
"core": self.rootPath + "app/lib/core/",
1821
"pre": self.rootPath + "app/pre/",
1922
"plugin": self.rootPath + "app/plugin/"
2023
}
2124

22-
def run(self):
23-
self.loadAllModules()
24-
classRoot.mount(["LIB_STATIC", "LIB_COMMON"])
25+
def run(self, hint=False):
26+
if hint:
27+
print("[Altfe] ;)")
28+
bridgeInit.load_all(self.read_all_modules())
29+
classRoot.mount(["LIB_STATIC"])
30+
classRoot.instantiate(["LIB_INS"])
31+
classRoot.mount(["LIB_INS", "LIB_COMMON"])
2532
classRoot.instantiate(["LIB_CORE", "PRE"])
2633
classRoot.mount(["LIB_CORE", "PRE", "PLUGIN"])
2734

28-
def loadAllModules(self):
35+
def read_all_modules(self):
36+
r = []
2937
conf = classRoot.loadConfig(self.rootPath + "app/config/switch.yml")["OnOff"]
30-
for dirName in self.APP_PATH:
31-
rPath = self.APP_PATH[dirName]
32-
files = os.listdir(rPath)
33-
for file in files:
34-
if dirName in conf and conf[dirName] is not None and file in conf[dirName]:
35-
if not conf[dirName][file]:
36-
continue
37-
r = rPath + file
38-
if os.path.isdir(r):
39-
tmp = os.listdir(r)
38+
for moduleType in self.APP_PATH:
39+
rootModulePath = self.APP_PATH[moduleType]
40+
files = os.listdir(rootModulePath)
41+
files.sort()
42+
for fileName in files:
43+
# skip
44+
if not bridgeInit.is_load(conf, moduleType, fileName):
45+
continue
46+
# read
47+
moduleName = "%s_%s_%s" % (moduleType, "".join(
48+
random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(5)), fileName)
49+
filePath = rootModulePath + fileName
50+
# dir handle
51+
if os.path.isdir(filePath):
52+
filePath += "/"
53+
tmp = os.listdir(filePath)
4054
if "main.py" in tmp:
41-
r += "/main.py"
55+
r.append([moduleName, filePath + "main.py"])
4256
else:
43-
continue
44-
elif file[-3:] != ".py":
45-
continue
46-
spec = importlib.util.spec_from_file_location(dirName + "_" + file, r)
47-
cls = importlib.util.module_from_spec(spec)
48-
spec.loader.exec_module(cls)
57+
for x in tmp:
58+
if x[-3:] == ".py" and bridgeInit.is_load(conf, moduleType, x):
59+
r.append([moduleName, filePath + x])
60+
elif fileName[-3:] == ".py":
61+
r.append([moduleName, filePath])
62+
return r
63+
64+
@staticmethod
65+
def is_load(conf, moduleType, fileName):
66+
if moduleType in conf and conf[moduleType] is not None and fileName in conf[moduleType]:
67+
if not conf[moduleType][fileName]:
68+
return False
69+
return True
70+
71+
@staticmethod
72+
def load_all(modules):
73+
for x in modules:
74+
bridgeInit.load_single(*x)
75+
76+
@staticmethod
77+
def load_single(name, path):
78+
spec = importlib.util.spec_from_file_location(name, path)
79+
cls = importlib.util.module_from_spec(spec)
80+
spec.loader.exec_module(cls)

altfe/interface/root.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class classRoot(object):
1414
"""
1515
__ENV = {}
1616
__MODULE = {
17+
"LIB_INS": {},
1718
"LIB_STATIC": {},
1819
"LIB_COMMON": {},
1920
"LIB_CORE": {},
@@ -80,9 +81,9 @@ def wrapper(module):
8081
return wrapper
8182

8283
@staticmethod
83-
def loadConfig(uri):
84+
def loadConfig(uri, default=False):
8485
if not os.path.exists(uri):
85-
return False
86+
return default
8687
with open(uri, "r", encoding="UTF-8") as f:
8788
sfx = uri.split(".")[-1]
8889
if sfx == "json":

app/config/biu_default.yml

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# It is the default configuration file for PixivBiu.
2+
# There is no English version yet... It will be available soon.
3+
# You can use the translation tool to read it, for now.
4+
5+
## 系统相关 ##
6+
sys.host: "127.0.0.1:4001"
7+
# 程序运行的地址,如果不是很懂请不要修改
8+
# 不可带有 http:// 前缀
9+
10+
sys.isDebug: false
11+
# 调试模式
12+
# true 为开启;false 为关闭
13+
14+
sys.api: "public"
15+
# 默认 api 模式
16+
# public: 可以使用全功能,但必须需要代理(翻墙)
17+
# byPassSni: 可以使用全功能,但无需代理(无需翻墙)
18+
19+
sys.proxy: ""
20+
# 本地代理服务监听地址
21+
# 如 http://127.0.0.1:1080/
22+
# 留空则程序会自动检测系统代理设置(仅 Windows、macOS)
23+
# 填入 no 则不使用任何代理
24+
25+
sys.language: ""
26+
# 语言设置,留空为程序自动判断
27+
# 可选:cn、en
28+
29+
sys.theme: "multiverse"
30+
# 默认主题
31+
# 暂无其他,请保持默认为 multiverse
32+
33+
sys.autoOpen: true
34+
# 启动后自动打开程序运行网址
35+
36+
37+
## 搜索相关 ##
38+
biu.search.maxThreads: 8
39+
# 搜索池最大线程数
40+
41+
biu.search.loadCacheFirst: true
42+
# 搜索时优先加载本地缓存
43+
# true 为开启;false 为关闭
44+
45+
46+
## 下载相关 ##
47+
biu.download.mode: "dl-single"
48+
# 下载模式
49+
# dl-single: 程序单线程下载
50+
# aria2: 使用 aria2 下载,如果启用此项,还需填写下方的 aria2Host、aria2Secret
51+
# dl: [暂不推荐] 程序多线程下载,暂时不稳定
52+
53+
biu.download.aria2Host: "localhost:6800"
54+
# aria2 RPC 监听地址,如 localhost:6800
55+
56+
biu.download.aria2Secret: ""
57+
# aria2 RPC 密钥,如未设置请留空
58+
59+
biu.download.maxDownloading: 8
60+
# 最大同时下载任务数
61+
62+
biu.download.saveURI: "{ROOTPATH}/downloads/{KT}/"
63+
# 下载保存路径,以 / 结尾
64+
# 不可使用 \ 符号,请将其替换为 / 或 \\
65+
# 可选变量
66+
# - {ROOTPATH}: 程序根目录
67+
# - {HOMEPATH}: 用户主目录,可能为 /Users/user/、C:/Users/user/、/home/user/
68+
# - {KT}: 搜索关键词
69+
# - {title}: 作品标题
70+
# - {work_id}: 作品 ID
71+
# - {user_name}: 作者名称
72+
# - {user_id}: 作者 ID
73+
# - {type}: 作品类型
74+
# - {date_image}: 作品的日期
75+
# - {date_today}: 今天的日期
76+
77+
biu.download.saveFileName: "{title}_{work_id}"
78+
# 下载图片的标题
79+
# 不可使用 \ 符号,请将其替换为 \\
80+
# 可选变量
81+
# - {title}: 作品标题
82+
# - {work_id}: 作品 ID
83+
# - {user_name}: 作者名称
84+
# - {user_id}: 作者 ID
85+
# - {type}: 作品类型
86+
# - {date_image}: 作品的日期
87+
# - {date_today}: 今天的日期
88+
89+
biu.download.autoArchive: true
90+
# 自动将拥有多张图片的作品归档(放入一个文件夹中)
91+
# true 为开启;false 为关闭
92+
93+
biu.download.autoDeterTheSame: true
94+
# 自动判断下载目录中重名图片是否相同
95+
# 若相同,则只保留一份;若不同,则自动将新图片重命名
96+
# true 为开启;false 为关闭
97+
98+
biu.download.whatsUgoira: "webp"
99+
# 将动图转换为指定格式
100+
# 可选 webp, gif
101+
102+
biu.download.imageHost: ""
103+
# 下载时使用的 Pixiv 图片服务器
104+
# 留空则程序自动判断
105+
# 参考如下:
106+
# https://i.pximg.net 官方图片服务器(需代理)
107+
# https://i.pixiv.cat 第三方反代图片服务器(需代理)
108+
# https://i.pixiv.re 第三方反代图片服务器(无需代理)

0 commit comments

Comments
 (0)