mirror of
https://github.com/JoeanAmier/XHS-Downloader.git
synced 2025-12-26 04:48:05 +08:00
优化项目代码
This commit is contained in:
parent
6f0cda3668
commit
5c913b6482
@ -34,7 +34,9 @@
|
||||
<h1>📸 程序截图</h1>
|
||||
<br>
|
||||
<p><b>🎥 点击图片观看演示视频</b></p>
|
||||
<a href="https://www.bilibili.com/video/BV1nQ4y137it/"><img src="static/程序运行截图.png" alt=""></a>
|
||||
<a href="https://www.bilibili.com/video/BV1nQ4y137it/"><img src="static/程序运行截图1.png" alt=""></a>
|
||||
<hr>
|
||||
<a href="https://www.bilibili.com/video/BV1nQ4y137it/"><img src="static/程序运行截图2.png" alt=""></a>
|
||||
<h1>🔗 支持链接</h1>
|
||||
<ul>
|
||||
<li><code>https://www.xiaohongshu.com/explore/作品ID</code></li>
|
||||
|
||||
14
README_EN.md
14
README_EN.md
@ -0,0 +1,14 @@
|
||||
<div align="center">
|
||||
<img src="static/XHS-Downloader.png" alt="" height="256" width="256"><br>
|
||||
<h1>XHS-Downloader</h1>
|
||||
<p><a href="README.md">简体中文</a> | English</p>
|
||||
<img alt="GitHub" src="https://img.shields.io/github/license/JoeanAmier/XHS-Downloader?style=for-the-badge&color=ff7a45">
|
||||
<img alt="GitHub forks" src="https://img.shields.io/github/forks/JoeanAmier/XHS-Downloader?style=for-the-badge&color=9254de">
|
||||
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/JoeanAmier/XHS-Downloader?style=for-the-badge&color=ff7875">
|
||||
<img alt="Static Badge" src="https://img.shields.io/badge/UserScript-ffec3d?style=for-the-badge&logo=tampermonkey&logoColor=%2300485B">
|
||||
<br>
|
||||
<img alt="GitHub code size in bytes" src="https://img.shields.io/github/languages/code-size/JoeanAmier/XHS-Downloader?style=for-the-badge&color=73d13d">
|
||||
<img alt="GitHub release (with filter)" src="https://img.shields.io/github/v/release/JoeanAmier/XHS-Downloader?style=for-the-badge&color=40a9ff">
|
||||
<img alt="GitHub all releases" src="https://img.shields.io/github/downloads/JoeanAmier/XHS-Downloader/total?style=for-the-badge&color=f759ab">
|
||||
</div>
|
||||
<br>
|
||||
@ -42,7 +42,11 @@ class XHSDownloader(App):
|
||||
self.APP = XHS(**self.parameter, language_object=self.prompt)
|
||||
|
||||
async def on_mount(self) -> None:
|
||||
self.install_screen(Setting(self.parameter), name="setting")
|
||||
self.install_screen(
|
||||
Setting(
|
||||
self.parameter,
|
||||
self.prompt),
|
||||
name="setting")
|
||||
self.install_screen(Index(self.APP, self.prompt), name="index")
|
||||
self.install_screen(Loading(), name="loading")
|
||||
await self.push_screen("index")
|
||||
@ -61,5 +65,9 @@ class XHSDownloader(App):
|
||||
await self.push_screen("loading")
|
||||
self.uninstall_screen("setting")
|
||||
self.__initialization()
|
||||
self.install_screen(Setting(self.parameter), name="setting")
|
||||
self.install_screen(
|
||||
Setting(
|
||||
self.parameter,
|
||||
self.prompt),
|
||||
name="setting")
|
||||
await self.push_screen("index")
|
||||
|
||||
@ -13,6 +13,11 @@ from textual.widgets import Label
|
||||
from textual.widgets import Select
|
||||
|
||||
from source.module import ROOT
|
||||
from source.translator import (
|
||||
LANGUAGE,
|
||||
Chinese,
|
||||
English,
|
||||
)
|
||||
|
||||
__all__ = ["Setting"]
|
||||
|
||||
@ -24,53 +29,56 @@ class Setting(Screen):
|
||||
Binding(key="b", action="index", description="返回首页"),
|
||||
]
|
||||
|
||||
def __init__(self, data: dict):
|
||||
def __init__(self, data: dict, language: Chinese | English):
|
||||
super().__init__()
|
||||
self.data = data
|
||||
self.prompt = language
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header()
|
||||
yield ScrollableContainer(
|
||||
Label("工作路径:", classes="params", ),
|
||||
Input(self.data["work_path"], placeholder="程序根路径", valid_empty=True, id="work_path", ),
|
||||
Label("文件夹名称:", classes="params", ),
|
||||
Label(self.prompt.work_path, classes="params", ),
|
||||
Input(self.data["work_path"], placeholder=self.prompt.work_path_placeholder, valid_empty=True,
|
||||
id="work_path", ),
|
||||
Label(self.prompt.folder_name, classes="params", ),
|
||||
Input(self.data["folder_name"], placeholder="Download", id="folder_name", ),
|
||||
Label("User-Agent:", classes="params", ),
|
||||
Input(self.data["user_agent"], placeholder="默认 UA", valid_empty=True, id="user_agent", ),
|
||||
Label("Cookie:", classes="params", ),
|
||||
Input(self.data["cookie"], placeholder="内置 Cookie,建议自行设置", valid_empty=True, id="cookie", ),
|
||||
Label("网络代理:", classes="params", ),
|
||||
Input(self.data["proxy"], placeholder="无代理", valid_empty=True, id="proxy", ),
|
||||
Label("请求超时限制:", classes="params", ),
|
||||
Label(self.prompt.user_agent, classes="params", ),
|
||||
Input(self.data["user_agent"], placeholder=self.prompt.user_agent_placeholder, valid_empty=True,
|
||||
id="user_agent", ),
|
||||
Label(self.prompt.cookie, classes="params", ),
|
||||
Input(self.data["cookie"], placeholder=self.prompt.cookie_placeholder, valid_empty=True, id="cookie", ),
|
||||
Label(self.prompt.proxy, classes="params", ),
|
||||
Input(self.data["proxy"], placeholder=self.prompt.proxy_placeholder, valid_empty=True, id="proxy", ),
|
||||
Label(self.prompt.timeout, classes="params", ),
|
||||
Input(str(self.data["timeout"]), placeholder="10", type="integer", id="timeout", ),
|
||||
Label("数据块大小:", classes="params", ),
|
||||
Label(self.prompt.chunk, classes="params", ),
|
||||
Input(str(self.data["chunk"]), placeholder="1048576", type="integer", id="chunk", ),
|
||||
Label("最大重试次数:", classes="params", ),
|
||||
Label(self.prompt.max_retry, classes="params", ),
|
||||
Input(str(self.data["max_retry"]), placeholder="5", type="integer", id="max_retry", ),
|
||||
Container(
|
||||
Label("", classes="params", ),
|
||||
Label("", classes="params", ),
|
||||
Label("图片下载格式", classes="params", ),
|
||||
Label("程序语言", classes="params", ),
|
||||
Label(self.prompt.image_format, classes="params", ),
|
||||
Label(self.prompt.language, classes="params", ),
|
||||
classes="horizontal-layout",
|
||||
),
|
||||
Container(
|
||||
Checkbox("记录作品数据", id="record_data", value=self.data["record_data"], ),
|
||||
Checkbox("文件夹归档模式", id="folder_mode", value=self.data["folder_mode"], ),
|
||||
Checkbox(self.prompt.record_data, id="record_data", value=self.data["record_data"], ),
|
||||
Checkbox(self.prompt.folder_mode, id="folder_mode", value=self.data["folder_mode"], ),
|
||||
Select.from_values(
|
||||
("PNG", "WEBP"),
|
||||
value=self.data["image_format"],
|
||||
allow_blank=False,
|
||||
id="image_format"),
|
||||
Select.from_values(("zh-CN", "en-US"),
|
||||
Select.from_values(list(LANGUAGE.keys()),
|
||||
value=self.data["language"],
|
||||
allow_blank=False,
|
||||
id="language",
|
||||
disabled=True, ),
|
||||
classes="horizontal-layout"),
|
||||
Container(
|
||||
Button("保存设置", id="save", ),
|
||||
Button("放弃更改", id="abandon", ),
|
||||
Button(self.prompt.save_button, id="save", ),
|
||||
Button(self.prompt.abandon_button, id="abandon", ),
|
||||
classes="settings_button", ),
|
||||
)
|
||||
yield Footer()
|
||||
|
||||
@ -35,14 +35,36 @@ class Chinese:
|
||||
project_address: str = "项目地址:"
|
||||
input_box_title: str = "请输入小红书图文/视频作品链接:"
|
||||
input_prompt: str = "多个链接之间使用空格分隔"
|
||||
download_button: str = "下载无水印图片/视频"
|
||||
download_button: str = "下载无水印作品文件"
|
||||
paste_button: str = "读取剪贴板"
|
||||
reset_button: str = "清空输入框"
|
||||
|
||||
exit_program: str = "退出程序"
|
||||
check_updates: str = "检查更新"
|
||||
get_script: str = "获取脚本"
|
||||
choose_language: str = "选择语言"
|
||||
settings: str = "程序设置"
|
||||
|
||||
work_path: str = "工作路径:"
|
||||
folder_name: str = "文件夹名称:"
|
||||
user_agent: str = "User-Agent:"
|
||||
cookie: str = "Cookie:"
|
||||
proxy: str = "网络代理:"
|
||||
timeout: str = "请求超时限制:"
|
||||
chunk: str = "下载数据块大小:"
|
||||
max_retry: str = "最大重试次数:"
|
||||
record_data: str = "记录作品数据"
|
||||
image_format: str = "图片下载格式"
|
||||
folder_mode: str = "文件夹归档模式"
|
||||
language: str = "程序语言"
|
||||
server: str = "启动本地服务器"
|
||||
|
||||
work_path_placeholder: str = "程序根路径"
|
||||
user_agent_placeholder: str = "默认 UA"
|
||||
cookie_placeholder: str = "内置 Cookie,建议自行设置"
|
||||
proxy_placeholder: str = "无代理"
|
||||
|
||||
save_button: str = "保存配置"
|
||||
abandon_button: str = "放弃更改"
|
||||
|
||||
@staticmethod
|
||||
def request_error(url: str) -> str:
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
Screen, RichLog {
|
||||
background: #2f3542;
|
||||
}
|
||||
Button {
|
||||
width: 1fr;
|
||||
margin: 1 1;
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 123 KiB |
BIN
static/程序运行截图1.png
Normal file
BIN
static/程序运行截图1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 147 KiB |
BIN
static/程序运行截图2.png
Normal file
BIN
static/程序运行截图2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 77 KiB |
Loading…
x
Reference in New Issue
Block a user