Compare commits

...

205 Commits
1.9 ... master

Author SHA1 Message Date
Quan
dbbf24b5ba docs: 修正资源路径错误 2025-12-16 14:04:59 +08:00
Quan
855113c94d refactor: 重构运行提示传递逻辑 2025-12-16 12:55:52 +08:00
Quan
8039c6a5db docs: Update Readme 2025-12-16 12:25:40 +08:00
Quan
bbc5d61011 fix: 修复代码逻辑错误 2025-12-16 10:15:31 +08:00
Quan
1e26d89dd8 revert: 修正运行提示错误 2025-12-16 10:04:29 +08:00
Quan
80eee2bb16 fix: 修复方法返回值异常的问题 2025-12-15 23:42:09 +08:00
Quan
8363d8a78d perf(script): 优化用户脚本内容格式 2025-12-15 21:35:14 +08:00
Quan
e53c15ddc1 docs: 更新用户脚本连接服务器功能说明 2025-12-15 21:12:56 +08:00
Quan
9d2547885d feat(script): 链接提取选择界面添加序号显示 2025-12-15 17:40:47 +08:00
Quan
6a182eb310 feat(script): 增加用户脚本服务器设置项 2025-12-15 17:08:52 +08:00
Quan
8382a9abc9 feat(script): 新增推送下载任务至服务器功能 2025-12-15 15:20:13 +08:00
Quan
d7ab7595e6 refactor(app): 调整应用关闭逻辑 2025-12-13 00:04:19 +08:00
Quan
9d1861b59e build(workflow): 处理 FastMCP 导致的构建错误 2025-12-12 22:25:34 +08:00
Quan
d67a1d233d perf: 修改 script server 默认端口 2025-12-12 21:45:27 +08:00
Quan
a7e3ed24e7 build(workflow): 添加 diskcache 隐藏导入依赖 2025-12-12 10:30:06 +08:00
Quan
1045d0aaf9 feat: 新增作品处理统计功能 2025-12-11 23:00:08 +08:00
Quan
e747d94396 docs: 更新项目环境配置说明 2025-12-11 22:20:41 +08:00
Quan
96be49116c chore(deps): 更新项目依赖版本 2025-12-06 14:45:27 +08:00
Quan
41c83af184 fix: 修复 MCP 模式无法下载文件的问题
Closes #322
2025-11-30 10:55:45 +08:00
Quan
1e5ffc1907 refactor: 新增用户脚本服务器代码 2025-11-08 21:30:18 +08:00
Quan
f72b163eb8 build: 更新项目依赖信息 2025-11-04 11:20:48 +08:00
dependabot[bot]
bd7078211b
build(deps): bump fastmcp in the pip group across 1 directory
Bumps the pip group with 1 update in the / directory: [fastmcp](https://github.com/jlowin/fastmcp).


Updates `fastmcp` from 2.12.4 to 2.13.0
- [Release notes](https://github.com/jlowin/fastmcp/releases)
- [Changelog](https://github.com/jlowin/fastmcp/blob/main/docs/changelog.mdx)
- [Commits](https://github.com/jlowin/fastmcp/compare/v2.12.4...v2.13.0)

---
updated-dependencies:
- dependency-name: fastmcp
  dependency-version: 2.13.0
  dependency-type: direct:production
  dependency-group: pip
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-29 15:41:36 +00:00
Quan
7f726ff726 docs: Update README.md 2025-10-25 11:30:05 +08:00
Quan
0338e08e46 build: 更新项目依赖信息 2025-10-17 11:30:29 +08:00
Quan
b9942ae332 ci: update macOS runner versions in build workflows 2025-10-17 11:25:20 +08:00
Quan
afdb9ed511 chore: 更新项目依赖信息 2025-10-14 09:45:49 +08:00
Quan
f2c52cbe89 perf: 调整内置延时机制 2025-09-16 13:05:07 +08:00
Quan
af63050292 perf: 更新 Script 元数据和样式名称 2025-08-19 00:15:04 +08:00
Quan
8023dbd81f fix(script): 修复用户脚本功能异常 2025-08-14 21:10:15 +08:00
Quan
67479affb2 fix(script): 修复合辑作品链接提取失败的问题 2025-08-14 10:40:03 +08:00
Quan
08c5443289 feat(script): 新增链接提取/图片下载选择模式开关 2025-08-14 10:30:18 +08:00
Quan
3fe81aa124 fix(script): 修复合辑作品链接提取失败的问题 2025-08-14 09:55:07 +08:00
Quan
bcd6b97a63 feat(app): 发布 2.6 版本 2025-08-11 13:00:57 +08:00
Quan
ad2320a689 docs: 更新项目英语翻译 2025-08-10 23:48:08 +08:00
Quan
1ceb97e9c2 perf(script): 优化图文作品复选弹窗显示效果 2025-08-10 23:24:28 +08:00
Quan
d5e0fa7b89 perf(script): 优化图文作品复选弹窗显示效果 2025-08-10 23:16:03 +08:00
Quan
ef7c793c16 perf(script): 优化用户脚本运行状态提示 2025-08-10 17:32:58 +08:00
Quan
1e1a1a0257 feat(script): 优化图文作品复选弹窗交互效果 2025-08-10 17:09:49 +08:00
Quan
e22944cc1c refactor(script): 优化运行弹窗提示的交互界面样式 2025-08-10 16:37:42 +08:00
Quan
4895ddab25 fix(script): 修复提取搜索结果作品链接失败的问题 2025-08-10 16:22:54 +08:00
Quan
5b54e78582 feat(script): 新增支持仅提取勾选的作品链接 2025-08-10 16:13:58 +08:00
Quan
120e5d65c3 refactor(script): 优化部分弹窗提示的交互界面样式 2025-08-10 13:41:48 +08:00
Quan
9ad005c381 feat(script): 添加未登录状态下无法提取作品链接的提示 2025-08-10 00:04:20 +08:00
Quan
f39f5a8552 perf(script): 优化作品 ID 提取逻辑 2025-08-09 10:11:45 +08:00
Quan
99397db7cc chore(workflows): include fastmcp metadata in PyInstaller build steps 2025-08-08 21:25:16 +08:00
Quan
71741fa962 ci: 调整过时问题和 PR 的自动管理频率 2025-08-06 10:41:20 +08:00
Quan
7c523af567 docs(README): 更新容器创建命令示例 2025-08-05 13:05:04 +08:00
Quan
b3f0c7afb6 feat(script): 脚本设置新增 菜单始终显示 配置项 2025-08-04 22:55:06 +08:00
Quan
7102565c64 build: 优化 Docker 构建过程并添加新平台支持 2025-08-04 15:55:20 +08:00
Quan
348e8bd40d chore(workflows): add manual trigger and adjust scheduling rules 2025-08-04 10:00:18 +08:00
Quan
9e6b819eb5 feat: 命令行模式支持传递多个作品链接
Closes #280
2025-08-02 19:05:37 +08:00
Quan
20cdd13eee docs: add ZMTO sponsorship section to README 2025-08-02 09:59:59 +08:00
Quan
0698e5ba90 docs: 更新路径说明与更新指南
1. 修订默认路径为 _internal\Volume 相关说明
2. 调整更新指南以配合新目录结构
3. 更新 Docker 命令说明

Closes #274
2025-08-01 11:45:04 +08:00
Quan
1b48e70d44 perf: 新增 folder_name 参数检查 2025-08-01 11:15:16 +08:00
Quan
079fe6c1f7 refactor: 配置与文件归集到单文件夹 2025-08-01 11:00:06 +08:00
Quan
0a9f2f3059 perf: 优化配置文件参数容错机制 2025-08-01 09:45:10 +08:00
Quan
e5d628ba93 docs(MCP): 更新 Docker 的命令示例 2025-07-29 12:44:59 +08:00
Quan
d5081f0ff9 fix(server): 修复 API 模式失效的问题
1. 拆分 API 模式和 MCP 模式
2. 修改服务器模式启动命令
3. 修正示例代码错误

Closes #273
2025-07-29 12:24:58 +08:00
Quan
0c7f5eb32c chore(dependencies): 更新项目依赖版本 2025-07-28 17:50:47 +08:00
Quan
e0fbd7916d perf: 优化提取链接的正则表达式
Closes #261
2025-07-28 17:30:53 +08:00
Quan
b63f546b3a perf: 支持更多作品链接格式
Closes #272
2025-07-28 17:00:07 +08:00
Quan
5e6f4d9576 revert: 修复图文作品文件格式异常的问题 2025-07-27 23:34:56 +08:00
Quan
8dd8761f88 perf(MCP): 重构 MCP 接口以改进功能和描述 2025-07-17 23:10:11 +08:00
Quan
c5b1f01b02 docs(MCP): 更新 MCP 调用的相关说明 2025-07-17 17:35:04 +08:00
Quan
1e163acc06 feat(server): 服务器模式支持通过 MCP 调用 2025-07-17 16:00:01 +08:00
Quan
87044f150b fix: 修复作品类型判断不完整的问题
Closes #268
2025-07-16 14:55:02 +08:00
Quan
4d77a12cd9 fix: 修复作品类型判断失败时异常退出的问题 2025-07-16 10:50:03 +08:00
Quan
f56046c810 fix: 修复部分图文作品下载失败的问题
Closes #264
2025-07-12 22:10:27 +08:00
Quan
da0dffb890 docs: Add DartNode sponsorship section to README 2025-07-06 17:35:20 +08:00
bbd2fe22df docs: 更新 README 2025-07-04 12:50:06 +08:00
1eea31d5bc perf: 优化提取链接的正则表达式 2025-06-26 22:25:21 +08:00
a916180284 ci: 调整过时问题和 PR 的自动管理流程并添加删除 GHCR 未标记镜像的工作流 2025-06-24 19:35:04 +08:00
f3b674c637 fix: 修复用户脚本 CSS 样式冲突问题
Closes #258
2025-06-19 17:10:18 +08:00
1034efc551 perf(api): 修改 API 模式默认端口为 5556 2025-06-15 20:55:13 +08:00
600f2fb60c docs: 更新 README 2025-05-28 20:00:40 +08:00
c1ad2e20a9 docs(README): 更新项目免责声明 2025-05-17 16:10:08 +08:00
af823116b0 ci: 优化 Docker 镜像发布流程并支持 GHCR
- 修改 Docker 镜像发布流程,同时支持 Docker Hub 和 GitHub Container Registry (GHCR)
- 更新手动发布和自动发布工作流,增加版本号和标签处理逻辑
- 调整过时问题和 PR 自动管理策略,缩短处理周期
- 在 README 中添加通过 GHCR 拉取镜像的方式
2025-05-16 13:55:12 +08:00
92dd28c815 feat: 支持音乐图集作品下载 2025-05-12 19:15:22 +08:00
a8669caeb9 docs(README): 更新徽章样式和颜色 2025-05-07 20:20:43 +08:00
8533ad6538 build: 更新 Docker 运行教程 2025-05-06 21:35:53 +08:00
07bb06398c ci: 更新工作流文件并添加星标历史图表
- 在 Close_Stale_Issues_and_PRs.yaml 中添加英文通知消息
- 在 README.md 和 README_EN.md 中添加星标历史图表
2025-04-29 19:05:13 +08:00
69490e526a ci: 添加自动管理过时 Issues 和 PRs 的 GitHub Actions 工作流
- 新增 .github/workflows/Close_Stale_Issues_and_PRs.yaml 文件
- 配置每日定时任务,自动检测和管理过时的 Issues 和 PRs
- 设置过时提醒和自动关闭的消息内容
- 定义过时和自动关闭的时间限制
- 添加相应的标签以标记过时和自动关闭的 Issues 和 PRs
- 配置免于自动管理的标签
2025-04-26 20:20:05 +08:00
39438ccb32 fix(script): 修复单张图片的作品下载后文件损坏问题 2025-04-23 21:45:05 +08:00
d11929e92d feat: 发布 2.5 版本 2025-04-20 21:00:11 +08:00
936b4f9075 feat: 支持以发布时间作为文件修改时间
1. 新增 write_mtime 配置参数
2. 更新项目英语翻译
2025-04-20 18:57:06 +08:00
d972420ab3 refactor(script): 重构用户脚本代码
1. 重构用户脚本交互界面
2. 重构用户脚本交互效果
3. 新增选择图片下载功能
4. 重构用户脚本设置面板
2025-04-15 22:15:28 +08:00
8420685019 fix(translation): 优化语言代码获取逻辑
- 增加对空语言代码的处理,避免潜在错误
- 改进语言代码的匹配逻辑,提高兼容性
2025-04-13 22:08:12 +08:00
c88ac3de3d feat(app): 支持 API 模式设置临时代理 2025-04-12 10:45:06 +08:00
da86da6bb4 chore: 添加 .gitignore 文件 2025-03-30 16:25:50 +08:00
99e4186ca2 docs(README): 更新贡献指南和依赖文件
适配 Textual 3.0.0 版本
2025-03-30 15:50:46 +08:00
7f07dbff3e fix(recorder.py): 修复已知问题 2025-03-23 17:15:34 +08:00
54e197e0fd docs(README): 更新配置文件参数说明 2025-03-23 16:50:09 +08:00
3b4f23c670 feat: 支持设置作者别名
1. 新增 mapping_data 配置参数
2. 新增自动更新作者昵称功能

Closes #176
Closes #194
Closes #199
Closes #229
2025-03-22 22:10:17 +08:00
f332b3fb2d refactor(app): 将 account_archive 更新为 author_archive 2025-03-21 20:54:57 +08:00
c43f3ad23e perf: 修改作者归档保存模式的文件夹名称格式 2025-03-21 20:47:13 +08:00
e1f4fdc716 perf(app): 修复监听剪贴板模式可能丢失链接的问题 2025-03-14 21:35:41 +08:00
c2fa98bb51 feat: 支持按作者归档保存作品文件
BREAKING CHANGE: 新增配置文件参数:account_archive

Closes #226
Closes #229
2025-03-12 22:35:13 +08:00
ea63059dbf perf(request.py): 优化 headers 处理逻辑
1. 修复已登录 Cookie 无法获取具体数据的问题
2. 更新项目依赖库版本

Closes #206
2025-02-28 19:20:14 +08:00
86b5de6687 ci: 优化 GitHub Actions 工作流并更新文档
- 重命名工作流:手动构建可执行文件 -> 构建可执行文件
- 添加日期变量到可执行文件名称,提高版本区分度
- 更新工作流触发条件和权限设置
- 修改 README 中关于构建和发布的说明,增加 Actions 下载链接
- 更新英文 README 中的相关信息
2025-02-27 19:00:04 +08:00
fca19144df refactor: 将端口从 8000 更改为 6666
- 修改了 app.py、Dockerfile、main.py 中的端口设置
- 更新了 README.md 和 README_EN.md 中的端口相关说明
- 调整了 API 文档的访问路径
2025-02-19 20:10:21 +08:00
14315e4657 build(requirements): 更新 httpx 依赖并修改 uv 编译命令
- 将 httpx 依赖升级到 0.28.1 版本并添加 socks 支持
- 修改 uv pip compile 命令,增加 --no-strip-extras 参数以保留额外依赖
2025-02-18 20:55:32 +08:00
71278527e1 style(XHS-Downloader): 代码格式化和依赖项更新
- 使用自动代码格式化工具对代码进行了统一格式化
- 更新了项目依赖项至最新版本
- 调整了部分代码结构以符合规范
2025-02-18 20:00:13 +08:00
7059603d46 feat(image): 增加对 JPEG 和 HEIC 图片格式的支持
- 在图片下载功能中添加了对 JPEG 和 HEIC 格式的支持
- 更新了相关模块和文档以支持新功能

Closes #229
2025-02-18 19:55:12 +08:00
1570ba320c style: 代码格式化和字符串处理优化
- 优化代码缩进和换行,提高可读性
- 统一使用单引号或双引号,保持一致性
- 移除冗余的空格和括号,精简代码
2025-02-15 21:30:24 +08:00
94198f5a51 build: 更新项目构建配置
- 添加 pyproject.toml 文件,配置项目信息和依赖
- 更新 requirements.txt,调整依赖版本
- 在 static.py 中添加版本号变量
- 添加 .python-version 文件,指定 Python 版本
2025-02-15 20:48:09 +08:00
697ff3f7a3 docs: 添加 issue 模板以提高问题处理效率
- 新增 bug 报告模板,用于清晰记录和重现问题
- 新增功能请求模板,用于收集和评估优化建议
2025-02-15 16:00:33 +08:00
cd036582c0 docs(example.py): 更新二次开发示例代码 2025-02-15 14:50:59 +08:00
459e9b54f5 perf(XHS-Downloader.js): 修正变量名未更新的问题 2025-02-14 22:06:38 +08:00
78060c55a5 perf(XHS-Downloader.js): 优化用户脚本代码
1. 更新脚本功能说明
2. 移除无效功能菜单
3. 优化功能状态显示
2025-02-14 21:53:13 +08:00
6392bf8f3a
Merge pull request #225 from BowieHe/develop
fix: 在 httpx 依赖中添加 [socks] 选项,启用 socks 支持
2025-02-07 10:51:39 +08:00
Bowie He
6e8c46a094 fix:添加httpx[socks]包来解决设置socks代理时出现的异常 2025-02-07 10:40:22 +08:00
JoeanAmier
2fc168f8fd docs(README): 更新 Docker 使用说明
- 在 TUI 和 API 模式的 Docker 命令中添加了 --name 参数,用于指定容器名称
- 在命令中添加了 -p 参数,用于映射主机端口和容器端口
2025-01-17 20:15:10 +08:00
JoeanAmier
69362e1f80 style: 修正项目英语翻译
更新项目说明
2025-01-15 21:23:46 +08:00
JoeanAmier
86439d5e8f docs(README): 添加手动构建可执行文件指南
- 在 README.md 中新增了手动构建可执行文件的详细指南
- 介绍了如何通过 Fork 仓库和 GitHub Actions 自动完成程序构建和打包
- 添加了构建流程各步骤的详细说明和注意事项
2025-01-13 20:55:02 +08:00
JoeanAmier
ad740a1466 ci: 移除 Docker 镜像发布工作流中的手动触发选项 2025-01-09 20:55:11 +08:00
JoeanAmier
9cc8ff22e3 docs(README): 更新贡献指南
- 增加了更多详细的贡献指南,包括代码风格、提交规范等内容
- 添加了贡献者公约的链接
- 调整了现有指南的措辞,使其更加清晰和友好
2025-01-09 19:05:16 +08:00
JoeanAmier
c20778c2e8 docs(README.md): 添加贡献指南 2025-01-08 23:15:09 +08:00
JoeanAmier
8f87bb4e5a ci: 更新 Docker 镜像构建和发布工作流
- 新增手动构建并发布 Docker镜像的工作流
- 修改发布 Docker 镜像的名称和标签
- 在现有工作流中添加最新标签发布
2025-01-08 22:40:10 +08:00
8f344c8438
Merge pull request #214 from Coooolfan/master
perf(XHS-Downloader.js): 使用svg代替ico
2025-01-08 21:54:11 +08:00
YangYiFan
8a5d9ae836
perf(XHS-Downloader.js): 使用svg代替ico 2025-01-05 23:05:34 +08:00
JoeanAmier
bd7af3d0d1 feat: 发布 2.4 版本 2025-01-05 11:45:15 +08:00
JoeanAmier
b3974fe8f3 feat(XHS-Downloader.js): 新增下载失败重试机制 2025-01-04 22:25:46 +08:00
JoeanAmier
ef68346f28 feat(XHS-Downloader.js): 新增文件打包下载功能开关 2025-01-04 22:00:05 +08:00
JoeanAmier
1bd7cfcf88 perf: 修复删除下载记录无效的问题
重构删除下载记录功能代码

Closes #211
2025-01-02 23:20:17 +08:00
JoeanAmier
5a334e9a34 perf(XHS-Downloader.js): 优化文件打包下载功能 2025-01-01 12:50:22 +08:00
JoeanAmier
ca7937e94e feat(XHS-Downloader.js): 新增文件打包下载功能 2024-12-31 20:30:59 +08:00
JoeanAmier
d05713878f style(XHS-Downloader.js): 修改用户脚本功能代码 2024-12-29 22:42:36 +08:00
JoeanAmier
e4554d2c57 feat(XHS-Downloader.js): 新增文件名称长度限制 2024-12-29 22:25:47 +08:00
JoeanAmier
7eb270b53e style: 更新用户脚本代码 2024-12-29 16:20:36 +08:00
JoeanAmier
2d8d6781e6 perf(translate.py): 更新项目翻译模块 2024-12-29 11:41:38 +08:00
JoeanAmier
63c8a9e325 feat: 优化程序交互提示 2024-12-29 11:00:04 +08:00
JoeanAmier
1d2731b93a fix: 修复特定情况下报错的问题 2024-12-29 10:34:08 +08:00
JoeanAmier
102e7adbd4 perf: 更新程序界面代码
更新英语翻译
2024-12-28 22:58:11 +08:00
JoeanAmier
13707c425a perf: 更新程序交互界面
1. 更新英语翻译
2. 更新界面文本
3. 更新界面主题
2024-12-28 17:55:16 +08:00
JoeanAmier
8f820330dc perf(XHS-Downloader.js): 优化文件下载功能 2024-12-28 12:15:17 +08:00
JoeanAmier
fc58bc84f3 refactor(XHS-Downloader.js): 重构用户脚本自动滚动页面功能 2024-12-28 10:10:29 +08:00
JoeanAmier
14d8ee3abe style(static.py): 更新默认 UA 和请求头 2024-12-26 19:30:16 +08:00
JoeanAmier
10a09b4c0b fix: 修复代码逻辑错误
修正英语项目说明

BREAKING CHANGE: 恢复内置延时机制
2024-12-22 16:10:11 +08:00
JoeanAmier
f5e9bc306d perf: 更新项目英语翻译 2024-12-22 14:55:15 +08:00
JoeanAmier
80a3997ee7 refactor: 重构项目翻译模块 2024-12-22 14:05:53 +08:00
JoeanAmier
cdd574a00b docs(README.md): 更新项目说明 2024-12-15 11:40:06 +08:00
JoeanAmier
ad73544e7e style: 更新项目翻译文件 2024-12-15 11:15:02 +08:00
JoeanAmier
60d32d1327 feat: 支持 API 模式传入 Cookie 2024-12-14 14:25:33 +08:00
JoeanAmier
b360eae802 docs: 更正英语语言代码 2024-12-14 13:35:04 +08:00
JoeanAmier
0cd01018a4 style(download.py): 修正代码格式 2024-12-06 23:25:06 +08:00
JoeanAmier
4a8b0e57d4 perf(download.py): 优化文件下载功能 2024-12-04 19:50:15 +08:00
JoeanAmier
561984356f perf: 适配新版本 HTTPX 库 2024-12-02 22:50:15 +08:00
JoeanAmier
3e85760b05 docs(README.md): 更新项目说明 2024-11-21 19:40:12 +08:00
JoeanAmier
81b88711d8 perf(cleaner.py): 优化文件名称非法字符处理
BREAKING CHANGE: 移除内置延时机制
2024-11-11 19:05:00 +08:00
JoeanAmier
2c9ca72f4d chore: 优化可执行文件构建流程 2024-11-10 15:45:47 +08:00
JoeanAmier
5463854906 feat: 发布 2.3 版本 2024-11-10 11:00:31 +08:00
JoeanAmier
de28b9de69 chore: 更新 Dockerfile 文件 2024-11-08 20:32:02 +08:00
JoeanAmier
7e0b0aca30 perf: 优化清理空文件夹功能 2024-11-02 21:42:29 +08:00
JoeanAmier
856b4ece98 build: 更新依赖版本要求 2024-10-31 19:50:41 +08:00
JoeanAmier
bc436682fb perf(download.py): 修复下载文件频繁提示失败的问题
Closes #170
Closes #182
Closes #185
2024-10-20 21:35:12 +08:00
JoeanAmier
8979ba8e25 perf(XHS-Downloader.js): 更新作品链接提取功能 2024-10-20 21:15:29 +08:00
JoeanAmier
58b2067c68 perf(download.py): 优化已下载文件判断逻辑
1. 优化图片文件后缀名
2. 修改文件下载并发数
3. 优化项目代码格式
4. 更新项目使用说明
2024-10-13 11:05:47 +08:00
JoeanAmier
04557b074f perf(XHS-Downloader.js): 禁用自动滚动屏幕功能
BREAKING CHANGE: 使用自动化方案滚动屏幕可能会被检测并风控,故暂时禁用自动滚动屏幕功能
2024-09-25 18:30:18 +08:00
JoeanAmier
80c3e71649 style: 优化代码导入方式
BREAKING CHANGE: 更新用户脚本说明
2024-09-24 20:50:22 +08:00
JoeanAmier
1698e1c792 fix(XHS-Downloader.js): 重构作品链接提取功能
Closes #179
2024-09-24 20:10:28 +08:00
JoeanAmier
2042afcd1e fix(app.py): 修复文件名称过长报错的问题
BREAKING CHANGE: 新增文件名称长度限制

Closes #177
2024-09-14 22:53:20 +08:00
JoeanAmier
99490d32f4 docs(README.md): 更新项目说明 2024-09-08 22:15:13 +08:00
JoeanAmier
ab405f605c refactor(browser.py): 优化从浏览器读取 Cookie 功能 2024-09-08 21:15:50 +08:00
JoeanAmier
10164ba7b6 perf(static.py): 更新文件签名数据 2024-09-08 17:55:52 +08:00
YangYiFan
8bfec97d56
perf(static.py): 补充文件标识头 2024-09-08 14:44:12 +08:00
JoeanAmier
76c4699e05 perf(manager.py): 优化代理测试逻辑 2024-09-08 13:10:16 +08:00
JoeanAmier
5b85379d49 perf(download.py): 优化代码逻辑
1. 更新英语翻译
2. 修复代码逻辑错误
3. 优化代码变量名
4. 优化代码格式
2024-09-08 12:25:15 +08:00
JoeanAmier
2359cf93a4 perf(XHS-Downloader.js): 优化作品链接提取功能 2024-09-08 11:27:38 +08:00
JoeanAmier
14bf951ca6 perf: 优化文件后缀处理逻辑 2024-09-08 11:18:49 +08:00
YangYiFan
911293b99d
fix(download.py): 修复文件后缀不正确的问题 2024-09-07 22:04:39 +08:00
JoeanAmier
0a52dc0ed2 feat: 发布 2.2 版本
1. 移除 sec_ch_ua_platform 参数
2. 移除 sec_ch_ua 参数
3. 优化请求延时间隔
4. 优化并发下载功能
5. 修正英语翻译错误
6. 新增并发下载限制
7. 修正命令行模式错误
8. 简化数据请求头

Closes #86
Closes #87
Closes #93
Closes #98
Closes #105
Closes #109
Closes #110
Closes #140
Closes #152
Closes #154
Closes #157
Closes #159
Closes #160
Closes #162
Closes #164
Closes #165
2024-08-30 13:05:25 +08:00
JoeanAmier
44d5c61856 docs: 更新项目说明 2024-08-25 20:05:15 +08:00
JoeanAmier
bc81d9700c chore: 优化可执行程序构建流程 2024-08-24 22:00:06 +08:00
JoeanAmier
15e412e6ae feat(download.py): 新增文件下载延时处理 2024-08-21 20:00:20 +08:00
JoeanAmier
24c7a1eb3e refactor(download.py): 移除文件并发下载功能 2024-08-21 19:40:16 +08:00
JoeanAmier
5a0d3b3f4d chore: 更新可执行文件构建流程 2024-08-18 16:35:11 +08:00
JoeanAmier
06161391f1 perf: 优化异常信息提示 2024-08-18 14:25:08 +08:00
JoeanAmier
76e40b6ddf perf(download.py): 优化文件下载异常提示
1. 优化错误信息提示
2. 更新翻译内容
2024-08-18 14:10:55 +08:00
JoeanAmier
77b1d05ad8 feat(XHS-Downloader.js): 新增专辑作品链接提取功能
1. 优化 Tampermonkey 用户脚本代码
2. 支持提取发现作品链接自动滚动屏幕
3. 更新依赖库版本
4. 更新项目参考
2024-08-17 12:00:03 +08:00
JoeanAmier
a4d1a40d11 docs: 更新 README 说明 2024-08-09 19:40:13 +08:00
JoeanAmier
0915574bc6 fix(download.py): 修复文件下载失败的问题 2024-08-09 19:10:13 +08:00
JoeanAmier
e2eee03feb fix: 修复非法文件名称报错的问题
1. 替换文件名称包含的非法字符
2. 替换文件名称包含的 Emoji 表情
2024-08-09 18:50:10 +08:00
JoeanAmier
ce01a7b2d7 chore: 优化可执行文件构建流程 2024-08-08 19:00:09 +08:00
JoeanAmier
169128de8d docs: 更正 README 内容 2024-08-07 22:45:50 +08:00
JoeanAmier
7cedd8d4b8 feat: 新增文件断点续传功能
1. 新增自动删除空文件夹功能
2. 引入 aiofiles 库
3. 修正 Actions 错误

Closes #142
Closes #143
2024-08-07 22:10:15 +08:00
JoeanAmier
24dc8a1a53 chore: 使用 Actions 构建可执行文件 2024-08-07 21:17:58 +08:00
JoeanAmier
4d531e85d9 chore: 使用 Actions 构建和发布 Docker 镜像 2024-08-07 20:37:07 +08:00
herniy
e6ac8647a2 chore: 使用 Actions 构建和发布 Docker 镜像 2024-08-07 20:35:07 +08:00
JoeanAmier
d1bca5a896 perf: 优化重定向链接获取逻辑
1. 更新 chunk 参数默认值
2. 更新配置文件参数说明

Closes #138
Closes #139
2024-08-04 15:35:23 +08:00
JoeanAmier
678afea954 perf: 默认开启局域网访问
1. 更正 README 使用方法内容
2. 更正 Dockerfile 版本号

Closes #134
Closes #135
Closes #137
2024-08-03 21:15:19 +08:00
JoeanAmier
3e8b69f8e1 fix: 修复项目功能异常
1. 更新 Cookie 参数处理
2. 优化作品数据返回格式
3. 更新用户脚本链接提取功能
4. 优化项目运行信息提示
5. 修复 record_data 参数无效的问题
6. 新增作品下载记录开关
7. 适配小红书平台规则
8. 默认开启局域网访问
9. 格式化项目代码
10. 更新英语翻译

Closes #127
Closes #128
Closes #130
Closes #132
2024-08-03 14:30:35 +08:00
JoeanAmier
dd5c09389a perf: 更新 Cookie 参数处理 2024-07-29 19:00:15 +08:00
JoeanAmier
01111cc401 fix: 修复项目功能异常
1. 修复 ScannerError 错误
2. 优化作品数据提取逻辑
3. 移除 Cookie 参数

Closes #124
Closes #126
2024-07-28 22:21:03 +08:00
JoeanAmier
3e67dfb634 使用 rookiepy 替代 browser-cookie3 2024-07-27 19:30:08 +08:00
JoeanAmier
5e33081e76 更新 Tampermonkey 用户脚本 2024-07-16 20:45:09 +08:00
JoeanAmier
2313cf1682 修复用户脚本功能异常的问题 2024-07-13 17:46:50 +08:00
JoeanAmier
3d28a6f262 发布 2.1 版本 2024-07-03 22:40:31 +08:00
JoeanAmier
b87132e364 更新项目依赖库版本 2024-06-29 23:20:08 +08:00
JoeanAmier
e7c4d6daee 使用 HTTPX 替代 AIOHTTP 2024-06-27 22:55:37 +08:00
JoeanAmier
01711be950 发布 2.0 版本 2024-06-19 20:20:07 +08:00
JoeanAmier
54b7cf86a5 新增 livePhoto 文件下载功能 2024-06-08 15:15:07 +08:00
JoeanAmier
bd0780c344 新增 Web API 模式 2024-06-05 21:30:10 +08:00
JoeanAmier
e26d4875e3 新增自定义作品文件名称格式功能 2024-04-27 23:00:51 +08:00
JoeanAmier
ea349048c3 新增视频/图文作品文件下载开关 2024-04-14 11:00:12 +08:00
JoeanAmier
3b2f1bda9e 修复已知问题 2024-04-02 21:55:41 +08:00
96 changed files with 13683 additions and 2014 deletions

41
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,41 @@
---
name: Bug report
about: 报告项目问题
title: '[功能异常] '
labels: ''
assignees: JoeanAmier
---
**问题描述**
清晰简洁地描述该错误是什么。
A clear and concise description of what the bug is.
**重现步骤**
重现该问题的步骤:
Steps to reproduce the behavior:
1. ...
2. ...
3. ...
**预期结果**
清晰简洁地描述您预期会发生的情况。
A clear and concise description of what you expected to happen.
**补充信息**
在此添加有关该问题的任何其他上下文信息,例如:操作系统、运行方式、配置文件、错误截图、运行日志等。
请注意:提供配置文件时,请删除 Cookie 内容,避免敏感数据泄露!
Add any other contextual information about the issue here, such as operating system, runtime mode, configuration files,
error screenshots, runtime logs, etc.
Please note: When providing configuration files, please delete cookie content to avoid sensitive data leakage!

View File

@ -0,0 +1,32 @@
---
name: Feature request
about: 功能优化建议
title: '[优化建议] '
labels: ''
assignees: JoeanAmier
---
**功能请求**
清晰简洁地描述问题是什么。例如:当 [...] 时,我总是感到沮丧。
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**描述您希望的解决方案**
清晰简洁地描述您希望发生的情况。
A clear and concise description of what you want to happen.
**描述您考虑过的替代方案**
清晰简洁地描述您考虑过的任何替代解决方案或功能。
A clear and concise description of any alternative solutions or features you've considered.
**补充信息**
在此添加有关功能请求的任何其他上下文或截图。
Add any other context or screenshots about the feature request here.

View File

@ -0,0 +1,40 @@
name: "自动管理过时的问题和PR"
on:
schedule:
- cron: "0 0 */4 * *"
workflow_dispatch:
permissions:
issues: write
pull-requests: write
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
with:
stale-issue-message: |
⚠️ 此 Issue 已超过一定时间未活动,如果没有进一步更新,将在 14 天后关闭。
⚠️ This issue has been inactive for a certain period of time. If there are no further updates, it will be closed in 14 days.
close-issue-message: |
🔒 由于长时间未响应,此 Issue 已被自动关闭。如有需要,请重新打开或提交新 issue。
🔒 Due to prolonged inactivity, this issue has been automatically closed. If needed, please reopen it or submit a new issue.
stale-pr-message: |
⚠️ 此 PR 已超过一定时间未更新,请更新,否则将在 14 天后关闭。
⚠️ This PR has not been updated for a certain period of time. Please update it, otherwise it will be closed in 14 days.
close-pr-message: |
🔒 此 PR 已因无更新而自动关闭。如仍需合并,请重新打开或提交新 PR。
🔒 This PR has been automatically closed due to inactivity. If you still wish to merge it, please reopen it or submit a new PR.
days-before-stale: 28
days-before-close: 14
ascending: true
stale-issue-label: "未跟进问题(Stale)"
close-issue-label: "自动关闭(Close)"
stale-pr-label: "未跟进问题(Stale)"
close-pr-label: "自动关闭(Close)"
exempt-issue-labels: "功能异常(bug),文档补充(docs),功能优化(enhancement),适合新手(good first issue),"
exempt-pr-labels: "功能异常(bug),文档补充(docs),功能优化(enhancement),适合新手(good first issue),"

View File

@ -0,0 +1,21 @@
name: 删除 GHCR Untagged 镜像
on:
schedule:
- cron: "0 0 15 * *"
release:
types: [ published ]
workflow_dispatch:
jobs:
delete-untagged:
runs-on: ubuntu-latest
steps:
- name: Delete all containers from package without tags
uses: Chizkiyahu/delete-untagged-ghcr-action@v6
with:
token: ${{ secrets.PAT_TOKEN }}
repository_owner: ${{ github.repository_owner }}
repository: ${{ github.repository }}
package_name: "xhs-downloader"
untagged_only: true
owner_type: user

View File

@ -0,0 +1,46 @@
name: 构建可执行文件
on:
workflow_dispatch:
jobs:
build:
name: 构建于 ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ windows-latest, windows-11-arm, macos-15-intel, macos-latest ]
steps:
- name: 签出存储库
uses: actions/checkout@v4
- name: 设置 Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: 安装依赖项
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: 构建 Win 可执行文件
if: runner.os == 'Windows'
run: |
echo "DATE=$(Get-Date -Format 'yyyyMMdd')" >> $env:GITHUB_ENV
pyinstaller --icon=./static/XHS-Downloader.ico --add-data "static:static" --add-data "locale:locale" --copy-metadata fastmcp --runtime-hook ./source/expansion/pyi_rth_beartype.py main.py
shell: pwsh
- name: 构建 Mac 可执行文件
if: runner.os == 'macOS'
run: |
echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
pyinstaller --icon=./static/XHS-Downloader.icns --add-data "static:static" --add-data "locale:locale" --copy-metadata fastmcp --runtime-hook ./source/expansion/pyi_rth_beartype.py main.py
- name: 上传文件
uses: actions/upload-artifact@v4
with:
name: XHS-Downloader_${{ runner.os }}_${{ runner.arch }}_${{ env.DATE }}
path: dist/main/

View File

@ -0,0 +1,93 @@
name: 构建并发布 Docker 镜像
on:
workflow_dispatch:
inputs:
is_beta:
type: boolean
required: true
description: "开发版"
default: true
custom_version:
type: string
required: false
description: "版本号"
default: ""
permissions:
contents: read
packages: write
attestations: write
id-token: write
env:
REGISTRY: ghcr.io
DOCKER_REPO: ${{ secrets.DOCKERHUB_USERNAME }}/xhs-downloader
GHCR_REPO: ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/xhs-downloader
jobs:
publish-docker:
runs-on: ubuntu-latest
steps:
- name: 拉取源码
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: 获取最新的发布标签
id: get-latest-release
run: |
if [ -z "${{ github.event.inputs.custom_version }}" ]; then
LATEST_TAG=$(curl -s \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/releases/latest \
| jq -r '.tag_name')
else
LATEST_TAG=${{ github.event.inputs.custom_version }}
fi
if [ -z "$LATEST_TAG" ]; then
exit 1
fi
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
- name: 设置 QEMU
uses: docker/setup-qemu-action@v3
- name: 设置 Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 生成标签
id: generate-tags
run: |
if [ "${{ inputs.is_beta }}" == "true" ]; then
LATEST_TAG="${LATEST_TAG%.*}.$(( ${LATEST_TAG##*.} + 1 ))"
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
TAGS="${{ env.DOCKER_REPO }}:${LATEST_TAG}-dev,${{ env.GHCR_REPO }}:${LATEST_TAG}-dev"
else
TAGS="${{ env.DOCKER_REPO }}:${LATEST_TAG},${{ env.DOCKER_REPO }}:latest,${{ env.GHCR_REPO }}:${LATEST_TAG},${{ env.GHCR_REPO }}:latest"
fi
echo "TAGS=$TAGS" >> $GITHUB_ENV
- name: 登录到 Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: 登录到 GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 构建和推送 Docker 镜像到 Docker Hub 和 GHCR
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ env.TAGS }}
provenance: false
sbom: false

View File

@ -0,0 +1,58 @@
name: 自动构建并发布可执行文件
on:
release:
types: [ published ]
permissions:
contents: write
discussions: write
jobs:
build:
name: 构建于 ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ windows-latest, windows-11-arm, macos-15-intel, macos-latest ]
steps:
- name: 签出存储库
uses: actions/checkout@v4
- name: 设置 Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: 安装依赖项
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: 构建 Win 可执行文件
if: runner.os == 'Windows'
run: |
pyinstaller --icon=./static/XHS-Downloader.ico --add-data "static:static" --add-data "locale:locale" --copy-metadata fastmcp --runtime-hook ./source/expansion/pyi_rth_beartype.py main.py
shell: pwsh
- name: 构建 Mac 可执行文件
if: runner.os == 'macOS'
run: |
pyinstaller --icon=./static/XHS-Downloader.icns --add-data "static:static" --add-data "locale:locale" --copy-metadata fastmcp --runtime-hook ./source/expansion/pyi_rth_beartype.py main.py
- name: 创建压缩包
run: |
7z a "XHS-Downloader_V${{ github.event.release.tag_name }}_${{ runner.os }}_${{ runner.arch }}.zip" ./dist/main/*
shell: bash
- name: 上传文件到 release
uses: softprops/action-gh-release@v2
with:
files: |
./XHS-Downloader_V*.zip
name: XHS-Downloader V${{ github.event.release.tag_name }}
body_path: ./static/Release_Notes.md
draft: ${{ github.event.release.draft }}
prerelease: ${{ github.event.release.prerelease }}

View File

@ -0,0 +1,59 @@
name: 自动构建并发布 Docker 镜像
on:
release:
types: [published]
permissions:
contents: read
packages: write
attestations: write
id-token: write
env:
REGISTRY: ghcr.io
DOCKER_REPO: ${{ secrets.DOCKERHUB_USERNAME }}/xhs-downloader
GHCR_REPO: ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/xhs-downloader
jobs:
publish-docker:
runs-on: ubuntu-latest
steps:
- name: 拉取源码
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: 设置 QEMU
uses: docker/setup-qemu-action@v3
- name: 设置 Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 登录到 Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: 登录到 GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 构建和推送 Docker 镜像到 Docker Hub 和 GHCR
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: |
${{ env.DOCKER_REPO }}:${{ github.event.release.tag_name }}
${{ env.DOCKER_REPO }}:latest
${{ env.GHCR_REPO }}:${{ github.event.release.tag_name }}
${{ env.GHCR_REPO }}:latest
provenance: false
sbom: false

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
__pycache__/
*.pyc
/.venv/
/.ruff_cache/
/.idea/
/.run/
/Volume/
!/.github/

1
.python-version Normal file
View File

@ -0,0 +1 @@
3.12

47
Dockerfile Normal file
View File

@ -0,0 +1,47 @@
# ---- 阶段 1: 构建器 (Builder) ----
# 使用一个功能完整的镜像,它包含编译工具或可以轻松安装它们
FROM python:3.12-bullseye as builder
# 安装编译 uvloop 和 httptools 所需的系统依赖 (C编译器等)
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# 设置工作目录
WORKDIR /app
# 复制需求文件
COPY requirements.txt .
# 在这个具备编译环境的阶段安装所有 Python 依赖
# 安装到一个独立的目录 /install 中,以便后续复制
RUN pip install --no-cache-dir --prefix="/install" -r requirements.txt
# ---- 阶段 2: 最终镜像 (Final Image) ----
# 使用轻量级 slim 镜像作为最终的运行环境
FROM python:3.12-slim
# 设置工作目录
WORKDIR /app
# 添加元数据标签
LABEL name="XHS-Downloader" authors="JoeanAmier" repository="https://github.com/JoeanAmier/XHS-Downloader"
# 从构建器阶段,将已经安装好的依赖包复制到最终镜像的系统路径中
COPY --from=builder /install /usr/local
# 复制项目代码和相关文件
COPY locale /app/locale
COPY source /app/source
COPY static/XHS-Downloader.tcss /app/static/XHS-Downloader.tcss
COPY LICENSE /app/LICENSE
COPY main.py /app/main.py
# 暴露端口
EXPOSE 5556
# 创建挂载点
VOLUME /app/Volume
# 设置容器启动命令
CMD ["python", "main.py"]

636
README.md
View File

@ -1,23 +1,32 @@
<div align="center"> <div align="center">
<img src="static/XHS-Downloader.png" alt="" height="256" width="256"><br> <img src="static/XHS-Downloader.png" alt="XHS-Downloader" height="256" width="256"><br>
<h1>XHS-Downloader</h1> <h1>XHS-Downloader</h1>
<p>简体中文 | <a href="README_EN.md">English</a></p> <p>简体中文 | <a href="README_EN.md">English</a></p>
<img alt="GitHub" src="https://img.shields.io/github/license/JoeanAmier/XHS-Downloader?style=for-the-badge&color=ff7a45"> <a href="https://trendshift.io/repositories/5435" target="_blank"><img src="https://trendshift.io/api/badge/repositories/5435" alt="JoeanAmier%2FXHS-Downloader | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
<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> <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" src="https://img.shields.io/github/license/JoeanAmier/XHS-Downloader?style=flat-square">
<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 forks" src="https://img.shields.io/github/forks/JoeanAmier/XHS-Downloader?style=flat-square&color=55efc4">
<img alt="GitHub all releases" src="https://img.shields.io/github/downloads/JoeanAmier/XHS-Downloader/total?style=for-the-badge&color=f759ab"> <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/JoeanAmier/XHS-Downloader?style=flat-square&color=fda7df">
<img alt="GitHub code size in bytes" src="https://img.shields.io/github/languages/code-size/JoeanAmier/XHS-Downloader?style=flat-square&color=a29bfe">
<img alt="GitHub release (with filter)" src="https://img.shields.io/github/v/release/JoeanAmier/XHS-Downloader?style=flat-square&color=48dbfb">
<br>
<img alt="Static Badge" src="https://img.shields.io/badge/Python-3.12-b8e994?style=flat-square&logo=python&labelColor=3dc1d3">
<img alt="Static Badge" src="https://img.shields.io/badge/UserScript-ffec3d?style=flat-square&logo=tampermonkey&logoColor=%2300485B">
<img src="https://img.shields.io/badge/Sourcery-enabled-884898?style=flat-square&color=1890ff" alt="">
<img alt="Static Badge" src="https://img.shields.io/badge/Docker-badc58?style=flat-square&logo=docker">
<img alt="GitHub all releases" src="https://img.shields.io/github/downloads/JoeanAmier/XHS-Downloader/total?style=flat-square&color=ffdd59">
</div> </div>
<br> <br>
<p>🔥 <b>小红书链接提取/作品采集工具</b>:提取账号发布、收藏、点赞作品链接;提取搜索结果作品、用户链接;采集小红书作品信息;提取小红书作品下载地址;下载小红书无水印作品文件!</p> <p>🔥 <b>小红书链接提取/作品采集工具</b>:提取账号发布、收藏、点赞、专辑作品链接;提取搜索结果作品链接、用户链接;采集小红书作品信息;提取小红书作品下载地址;下载小红书无水印作品文件!</p>
<p>🔥 “小红书”、“XiaoHongShu”、“RedNote” 含义相同,本项目统称为 “小红书”</p>
<h1>📑 项目功能</h1> <h1>📑 项目功能</h1>
<details>
<summary>项目程序与用户脚本功能清单(点击展开)</summary>
<ul><b>程序功能</b> <ul><b>程序功能</b>
<li>✅ 采集小红书作品信息</li> <li>✅ 采集小红书作品信息</li>
<li>✅ 提取小红书作品下载地址</li> <li>✅ 提取小红书作品下载地址</li>
<li>✅ 下载小红书无水印作品文件</li> <li>✅ 下载小红书无水印作品文件</li>
<li>✅ 下载小红书 livePhoto 文件(含水印)</li>
<li>✅ 自动跳过已下载的作品文件</li> <li>✅ 自动跳过已下载的作品文件</li>
<li>✅ 作品文件完整性处理机制</li> <li>✅ 作品文件完整性处理机制</li>
<li>✅ 自定义图文作品文件下载格式</li> <li>✅ 自定义图文作品文件下载格式</li>
@ -26,108 +35,117 @@
<li>✅ 后台监听剪贴板下载作品</li> <li>✅ 后台监听剪贴板下载作品</li>
<li>✅ 记录已下载作品 ID</li> <li>✅ 记录已下载作品 ID</li>
<li>✅ 支持命令行下载作品文件</li> <li>✅ 支持命令行下载作品文件</li>
<li>✅ 从浏览器读取 Cookie</li> <li>✅ 从浏览器读取 Cookie</li>
<li>☑️ 支持 API 调用功能</li> <li>✅ 自定义文件名称格式</li>
<li>✅ 支持 API 调用功能</li>
<li>✅ 支持 MCP 调用功能</li>
<li>✅ 支持文件断点续传下载</li>
<li>✅ 智能识别作品文件类型</li>
<li>✅ 支持设置作者备注</li>
<li>✅ 自动更新作者昵称</li>
</ul> </ul>
<ul><b>脚本功能</b> <ul><a href="#user-scripts"><b>脚本功能</b></a>
<li>✅ 下载小红书无水印作品文件</li> <li>✅ 下载小红书无水印作品文件</li>
<li>✅ 提取发现页面作品链接</li> <li>✅ 提取推荐页面作品链接</li>
<li>✅ 提取账号发布作品链接</li> <li>✅ 提取账号发布作品链接</li>
<li>✅ 提取账号收藏作品链接</li> <li>✅ 提取账号收藏作品链接</li>
<li>✅ 提取账号点赞作品链接</li> <li>✅ 提取账号点赞作品链接</li>
<li>✅ 提取账号专辑作品链接</li>
<li>✅ 提取搜索结果作品链接</li> <li>✅ 提取搜索结果作品链接</li>
<li>✅ 提取搜索结果用户链接</li> <li>✅ 提取搜索结果用户链接</li>
</ul> </ul>
</details>
<h1>📸 程序截图</h1> <h1>📸 程序截图</h1>
<p><b>🎥 点击图片观看演示视频</b></p> <p><a href="https://www.bilibili.com/video/BV1Fcb3zWEjt/">前往 bilibili 观看演示</a><a href="https://youtu.be/VIjDytHaopg">前往 YouTube 观看演示</a></p>
<a href="https://www.bilibili.com/video/BV1PJ4m1Y7Jt/"><img src="static/screenshot/程序运行截图CN1.png" alt=""></a> <img src="static/screenshot/程序运行截图CN1.png" alt="">
<hr> <hr>
<a href="https://www.bilibili.com/video/BV1PJ4m1Y7Jt/"><img src="static/screenshot/程序运行截图CN2.png" alt=""></a> <img src="static/screenshot/程序运行截图CN2.png" alt="">
<hr> <hr>
<a href="https://www.bilibili.com/video/BV1PJ4m1Y7Jt/"><img src="static/screenshot/程序运行截图CN3.png" alt=""></a> <img src="static/screenshot/程序运行截图CN3.png" alt="">
<h1>🔗 支持链接</h1> <h1>🔗 支持链接</h1>
<ul> <ul>
<li><code>https://www.xiaohongshu.com/explore/作品ID</code></li> <li><code>https://www.xiaohongshu.com/explore/作品ID?xsec_token=XXX</code></li>
<li><code>https://www.xiaohongshu.com/discovery/item/作品ID</code></li> <li><code>https://www.xiaohongshu.com/discovery/item/作品ID?xsec_token=XXX</code></li>
<li><code>https://www.xiaohongshu.com/user/profile/作者ID/作品ID?xsec_token=XXX</code></li>
<li><code>https://xhslink.com/分享码</code></li> <li><code>https://xhslink.com/分享码</code></li>
<br/> <br/>
<p><b>支持单次输入多个作品链接,链接之间使用空格分隔</b></p> <p><b>支持单次输入多个作品链接,链接之间使用空格分隔;程序会自动提取有效链接,无需额外处理!</b></p>
</ul> </ul>
<h1>🪟 关于终端</h1> <h1>🪟 关于终端</h1>
<p>⭐ 推荐使用 <a href="https://learn.microsoft.com/zh-cn/windows/terminal/install">Windows 终端</a> Windows 11 默认终端)运行程序以便获得最佳显示效果!</p> <p>⭐ 推荐使用 <a href="https://learn.microsoft.com/zh-cn/windows/terminal/install">Windows 终端</a> Windows 11 默认终端)运行程序以便获得最佳显示效果!</p>
<h1>🥣 使用方法</h1> <h1>🥣 使用方法</h1>
<p>如果仅需下载无水印作品文件,建议选择 <b>程序运行</b>;如果有其他需求,建议选择 <b>源码运行</b></p> <p>如果仅需下载无水印作品文件,建议选择 <b>程序运行</b><b>Docker 运行</b>;如果有其他需求,建议选择 <b>源码运行</b></p>
<p>建议自行设置 <code>cookie</code> 参数,若不设置该参数,程序功能可能无法正常使用</p> <p><code>2.2</code> 版本开始,项目功能无异常的情况下,无需额外处理 Cookie</p>
<h2>🖱 程序运行</h2> <h2>🖱 程序运行</h2>
<p>Windows 10 及以上用户可前往 <a href="https://github.com/JoeanAmier/XHS-Downloader/releases/latest">Releases</a> 下载程序压缩包或安装包,解压或安装后打开程序文件夹,双击运行 <code>main.exe</code> 即可使用。</p> <p>⭐ Mac OS、Windows 10 及以上用户可前往 <a href="https://github.com/JoeanAmier/XHS-Downloader/releases/latest">Releases</a> 或者 <a href="https://github.com/JoeanAmier/XHS-Downloader/actions">Actions</a> 下载程序压缩包,解压后打开程序文件夹,双击运行 <code>main</code> 即可使用。</p>
<p>若通过此方式使用程序,文件默认下载路径为:<code>.\_internal\Download</code>;配置文件路径为:<code>.\_internal\settings.json</code></p> <p>⭐ 本项目包含自动构建可执行文件的 GitHub Actions使用者可以随时使用 GitHub Actions 将最新源码构建为可执行文件!</p>
<p>⭐ 自动构建可执行文件教程请查阅本文档的 <code>构建可执行文件指南</code> 部分;如果需要更加详细的图文教程,请 <a href="https://mp.weixin.qq.com/s/TorfoZKkf4-x8IBNLImNuw">查阅文章</a></p>
<p><strong>注意:由于 Mac OS 平台的可执行文件 <code>main</code> 未经过代码签名,首次运行时会受到系统安全限制。请先在终端执行 <code>xattr -cr 项目文件夹路径</code> 命令移除安全标记,执行一次后即可正常运行。</strong></p>
<p>若通过此方式使用程序,文件默认下载路径为:<code>.\_internal\Volume\Download</code>;配置文件路径为:<code>.\_internal\Volume\settings.json</code></p>
<h3>程序更新</h3>
<p><strong>方案一:</strong>下载并解压文件,将旧版本的 <code>_internal\Volume</code> 文件夹复制到新版本的 <code>_internal</code> 文件夹。</p>
<p><strong>方案二:</strong>下载并解压文件(不要运行程序),复制全部文件,直接覆盖旧版本文件。</p>
<h2>⌨️ 源码运行</h2> <h2>⌨️ 源码运行</h2>
<ol> <ol>
<li>安装版本号不低于 <code>3.12</code> 的 Python 解释器</li> <li>安装 <code>3.12</code> 版本的 <a href="https://www.python.org/">Python</a> 解释器</li>
<li>下载最新的源码或 <a href="https://github.com/JoeanAmier/XHS-Downloader/releases/latest">Releases</a> 发布的源码至本地</li>
<ol><b>使用 pip 安装项目依赖</b>
<li>运行 <code>python -m venv venv</code> 命令创建虚拟环境(可选)</li>
<li>运行 <code>.\venv\Scripts\activate.ps1</code> 或者 <code>venv\Scripts\activate</code> 命令激活虚拟环境(可选)</li>
<li>运行 <code>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt</code> 命令安装程序所需模块</li> <li>运行 <code>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt</code> 命令安装程序所需模块</li>
<li>下载本项目最新的源码或 <a href="https://github.com/JoeanAmier/XHS-Downloader/releases/latest">Releases</a> 发布的源码至本地</li> <li>运行 <code>python .\main.py</code> 或者 <code>python main.py</code> 命令启动 XHS-Downloader</li>
<li>运行 <code>main.py</code> 即可使用</li>
</ol> </ol>
<ol><b>使用 uv 安装项目依赖(推荐)</b>
<li>运行 <code>uv venv</code> 命令创建虚拟环境</li>
<li>运行 <code>uv sync</code> 命令同步环境依赖</li>
<li>运行 <code>uv run main.py</code> 命令启动 XHS-Downloader</li>
</ol>
</ol>
<h2>⌨️ Docker 运行</h2>
<ol>
<li>获取镜像</li>
<ul>
<li>方式一:使用 <code>Dockerfile</code> 文件构建镜像</li>
<li>方式二:使用 <code>docker pull joeanamier/xhs-downloader</code> 命令拉取镜像</li>
<li>方式三:使用 <code>docker pull ghcr.io/joeanamier/xhs-downloader</code> 命令拉取镜像</li>
</ul>
<li>创建容器</li>
<ul>
<li>TUI 模式:<code>docker run --name 容器名称(可选) -p 主机端口号:5556 -v xhs_downloader_volume:/app/Volume -it &lt;镜像名称&gt;</code></li>
<li>API 模式:<code>docker run --name 容器名称(可选) -p 主机端口号:5556 -v xhs_downloader_volume:/app/Volume -it &lt;镜像名称&gt; python main.py api</code></li>
<li>MCP 模式:<code>docker run --name 容器名称(可选) -p 主机端口号:5556 -v xhs_downloader_volume:/app/Volume -it &lt;镜像名称&gt; python main.py mcp</code></li>
<br><b>注意:</b>此处的 <code>&lt;镜像名称&gt;</code> 需与您在第一步中使用的镜像名称保持一致(<code>joeanamier/xhs-downloader</code><code>ghcr.io/joeanamier/xhs-downloader</code>
</ul>
<li>运行容器
<ul>
<li>启动容器:<code>docker start -i 容器名称/容器 ID</code></li>
<li>重启容器:<code>docker restart -i 容器名称/容器 ID</code></li>
</ul>
</li>
</ol>
<p>Docker 运行项目时不支持 <b>命令行调用模式</b>,无法使用 <b>读取剪贴板</b><b>监听剪贴板</b> 功能,可以正常粘贴内容,其他功能如有异常请反馈!</p>
<h1>🛠 命令行模式</h1> <h1>🛠 命令行模式</h1>
<p>项目支持命令行运行模式,若想要下载图文作品的部分图片,可以使用此模式传入需要下载的图片序号!</p> <p>项目支持命令行运行模式,若想要下载图文作品的部分图片,可以使用此模式设置需要下载的图片序号!</p>
<p>可以使用命令行从浏览器读取 Cookie 并写入配置文件!注意需要关闭对应浏览器才能读取数据!</p> <p><strong>注意:</strong>未设置 <code>--index</code> 参数时,支持传入多个作品链接,全部链接需要使用引号包围,链接之间使用空格分隔;已设置 <code>--index</code> 参数时,不支持传入多个作品链接,即使传入多个作品链接,程序仅处理首个作品链接</p>
<p><code>bool</code> 类型参数支持使用 <code>true</code><code>false</code><code>1</code><code>0</code><code>yes</code><code>no</code><code>on</code><code>off</code>(不区分大小写)来设置。</p> <p><code>bool</code> 类型参数支持使用 <code>true</code><code>false</code><code>1</code><code>0</code><code>yes</code><code>no</code><code>on</code><code>off</code>(不区分大小写)来设置。</p>
<h2>从浏览器读取 Cookie</h2>
<p>可以使用命令行实现 <b>从浏览器读取 Cookie 并写入配置文件!</b></p>
<p>命令示例:<code>python .\main.py --browser_cookie Chrome --update_settings</code></p> <p>命令示例:<code>python .\main.py --browser_cookie Chrome --update_settings</code></p>
<p>兼容性提醒:此功能依赖的第三方模块已长期未更新,可能无法正常支持最新浏览器版本。若功能出现异常,请尝试手动获取 Cookie</p>
<hr> <hr>
<img src="static/screenshot/命令行模式截图1.png" alt=""> <img src="static/screenshot/命令行模式截图CN1.png" alt="">
<hr> <hr>
<img src="static/screenshot/命令行模式截图2.png" alt=""> <img src="static/screenshot/命令行模式截图CN2.png" alt="">
<h1>🕹 用户脚本</h1> <h1>🖥 服务器模式</h1>
<img src="static/screenshot/用户脚本截图1.png" alt=""> <p>服务器模式包含 API 模式和 MCP 模式!</p>
<hr> <h2>API 模式</h2>
<img src="static/screenshot/用户脚本截图2.png" alt=""> <p><b>启动:</b>运行命令:<code>python .\main.py api</code></p>
<p>如果您的浏览器安装了 <a href="https://www.tampermonkey.net/">Tampermonkey</a> 浏览器扩展程序,可以添加 <a href="https://raw.githubusercontent.com/JoeanAmier/XHS-Downloader/master/static/XHS-Downloader.js">用户脚本</a>,无需下载安装即可体验项目功能!</p> <p><b>关闭:</b>按下 <code>Ctrl</code> + <code>C</code> 关闭服务器</p>
<p>提示:使用 XHS-Downloader 用户脚本批量提取作品链接,搭配 XHS-Downloader 程序可以实现批量下载无水印作品文件!</p> <p>访问 <code>http://127.0.0.1:5556/docs</code> 或者 <code>http://127.0.0.1:5556/redoc</code>;你会看到自动生成的交互式 API 文档!</p>
<h1>💻 二次开发</h1> <p><b>请求接口:</b><code>/xhs/detail</code></p>
<p>如果有其他需求,可以根据 <code>main.py</code> 的注释提示进行代码调用或修改!</p> <p><b>请求方法:</b><code>POST</code></p>
<pre> <p><b>请求格式:</b><code>JSON</code></p>
async def example(): <p><b>请求参数:</b></p>
"""通过代码设置参数,适合二次开发"""
# 示例链接
error_link = "https://github.com/JoeanAmier/XHS_Downloader"
demo_link = "https://www.xiaohongshu.com/explore/xxxxxxxxxx"
multiple_links = f"{demo_link} {demo_link} {demo_link}"
# 实例对象
work_path = "D:\\" # 作品数据/文件保存根路径,默认值:项目根路径
folder_name = "Download" # 作品文件储存文件夹名称自动创建默认值Download
user_agent = "" # 请求头 User-Agent可选参数
cookie = "" # 小红书网页版 Cookie无需登录必需参数
proxy = None # 网络代理
timeout = 5 # 请求数据超时限制单位默认值10
chunk = 1024 * 1024 * 10 # 下载文件时,每次从服务器获取的数据块大小,单位:字节
max_retry = 2 # 请求数据失败时重试的最大次数单位默认值5
record_data = False # 是否保存作品数据至文件
image_format = "WEBP" # 图文作品文件下载格式支持PNG、WEBP
folder_mode = False # 是否将每个作品的文件储存至单独的文件夹
async with XHS() as xhs:
pass # 使用默认参数
async with XHS(work_path=work_path,
folder_name=folder_name,
user_agent=user_agent,
cookie=cookie,
proxy=proxy,
timeout=timeout,
chunk=chunk,
max_retry=max_retry,
record_data=record_data,
image_format=image_format,
folder_mode=folder_mode,
) as xhs: # 使用自定义参数
download = True # 是否下载作品文件默认值False
# 返回作品详细信息,包括下载地址
# 获取数据失败时返回空字典
print(await xhs.extract(error_link, download, ))
print(await xhs.extract(demo_link, download, ))
# 支持传入多个作品链接
print(await xhs.extract(multiple_links, download, ))
</pre>
<h1>⚙️ 配置文件</h1>
<p>项目根目录下的 <code>settings.json</code> 文件,首次运行自动生成,可以自定义部分运行参数。</p>
<table> <table>
<thead> <thead>
<tr> <tr>
@ -139,10 +157,224 @@ async def example():
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td align="center">url</td>
<td align="center">str</td>
<td align="center">小红书作品链接,自动提取,不支持多链接;必需参数</td>
<td align="center"></td>
</tr>
<tr>
<td align="center">download</td>
<td align="center">bool</td>
<td align="center">是否下载作品文件;设置为 <code>true</code> 将会耗费更多时间;可选参数</td>
<td align="center">false</td>
</tr>
<tr>
<td align="center">index</td>
<td align="center">list[int]</td>
<td align="center">下载指定序号的图片文件,仅对图文作品生效;<code>download</code> 参数设置为 <code>false</code> 时不生效;可选参数</td>
<td align="center">null</td>
</tr>
<tr>
<td align="center">cookie</td>
<td align="center">str</td>
<td align="center">请求数据时使用的 Cookie可选参数</td>
<td align="center">配置文件 cookie 参数</td>
</tr>
<tr>
<td align="center">proxy</td>
<td align="center">str</td>
<td align="center">请求数据时使用的代理;可选参数</td>
<td align="center">配置文件 proxy 参数</td>
</tr>
<tr>
<td align="center">skip</td>
<td align="center">bool</td>
<td align="center">是否跳过存在下载记录的作品;设置为 <code>true</code> 将不会返回存在下载记录的作品数据;可选参数</td>
<td align="center">false</td>
</tr>
</tbody>
</table>
<p><b>代码示例:</b></p>
<pre>
async def example_api():
"""通过 API 设置参数,适合二次开发"""
server = "http://127.0.0.1:5556/xhs/detail"
data = {
"url": "", # 必需参数
"download": True,
"index": [
3,
6,
9,
],
"proxy": "http://127.0.0.1:10808",
}
response = post(server, json=data, timeout=10)
print(response.json())
</pre>
<h2>MCP 模式</h2>
<p><b>启动:</b>运行命令:<code>python .\main.py mcp</code></p>
<p><b>关闭:</b>按下 <code>Ctrl</code> + <code>C</code> 关闭服务器</p>
<h3>MCP 配置示例</h3>
[//]: # (<h4>STDIO</h4>)
<h4>Streamable HTTP</h4>
<p><b>MCP URL</b><code>http://127.0.0.1:5556/mcp/</code></p>
<img src="static/screenshot/MCP配置示例.png" alt="MCP配置示例">
<h3>MCP 调用示例</h3>
<details>
<summary>MCP 功能及调用示例(点击展开)</summary>
<h4><strong>获取小红书作品信息</strong></h4>
<img src="static/screenshot/MCP获取数据.png" alt="MCP获取数据">
<hr>
<h4><strong>下载小红书作品文件</strong></h4>
<p>下载图文作品时可以指定需要下载的图片序号;默认不返回作品信息,如需返回作品信息,请在对话时明确表述。</p>
<img src="static/screenshot/MCP下载文件1.png" alt="MCP下载文件">
<hr>
<img src="static/screenshot/MCP下载文件2.png" alt="MCP下载文件">
</details>
<h1>📜 其他说明</h1>
<ul>
<li>由于作品链接携带日期信息,使用先前日期获取的作品链接可能会被风控,建议下载作品文件时使用最新获取的作品链接</li>
<li>Windows 系统需要以管理员身份运行程序才能读取 Chromium、Chrome、Edge 浏览器 Cookie</li>
<li>如果开启保存作品数据至文件功能,作品数据默认储存至 <code>./Volume/Download/ExploreData.db</code> 文件</li>
<li>程序下载记录数据储存至 <code>./Volume/ExploreID.db</code> 文件</li>
<li>为了避免请求频率过高对平台服务器造成影响,本项目内置请求延时机制</li>
</ul>
<h1 id="user-scripts">🕹 用户脚本</h1>
<p>如果您的浏览器安装了 <a href="https://www.tampermonkey.net/">Tampermonkey</a> 浏览器扩展程序,可以使用用户脚本体验项目功能!</p>
<p>用户脚本链接(右键单击复制链接):<a href="https://raw.githubusercontent.com/JoeanAmier/XHS-Downloader/refs/heads/master/static/XHS-Downloader.js">master 分支</a><a href="https://raw.githubusercontent.com/JoeanAmier/XHS-Downloader/refs/heads/develop/static/XHS-Downloader.js">develop 分支</a></p>
<img src="static/screenshot/脚本安装教程.png" alt="">
<hr>
<details>
<summary>查看 Tampermonkey 用户脚本截图(点击展开)</summary>
<img src="static/screenshot/用户脚本截图1.png" alt="">
<hr>
<img src="static/screenshot/用户脚本截图2.png" alt="">
<hr>
<img src="static/screenshot/用户脚本截图3.png" alt="">
<hr>
<img src="static/screenshot/用户脚本截图4.png" alt="">
</details>
<p>提示:使用 XHS-Downloader 用户脚本批量提取作品链接,搭配 XHS-Downloader 程序可以实现批量下载无水印作品文件!</p>
<h2>🌏 连接服务器</h2>
<p>⭐ 本项目支持通过浏览器用户脚本与主程序联动,实现一键推送下载任务。</p>
<ul><b>功能说明:</b>
<li>在项目程序的配置文件中,需要将 <code>script_server</code> 参数设置为 <code>true</code></li>
<li>保持项目程序在后台运行它将作为服务器接收用户脚本的指令TUI、MCP 和 API 模式均支持)</li>
<li>当您在浏览器中访问作品页面时,点击用户脚本菜单中的 <code>推送下载任务</code> 选项</li>
<li>用户脚本会将下载任务发送给项目程序,由项目程序负责处理和下载文件</li>
</ul>
<h2>📜 脚本说明</h2>
<ul>
<li>下载小红书无水印作品文件时,脚本需要花费时间处理文件,请等待片刻,请勿多次点击下载按钮</li>
<li>无水印图片文件为 PNG 格式;无水印视频文件较大,可能需要较长的时间处理,页面跳转可能会导致下载失败</li>
<li>提取账号发布、收藏、点赞、专辑作品链接时,脚本可以自动滚动页面直至加载全部作品</li>
<li>提取推荐作品链接、搜索作品、用户链接时脚本可以自动滚动指定次数加载更多内容默认滚动次数50 次</li>
<li>自动滚动页面功能默认关闭;用户可以自由开启,并修改滚动页面次数,修改后立即生效</li>
<li>如果未开启自动滚动页面功能,用户需要手动滚动页面以便加载更多内容后再进行其他操作</li>
<li>支持作品文件打包下载;该功能默认开启,多个文件的作品将会以压缩包格式下载</li>
<li>使用全局代理工具可能会导致脚本下载文件失败,如有异常,请尝试关闭代理工具,必要时向作者反馈</li>
<li>XHS-Downloader 用户脚本仅实现可见即可得的数据采集功能,无任何收费功能和破解功能</li>
</ul>
<p><strong>自动滚动页面功能代码已重构,该功能默认关闭!启用该功能可能会被小红书检测为自动化操作,从而导致账号受到风控或封禁风险!</strong></p>
<h1>💻 二次开发</h1>
<p>如果有其他需求,可以根据 <code>example.py</code> 的注释提示进行代码调用或修改!</p>
<pre>
async def example():
"""通过代码设置参数,适合二次开发"""
# 示例链接
demo_link = "https://www.xiaohongshu.com/explore/XXX?xsec_token=XXX"
# 实例对象
work_path = "D:\\" # 作品数据/文件保存根路径,默认值:项目根路径
folder_name = "Download" # 作品文件储存文件夹名称自动创建默认值Download
name_format = "作品标题 作品描述"
user_agent = "" # User-Agent
cookie = "" # 小红书网页版 Cookie无需登录可选参数登录状态对数据采集有影响
proxy = None # 网络代理
timeout = 5 # 请求数据超时限制单位默认值10
chunk = 1024 * 1024 * 10 # 下载文件时,每次从服务器获取的数据块大小,单位:字节
max_retry = 2 # 请求数据失败时重试的最大次数单位默认值5
record_data = False # 是否保存作品数据至文件
image_format = "WEBP" # 图文作品文件下载格式支持AUTO、PNG、WEBP、JPEG、HEIC
folder_mode = False # 是否将每个作品的文件储存至单独的文件夹
image_download = True # 图文、图集作品文件下载开关
video_download = True # 视频作品文件下载开关
live_download = False # 图文动图文件下载开关
download_record = True # 是否记录下载成功的作品 ID
language = "zh_CN" # 设置程序提示语言
author_archive = True # 是否将每个作者的作品存至单独的文件夹
write_mtime = True # 是否将作品文件的 修改时间 修改为作品的发布时间
read_cookie = None # 读取浏览器 Cookie支持设置浏览器名称字符串或者浏览器序号整数设置为 None 代表不读取
# async with XHS() as xhs:
# pass # 使用默认参数
async with XHS(
work_path=work_path,
folder_name=folder_name,
name_format=name_format,
user_agent=user_agent,
cookie=cookie,
proxy=proxy,
timeout=timeout,
chunk=chunk,
max_retry=max_retry,
record_data=record_data,
image_format=image_format,
folder_mode=folder_mode,
image_download=image_download,
video_download=video_download,
live_download=live_download,
download_record=download_record,
language=language,
read_cookie=read_cookie,
author_archive=author_archive,
write_mtime=write_mtime,
) as xhs: # 使用自定义参数
download = True # 是否下载作品文件默认值False
# 返回作品详细信息,包括下载地址
# 获取数据失败时返回空字典
print(
await xhs.extract(
demo_link,
download,
index=[
1,
2,
5,
],
)
)
</pre>
<h1>📋 读取剪贴板</h1>
<p>项目使用 <code>pyperclip</code> 实现读取剪贴板功能,该模块在不同的系统上会有差异。</p>
<p>在 Windows 上,不需要额外的模块。</p>
<p>在 Mac 上,该模块使用 pbcopy 和 pbpaste 命令,这些命令应该随操作系统一起提供。</p>
<p>在 Linux 上,该模块使用 xclip 或 xsel 命令,这些命令应该随操作系统一起提供。否则,请运行 "sudo apt-get install xclip" 或 "sudo apt-get install xsel"注意xsel 似乎并不总是有效)</p>
<p>在其他 Linux 系统上,你需要安装 qtpy 或 PyQT5 模块。</p>
<h1>⚙️ 配置文件</h1>
<p>项目根目录下的 <code>./Volume/settings.json</code> 文件,首次运行自动生成,可以自定义程序运行参数;如果设置了无效的参数值,程序将会使用参数默认值!</p>
<p>如果您在程序界面修改配置时无法正常交互,可以直接编辑配置文件;如果您的计算机没有合适的程序编辑 JSON 文件,建议使用 <a href="https://www.toolhelper.cn/JSON/JSONFormat">在线工具</a> 编辑配置文件内容,修改后需要重启软件才能生效。</p>
<table>
<thead>
<tr>
<th align="center">参数</th>
<th align="center">类型</th>
<th align="center">含义</th>
<th align="center">默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">mapping_data</td>
<td align="center">str: str</td>
<td align="center"><sup><a href="#author_archive">#</a></sup>作者别名映射表,格式:<code>作者ID: 作者别名</code></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">work_path</td> <td align="center">work_path</td>
<td align="center">str</td> <td align="center">str</td>
<td align="center">作品数据 / 文件保存根路径</td> <td align="center">作品数据 / 文件保存根路径</td>
<td align="center">项目根路径</td> <td align="center">项目根路径/Volume</td>
</tr> </tr>
<tr> <tr>
<td align="center">folder_name</td> <td align="center">folder_name</td>
@ -151,15 +383,21 @@ async def example():
<td align="center">Download</td> <td align="center">Download</td>
</tr> </tr>
<tr> <tr>
<td align="center">name_format</td>
<td align="center">str</td>
<td align="center">作品文件名称格式,字段之间使用空格分隔,支持字段:<code>收藏数量</code><code>评论数量</code><code>分享数量</code><code>点赞数量</code><code>作品标签</code><code>作品ID</code><code>作品标题</code><code>作品描述</code><code>作品类型</code><code>发布时间</code><code>最后更新时间</code><code>作者昵称</code><code>作者ID</code></td>
<td align="center"><code>发布时间 作者昵称 作品标题</code></td>
</tr>
<tr>
<td align="center">user_agent</td> <td align="center">user_agent</td>
<td align="center">str</td> <td align="center">str</td>
<td align="center">请求头 User-Agent</td> <td align="center">浏览器 User Agent</td>
<td align="center">默认 UA</td> <td align="center">内置 Chrome User Agent</td>
</tr> </tr>
<tr> <tr>
<td align="center">cookie</td> <td align="center">cookie</td>
<td align="center">str</td> <td align="center">str</td>
<td align="center">小红书网页版 Cookie<b>无需登录</b></td> <td align="center">小红书网页版 Cookie<b>无需登录,非必需参数!</b></td>
<td align="center"></td> <td align="center"></td>
</tr> </tr>
<tr> <tr>
@ -178,7 +416,7 @@ async def example():
<td align="center">chunk</td> <td align="center">chunk</td>
<td align="center">int</td> <td align="center">int</td>
<td align="center">下载文件时,每次从服务器获取的数据块大小,单位:字节</td> <td align="center">下载文件时,每次从服务器获取的数据块大小,单位:字节</td>
<td align="center">1048576(1 MB)</td> <td align="center">2097152(2 MB)</td>
</tr> </tr>
<tr> <tr>
<td align="center">max_retry</td> <td align="center">max_retry</td>
@ -195,26 +433,78 @@ async def example():
<tr> <tr>
<td align="center">image_format</td> <td align="center">image_format</td>
<td align="center">str</td> <td align="center">str</td>
<td align="center">图文作品文件下载格式,支持:<code>PNG</code><code>WEBP</code></td> <td align="center">图文作品文件下载格式,支持:<code>AUTO</code><code>PNG</code><code>WEBP</code><code>JPEG</code><code>HEIC</code><br><strong>部分作品没有 <code>HEIC</code> 格式的文件,此时下载的文件可能为 <code>WEBP</code> 格式!</strong><br><strong>设置为 <code>AUTO</code> 时表示动态格式,实际格式取决于服务器响应数据!</strong></td>
<td align="center">PNG</td> <td align="center">PNG</td>
</tr> </tr>
<tr> <tr>
<td align="center">image_download</td>
<td align="center">bool</td>
<td align="center">图文、图集作品文件下载开关</td>
<td align="center">true</td>
</tr>
<tr>
<td align="center">video_download</td>
<td align="center">bool</td>
<td align="center">视频作品文件下载开关</td>
<td align="center">true</td>
</tr>
<tr>
<td align="center">live_download</td>
<td align="center">bool</td>
<td align="center">图文动图文件下载开关</td>
<td align="center">false</td>
</tr>
<tr>
<td align="center">folder_mode</td> <td align="center">folder_mode</td>
<td align="center">bool</td> <td align="center">bool</td>
<td align="center">是否将每个作品的文件储存至单独的文件夹;文件夹名称与文件名称保持一致</td> <td align="center">是否将每个作品的文件储存至单独的文件夹;文件夹名称与文件名称保持一致</td>
<td align="center">false</td> <td align="center">false</td>
</tr> </tr>
<tr> <tr>
<td align="center">download_record</td>
<td align="center">bool</td>
<td align="center">是否记录下载成功的作品 ID如果开启程序将会自动跳过下载存在记录的作品</td>
<td align="center">true</td>
</tr>
<tr>
<td align="center">author_archive</td>
<td align="center">bool</td>
<td align="center"><sup><a href="#author_archive">#</a></sup>是否将每个作者的作品储存至单独的文件夹;文件夹名称为 <code>作者ID_作者昵称</code></td>
<td align="center">false</td>
</tr>
<tr>
<td align="center">write_mtime</td>
<td align="center">bool</td>
<td align="center">是否将作品文件的 <code>修改时间</code> 属性修改为作品的发布时间</td>
<td align="center">false</td>
</tr>
<tr>
<td align="center">language</td> <td align="center">language</td>
<td align="center">str</td> <td align="center">str</td>
<td align="center">设置程序语言,目前支持:<code>zh_CN</code><code>en_GB</code></td> <td align="center">设置程序语言,目前支持:<code>zh_CN</code><code>en_US</code></td>
<td align="center">zh_CN</td> <td align="center">zh_CN</td>
</tr> </tr>
<tr>
<td align="center">script_server</td>
<td align="center">bool</td>
<td align="center">是否开启用户脚本服务器用于接收浏览器用户脚本的下载任务TUI、MCP 和 API 模式生效)</td>
<td align="center">false</td>
</tr>
</tbody> </tbody>
</table> </table>
<hr>
<div id="author_archive">
<p>如果 <code>author_archive</code> 参数设置为 <code>true</code>,程序会把每个作者的作品储存至单独的文件夹;当作者的昵称发生变化时,程序会自动更新已下载作品文件名称中的作者昵称部分!</p>
<p>除此之外,你还可以通过设置 <code>mapping_data</code> 参数为某个作者设置别名;如果对某个作者设置了别名,程序会使用你设置的作者别名去替代作者昵称!</p>
</div>
<hr>
<p><b>其他说明:<code>user_agent</code>参数获取示例;强烈建议根据实际浏览器信息进行设置!</b></p>
<img src="static/screenshot/请求头示例图.png" alt="">
<h1>🌐 Cookie</h1> <h1>🌐 Cookie</h1>
<p><code>2.2</code> 版本开始,项目功能无异常的情况下,无需额外处理 Cookie</p>
<ol> <ol>
<li>打开浏览器(可选无痕模式启动),访问 <code>https://www.xiaohongshu.com/explore</code></li> <li>打开浏览器(可选无痕模式启动),访问 <code>https://www.xiaohongshu.com/explore</code></li>
<li>登录小红书账号(可跳过)</li>
<li>按下 <code>F12</code> 打开开发人员工具</li> <li>按下 <code>F12</code> 打开开发人员工具</li>
<li>选择 <code>网络</code> 选项卡</li> <li>选择 <code>网络</code> 选项卡</li>
<li>勾选 <code>保留日志</code></li> <li>勾选 <code>保留日志</code></li>
@ -228,6 +518,96 @@ async def example():
<img src="static/screenshot/获取Cookie示意图.png" alt=""> <img src="static/screenshot/获取Cookie示意图.png" alt="">
<h1>🗳 下载记录</h1> <h1>🗳 下载记录</h1>
<p>XHS-Downloader 会将下载过的作品 ID 储存至数据库当重复下载相同的作品时XHS-Downloader 会自动跳过该作品的文件下载(即使作品文件不存在),如果想要重新下载作品文件,请先删除数据库中对应的作品 ID再使用 XHS-Downloader 下载作品文件!</p> <p>XHS-Downloader 会将下载过的作品 ID 储存至数据库当重复下载相同的作品时XHS-Downloader 会自动跳过该作品的文件下载(即使作品文件不存在),如果想要重新下载作品文件,请先删除数据库中对应的作品 ID再使用 XHS-Downloader 下载作品文件!</p>
<p>该功能默认开启如果关闭该功能XHS-Downloader 会检查文件是否存在,若文件存在则跳过下载!</p>
<h2>构建可执行文件指南</h2>
<details>
<summary><b>构建可执行文件指南(点击展开)</b></summary>
本指南将引导您通过 Fork 本仓库并执行 GitHub Actions 自动完成基于最新源码的程序构建和打包!
---
## 使用步骤
### 1. Fork 本仓库
1. 点击项目仓库右上角的 **Fork** 按钮,将本仓库 Fork 到您的个人 GitHub 账户中
2. 您的 Fork 仓库地址将类似于:`https://github.com/your-username/this-repo`
---
### 2. 启用 GitHub Actions
1. 前往您 Fork 的仓库页面
2. 点击顶部的 **Settings** 选项卡
3. 点击右侧的 **Actions** 选项卡
4. 点击 **General** 选项
5. 在 **Actions permissions** 下,选择 **Allow all actions and reusable workflows** 选项,点击 **Save** 按钮
---
### 3. 手动触发打包流程
1. 在您 Fork 的仓库中,点击顶部的 **Actions** 选项卡
2. 找到名为 **构建可执行文件** 的工作流
3. 点击右侧的 **Run workflow** 按钮:
- 选择 **master** 或者 **develop** 分支
- 点击 **Run workflow**
---
### 4. 查看打包进度
1. 在 **Actions** 页面中,您可以看到触发的工作流运行记录
2. 点击运行记录,查看详细的日志以了解打包进度和状态
---
### 5. 下载打包结果
1. 打包完成后,进入对应的运行记录页面
2. 在页面底部的 **Artifacts** 部分,您将看到打包的结果文件
3. 点击下载并保存到本地,即可获得打包好的程序
---
## 注意事项
1. **资源使用**
- Actions 的运行环境由 GitHub 免费提供普通用户每月有一定的免费使用额度2000 分钟)
2. **代码修改**
- 您可以自由修改 Fork 仓库中的代码以定制程序打包流程
- 修改后重新触发打包流程,您将得到自定义的构建版本
3. **与主仓库保持同步**
- 如果主仓库更新了代码或工作流,建议您定期同步 Fork 仓库以获取最新功能和修复
---
## Actions 常见问题
### Q1: 为什么我无法触发工作流?
A: 请确认您已按照步骤 **启用 Actions**,否则 GitHub 会禁止运行工作流
### Q2: 打包流程失败怎么办?
A:
- 检查运行日志,了解失败原因
- 确保代码没有语法错误或依赖问题
- 如果问题仍未解决,可以在本仓库的 [Issues 页面](https://github.com/JoeanAmier/XHS-Downloader/issues) 提出问题
### Q3: 我可以直接使用主仓库的 Actions 吗?
A: 由于权限限制,您无法直接触发主仓库的 Actions。请通过 Fork 仓库的方式执行打包流程
</details>
<h1>⭐ Star 趋势</h1>
<p>
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=JoeanAmier/XHS-Downloader&amp;type=Timeline"/>
</p>
<h1>♥️ 支持项目</h1> <h1>♥️ 支持项目</h1>
<p>如果 <b>XHS-Downloader</b> 对您有帮助,请考虑为它点个 <b>Star</b> ⭐,感谢您的支持!</p> <p>如果 <b>XHS-Downloader</b> 对您有帮助,请考虑为它点个 <b>Star</b> ⭐,感谢您的支持!</p>
<table> <table>
@ -244,38 +624,86 @@ async def example():
</tbody> </tbody>
</table> </table>
<p>如果您愿意,可以考虑提供资助为 <b>XHS-Downloader</b> 提供额外的支持!</p> <p>如果您愿意,可以考虑提供资助为 <b>XHS-Downloader</b> 提供额外的支持!</p>
<h1>🌟 贡献指南</h1>
<p><strong>欢迎对本项目做出贡献!为了保持代码库的整洁、高效和易于维护,请仔细阅读以下指南,以确保您的贡献能够顺利被接受和整合。</strong></p>
<ul>
<li>在开始开发前,请从 <code>develop</code> 分支拉取最新的代码,以此为基础进行修改;这有助于避免合并冲突并保证您的改动基于最新的项目状态。</li>
<li>如果您的更改涉及多个不相关的功能或问题,请将它们分成多个独立的提交或拉取请求。</li>
<li>每个拉取请求应尽可能专注于单一功能或修复,以便于代码审查和测试。</li>
<li>遵循现有的代码风格;请确保您的代码与项目中已有的代码风格保持一致;建议使用 Ruff 工具保持代码格式规范。</li>
<li>编写可读性强的代码;添加适当的注释帮助他人理解您的意图。</li>
<li>每个提交都应该包含一个清晰、简洁的提交信息,以描述所做的更改。提交信息应遵循以下格式:<code>&lt;类型&gt;: &lt;简短描述&gt;</code></li>
<li>当您准备提交拉取请求时,请优先将它们提交到 <code>develop</code> 分支;这是为了给维护者一个缓冲区,在最终合并到 <code>master</code>
分支之前进行额外的测试和审查。</li>
<li>建议在开发前或遇到疑问时与作者沟通,确保开发方向一致,避免重复劳动或无效提交。</li>
</ul>
<p><strong>参考资料:</strong></p>
<ul>
<li><a href="https://www.contributor-covenant.org/zh-cn/version/2/1/code_of_conduct/">贡献者公约</a></li>
<li><a href="https://opensource.guide/zh-hans/how-to-contribute/">如何为开源做贡献</a></li>
</ul>
<h1>✉️ 联系作者</h1> <h1>✉️ 联系作者</h1>
<ul> <ul>
<li>微信(其他事务): Downloader_Tools</li> <li>作者邮箱yonglelolu@foxmail.com</li>
<li>微信公众号(问题解答): Downloader Tools</li> <li>作者微信: Downloader_Tools</li>
<li>QQ 群聊(使用交流): <a href="https://github.com/JoeanAmier/XHS-Downloader/blob/master/static/QQ%E7%BE%A4%E8%81%8A%E4%BA%8C%E7%BB%B4%E7%A0%81.png">扫码加入群聊</a></li> <li>微信公众号: Downloader Tools</li>
<li><b>Discord 社区</b>: <a href="https://discord.com/invite/ZYtmgKud9Y">点击加入社区</a></li>
<li>QQ 群聊: <a href="https://github.com/JoeanAmier/XHS-Downloader/blob/master/static/QQ%E7%BE%A4%E8%81%8A%E4%BA%8C%E7%BB%B4%E7%A0%81.png">扫码加入群聊</a></li>
</ul> </ul>
<p><b>说明:</b>QQ 群聊仅限于讨论项目使用问题,严禁发布任何广告,严禁讨论任何账号交易、账号流量、流量变现、灰色产业等相关的内容!</p> <p><b>说明:</b>QQ 群聊仅限于讨论项目使用问题,严禁发布任何广告,严禁讨论任何账号交易、账号流量、流量变现、灰色产业等相关的内容!</p>
<p><b>作者的其他开源项目:</b></p> <p><b>作者的其他开源项目:</b></p>
<ul> <ul>
<li><b>TikTokDownloader抖音 / TikTok</b><a href="https://github.com/JoeanAmier/TikTokDownloader">https://github.com/JoeanAmier/TikTokDownloader</a></li> <li><b>DouK-Downloader抖音、TikTok</b><a href="https://github.com/JoeanAmier/TikTokDownloader">https://github.com/JoeanAmier/TikTokDownloader</a></li>
<li><b>KS-Downloader快手</b><a href="https://github.com/JoeanAmier/KS-Downloader">https://github.com/JoeanAmier/KS-Downloader</a></li> <li><b>KS-Downloader快手、KuaiShou</b><a href="https://github.com/JoeanAmier/KS-Downloader">https://github.com/JoeanAmier/KS-Downloader</a></li>
</ul> </ul>
# 💰 项目赞助
## DartNode
[![Powered by DartNode](static/DartNode_AD.png)](https://dartnode.com "Powered by DartNode - Free VPS for Open Source")
***
## ZMTO
<a href="https://www.zmto.com/"><img src="https://console.zmto.com/templates/2019/dist/images/logo_dark.svg" alt="ZMTO"></a>
<p><a href="https://www.zmto.com/">ZMTO</a>一家专业的云基础设施提供商以可靠的尖端技术与专业支持提供高效的解决方案并为符合条件的开源项目提供企业级VPS基础设施支持开源生态系统的可持续发展与创新。</p>
<h1>⚠️ 免责声明</h1> <h1>⚠️ 免责声明</h1>
<ul> <ol>
<li>使用者对本项目的使用由使用者自行决定,并自行承担风险。作者对使用者使用本项目所产生的任何损失、责任、或风险概不负责。</li> <li>使用者对本项目的使用由使用者自行决定,并自行承担风险。作者对使用者使用本项目所产生的任何损失、责任、或风险概不负责。</li>
<li>本项目的作者提供的代码和功能是基于现有知识和技术的开发成果。作者尽力确保代码的正确性和安全性,但不保证代码完全没有错误或缺陷。</li> <li>本项目的作者提供的代码和功能是基于现有知识和技术的开发成果。作者按现有技术水平努力确保代码的正确性和安全性,但不保证代码完全没有错误或缺陷。</li>
<li>本项目依赖的所有第三方库、插件或服务各自遵循其原始开源或商业许可,使用者需自行查阅并遵守相应协议,作者不对第三方组件的稳定性、安全性及合规性承担任何责任。</li>
<li>使用者在使用本项目时必须严格遵守 <a href="https://github.com/JoeanAmier/XHS-Downloader/blob/master/LICENSE">GNU <li>使用者在使用本项目时必须严格遵守 <a href="https://github.com/JoeanAmier/XHS-Downloader/blob/master/LICENSE">GNU
General Public License v3.0</a> 的要求,并在适当的地方注明使用了 <a General Public License v3.0</a> 的要求,并在适当的地方注明使用了 <a
href="https://github.com/JoeanAmier/XHS-Downloader/blob/master/LICENSE">GNU General Public License href="https://github.com/JoeanAmier/XHS-Downloader/blob/master/LICENSE">GNU General Public License
v3.0</a> 的代码。 v3.0</a> 的代码。
</li> </li>
<li>使用者在任何情况下均不得将本项目的作者、贡献者或其他相关方与使用者的使用行为联系起来,或要求其对使用者使用本项目所产生的任何损失或损害负责。</li>
<li>使用者在使用本项目的代码和功能时,必须自行研究相关法律法规,并确保其使用行为合法合规。任何因违反法律法规而导致的法律责任和风险,均由使用者自行承担。</li> <li>使用者在使用本项目的代码和功能时,必须自行研究相关法律法规,并确保其使用行为合法合规。任何因违反法律法规而导致的法律责任和风险,均由使用者自行承担。</li>
<li>使用者不得使用本工具从事任何侵犯知识产权的行为,包括但不限于未经授权下载、传播受版权保护的内容,开发者不参与、不支持、不认可任何非法内容的获取或分发。</li>
<li>本项目不对使用者涉及的数据收集、存储、传输等处理活动的合规性承担责任。使用者应自行遵守相关法律法规,确保处理行为合法正当;因违规操作导致的法律责任由使用者自行承担。</li>
<li>使用者在任何情况下均不得将本项目的作者、贡献者或其他相关方与使用者的使用行为联系起来,或要求其对使用者使用本项目所产生的任何损失或损害负责。</li>
<li>本项目的作者不会提供 XHS-Downloader 项目的付费版本,也不会提供与 XHS-Downloader 项目相关的任何商业服务。</li> <li>本项目的作者不会提供 XHS-Downloader 项目的付费版本,也不会提供与 XHS-Downloader 项目相关的任何商业服务。</li>
<li>基于本项目进行的任何二次开发、修改或编译的程序与原创作者无关,原创作者不承担与二次开发行为或其结果相关的任何责任,使用者应自行对因二次开发可能带来的各种情况负全部责任。</li> <li>基于本项目进行的任何二次开发、修改或编译的程序与原创作者无关,原创作者不承担与二次开发行为或其结果相关的任何责任,使用者应自行对因二次开发可能带来的各种情况负全部责任。</li>
</ul> <li>本项目不授予使用者任何专利许可;若使用本项目导致专利纠纷或侵权,使用者自行承担全部风险和责任。未经作者或权利人书面授权,不得使用本项目进行任何商业宣传、推广或再授权。</li>
<li>作者保留随时终止向任何违反本声明的使用者提供服务的权利,并可能要求其销毁已获取的代码及衍生作品。</li>
<li>作者保留在不另行通知的情况下更新本声明的权利,使用者持续使用即视为接受修订后的条款。</li>
</ol>
<b>在使用本项目的代码和功能之前,请您认真考虑并接受以上免责声明。如果您对上述声明有任何疑问或不同意,请不要使用本项目的代码和功能。如果您使用了本项目的代码和功能,则视为您已完全理解并接受上述免责声明,并自愿承担使用本项目的一切风险和后果。</b> <b>在使用本项目的代码和功能之前,请您认真考虑并接受以上免责声明。如果您对上述声明有任何疑问或不同意,请不要使用本项目的代码和功能。如果您使用了本项目的代码和功能,则视为您已完全理解并接受上述免责声明,并自愿承担使用本项目的一切风险和后果。</b>
# 💡 代码参考 # 💡 项目参考
* https://docs.aiohttp.org/en/stable/ * https://github.com/encode/httpx/
* https://textual.textualize.io/ * https://github.com/tiangolo/fastapi
* https://aiosqlite.omnilib.dev/en/stable/ * https://github.com/textualize/textual/
* https://click.palletsprojects.com/en/8.1.x/ * https://github.com/pyinstaller/pyinstaller
* https://github.com/borisbabic/browser_cookie3 * https://github.com/zbowling/beartype-pyinstaller-repro
* https://github.com/jlowin/fastmcp
* https://github.com/omnilib/aiosqlite
* https://github.com/carpedm20/emoji/
* https://github.com/asweigart/pyperclip
* https://github.com/lxml/lxml
* https://github.com/yaml/pyyaml
* https://github.com/pallets/click/
* https://github.com/encode/uvicorn
* https://github.com/Tinche/aiofiles

View File

@ -1,155 +1,408 @@
<div align="center"> <div align="center">
<img src="static/XHS-Downloader.png" alt="" height="256" width="256"><br> <img src="static/XHS-Downloader.png" alt="XHS-Downloader" height="256" width="256"><br>
<h1>XHS-Downloader</h1> <h1>XHS-Downloader</h1>
<p><a href="README.md">简体中文</a> | English</p> <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"> <a href="https://trendshift.io/repositories/5435" target="_blank"><img src="https://trendshift.io/api/badge/repositories/5435" alt="JoeanAmier%2FXHS-Downloader | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
<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> <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" src="https://img.shields.io/github/license/JoeanAmier/XHS-Downloader?style=flat-square">
<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 forks" src="https://img.shields.io/github/forks/JoeanAmier/XHS-Downloader?style=flat-square&color=55efc4">
<img alt="GitHub all releases" src="https://img.shields.io/github/downloads/JoeanAmier/XHS-Downloader/total?style=for-the-badge&color=f759ab"> <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/JoeanAmier/XHS-Downloader?style=flat-square&color=fda7df">
<img alt="GitHub code size in bytes" src="https://img.shields.io/github/languages/code-size/JoeanAmier/XHS-Downloader?style=flat-square&color=a29bfe">
<img alt="GitHub release (with filter)" src="https://img.shields.io/github/v/release/JoeanAmier/XHS-Downloader?style=flat-square&color=48dbfb">
<br>
<img alt="Static Badge" src="https://img.shields.io/badge/Python-3.12-b8e994?style=flat-square&logo=python&labelColor=3dc1d3">
<img alt="Static Badge" src="https://img.shields.io/badge/UserScript-ffec3d?style=flat-square&logo=tampermonkey&logoColor=%2300485B">
<img src="https://img.shields.io/badge/Sourcery-enabled-884898?style=flat-square&color=1890ff" alt="">
<img alt="Static Badge" src="https://img.shields.io/badge/Docker-badc58?style=flat-square&logo=docker">
<img alt="GitHub all releases" src="https://img.shields.io/github/downloads/JoeanAmier/XHS-Downloader/total?style=flat-square&color=ffdd59">
</div> </div>
<br> <br>
<div align="center"> <p>🔥 <b>RedNote Link Extraction/Content Collection Tool</b>Extract account-published, favorites, and liked works links; extract search result works links and user links; collect RedNote works information; extract RedNote works download addresses; download RedNote watermark-free works files!</p>
<p>🔥 <b>Xiaohongshu Artwork Collection Tool</b>: Collect information on Xiaohongshu artworks; Extract the download address of Xiaohongshu artworks; Download the Xiaohongshu watermark-free artwork files!</p> <p>🔥 "RedNote", "XiaoHongShu" and "小红书" have the same meaning, and this project is collectively referred to as "RedNote".</p>
<p>❤️ The author only releases XHS-Downloader on GitHub, without collaborating with any individuals or websites. Additionally, there are no charging plans for the tool!</p> <p>⭐ Due to the author's limited energy, I was unable to update the English document in a timely manner, and the content may have become outdated, partial translation is machine translation, the translation result may be incorrect, Suggest referring to Chinese documentation. If you want to contribute to translation, we warmly welcome you.</p>
<p>⭐ Due to the author's limited energy, I was unable to update the English document in a timely manner, and the content may have become outdated. Suggest referring to Chinese documentation. If you want to contribute to translation, we warmly welcome you</p> <h1>📑 Project Features</h1>
</div> <details>
<h1>📑 The Project Features:</h1> <summary>Program Features and User Script Features (Click to Expand)</summary>
<ul> <ul><b>Program Features</b>
<li>✅ Collect Xiaohongshu graphic/text or video artworks' information</li> <li>✅ Collect RedNote works information</li>
<li>✅ Extract Xiaohongshu graphic/text or video artworks' download addresses</li> <li>✅ Extract RedNote works download addresses</li>
<li>✅ Download Xiaohongshu graphic/text or video artworks without watermarks</li> <li>✅ Download RedNote watermark-free works files</li>
<li>✅ Supports Tampermonkey user scripts</li> <li>✅ Download RedNote livePhoto files (watermark)</li>
<li>✅ Batch download account artworks (with user scripts)</li> <li>✅ Automatically skip already downloaded works files</li>
<li>✅ Automatically skip already downloaded artworks</li> <li>✅ works file integrity handling mechanism</li>
<li>✅ Mechanism for handling the integrity of artwork files</li> <li>✅ Customizable image works file download format</li>
<li>✅ Customize the download format for graphic and text artworks</li> <li>✅ Persistently store works information to files</li>
<li>✅ Persistently store artwork information to a file</li> <li>✅ Store works files to a separate folder</li>
<li>✅ Store artwork files in a separate folder</li> <li>✅ Background clipboard monitoring for works download</li>
<li>☑️ Background monitoring of clipboard for downloading artworks</li> <li>✅ Record downloaded works IDs</li>
<li>☑️ Supports API calling functionality</li> <li>✅ Support command line for downloading works files</li>
<li>✅ Read cookies from browser</li>
<li>✅ Customizable file name format</li>
<li>✅ Support API call functionality</li>
<li>✅ Support MCP call functionality</li>
<li>✅ Support file breakpoint resume download</li>
<li>✅ Intelligent recognition of works file types</li>
<li>✅ Supports author alias configuration</li>
<li>✅ Automatic author nickname updates</li>
</ul> </ul>
<h1>📸 Program Screenshot</h1> <ul><a href="#user-scripts"><b>Script Features</b></a>
<br> <li>✅ Download RedNote watermark-free works files</li>
<p><b>🎥 Click on the image to watch the demo video</b></p> <li>✅ Extract discovery page works links</li>
<a href="https://www.bilibili.com/video/BV1nQ4y137it/"><img src="static/screenshot/程序运行截图EN1.png" alt=""></a> <li>✅ Extract account-published works links</li>
<li>✅ Extract account-favorited works links</li>
<li>✅ Extract account-liked works links</li>
<li>✅ Extract account-board works links</li>
<li>✅ Extract search result works links</li>
<li>✅ Extract search result user links</li>
</ul>
</details>
<h1>📸 Program Screenshots</h1>
<p><a href="https://www.bilibili.com/video/BV1Fcb3zWEjt/">Watch Demo on Bilibili</a><a href="https://youtu.be/VIjDytHaopg">Watch Demo on YouTube</a></p>
<img src="static/screenshot/程序运行截图EN1.png" alt="">
<hr> <hr>
<a href="https://www.bilibili.com/video/BV1nQ4y137it/"><img src="static/screenshot/程序运行截图EN2.png" alt=""></a> <img src="static/screenshot/程序运行截图EN2.png" alt="">
<h1>🔗 Support Hyperlinks</h1> <hr>
<img src="static/screenshot/程序运行截图EN3.png" alt="">
<h1>🔗 Supported Links</h1>
<ul> <ul>
<li><code>https://www.xiaohongshu.com/explore/artwork's ID</code></li> <li><code>https://www.xiaohongshu.com/explore/WorksID?xsec_token=XXX</code></li>
<li><code>https://www.xiaohongshu.com/discovery/item/artwork's ID</code></li> <li><code>https://www.xiaohongshu.com/discovery/item/WorksID?xsec_token=XXX</code></li>
<li><code>https://xhslink.com/share code</code></li> <li><code>https://www.xiaohongshu.com/user/profile/AuthorID/WorksID?xsec_token=XXX</code></li>
<li><code>https://xhslink.com/ShareCode</code></li>
<br/> <br/>
<p><b>The program supports entering multiple artwork links in a single input box, separated by spaces.</b></p> <p><b>Supports entering multiple works links at once, separated by spaces; the program will automatically extract valid links without additional processing!</b></p>
</ul> </ul>
<h1>🪟 About the Terminal</h1> <h1>🪟 About the Terminal</h1>
<p><a href="https://learn.microsoft.com/zh-cn/windows/terminal/install">Windows Terminal</a> (Default terminal in Windows 11) is recommended to run the program for optimal display performance!</p> <p>⭐ It is recommended to use the <a href="https://learn.microsoft.com/en-us/windows/terminal/install">Windows Terminal</a> (default terminal for Windows 11) to run the program for the best display effect!</p>
<h1>🥣 How to Use</h1> <h1>🥣 Usage</h1>
<p>If you only need to download watermark-free artwork files, <b>Program Running</b> is recommended; If you have other needs, <b>Source Code Running</b> is recommended!</p> <p>If you only need to download watermark-free works files, it is recommended to choose <b>Program Run</b>; if you have other needs, it is recommended to choose <b>Source Code Run</b>!</p>
<h2>🖱 Program Running</h2> <p>Starting from version <code>2.2</code>, if there are no abnormalities in project functionality, there is no need to handle cookies separately!</p>
<p>Users with Windows 10 or above can go to <a href="https://github.com/JoeanAmier/XHS-Downloader/releases/latest">Releases</a> download the program zip file, unzip it, open the program folder, and double-click <code>main.exe</code> to run the program</p> <h2>🖱 Program Run</h2>
<p>If you use the program this way, the default download path for files is: <code>.\_internal\Download</code>; configuration file path: <code>.\_internal\settings.json</code></p> <p>⭐ Mac OS, Windows 10 and above users can go to <a href="https://github.com/JoeanAmier/XHS-Downloader/releases/latest">Releases</a> or <a href="https://github.com/JoeanAmier/XHS-Downloader/actions">Actions</a> to download the program package, unzip it, open the program folder, and double-click to run <code>main</code> to use.</p>
<h2>⌨️ Source Code Running</h2> <p>⭐ This project includes GitHub Actions for automatic building executable files. Users can use GitHub Actions to build the latest source code into executable files at any time!</p>
<p>⭐ For the automatic building executable files tutorial, please refer to the <code>Build of Executable File Guide</code> section of this document. If you need a more detailed step-by-step tutorial with illustrations, please <a href="https://mp.weixin.qq.com/s/TorfoZKkf4-x8IBNLImNuw">check out this article</a>!</p>
<p><strong>Note: Due to the macOS platform's executable file <code>main</code> not being code-signed, it will be restricted by system security measures on first run. Please execute the command <code>xattr -cr project_folder_path</code> in the terminal to remove the security flag, after which it can run normally.</strong></p>
<p>If you use the program in this way, the default download path for files is: <code>.\_internal\Volume\Download</code>; the configuration file path is: <code>.\_internal\Volume\settings.json</code></p>
<h3>Update Methods</h3>
<p><strong>Method 1:</strong> Download and extract the files, then copy the old version of the <code>_internal\Volume</code> folder into the new version's <code>_internal</code> folder.</p>
<p><strong>Method 2:</strong> Download and extract the files (do not run the program), then copy all files and directly overwrite the old version.</p>
<h2>⌨️ Run from Source Code</h2>
<ol> <ol>
<li>Install Python Interpreter with version >= <code>3.12</code></li> <li>Install <a href="https://www.python.org/">Python</a> interpreter version <code>3.12</code></li>
<li>Execute <code>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt</code> to install the required modules for the program</li> <li>Download the latest source code or the source code released in <a href="https://github.com/JoeanAmier/XHS-Downloader/releases/latest">Releases</a> to your local machine</li>
<li>Download the latest source code or code released in <a href="https://github.com/JoeanAmier/XHS-Downloader/releases/latest">Releases</a> to your local workplace</li> <ol><b>Install project dependencies using pip</b>
<li>Run <code>main.py</code> to use the program</li> <li>Run the command <code>python -m venv venv</code> to create a virtual environment (optional)</li>
<li>Run the command <code>.\venv\Scripts\activate.ps1</code> or <code>venv\Scripts\activate</code> to activate the virtual environment (optional)</li>
<li>Run the command <code>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt</code> to install the required modules for the program</li>
<li>Run the command <code>python .\main.py</code> or <code>python main.py</code> to start XHS-Downloader</li>
</ol> </ol>
<h1>🕹 User Script</h1> <ol><b>Install project dependencies using uv (recommended)</b>
<p>If your browser has installed <a href="https://www.tampermonkey.net/">Tampermonkey</a> extension, add <a href="https://raw.githubusercontent.com/JoeanAmier/XHS-Downloader/master/static/XHS-Downloader.js">User script</a>, and you can experience the project's functionalities without downloading the program!</p> <li>Run the command <code>uv venv</code> to create a virtual environment</li>
<p>Tip: You can use the XHS-Downloader user script to extract artwork links in batches from web pages. Combine it with the XHS-Downloader program to achieve batch downloading of watermark-free artwork files!</p> <li>Run the command <code>uv sync</code> to synchronize environment dependencies</li>
<h2>Script Functionality</h2> <li>Run the command <code>uv run main.py</code> to start XHS-Downloader</li>
</ol>
</ol>
<h2>⌨️ Docker Run</h2>
<ol>
<li>Get Image</li>
<ul> <ul>
<li>Download Xiaohongshu watermark-free artwork files</li> <li>Method 1: Build the image using the <code>Dockerfile</code></li>
<li>Extract artwork links from the discovery page</li> <li>Method 2: Pull the image using the command <code>docker pull joeanamier/xhs-downloader</code></li>
<li>Extract artwork links from account-published content</li> <li>Method 3: Pull the image using the command <code>docker pull ghcr.io/joeanamier/xhs-downloader</code></li>
<li>Extract artwork links from account-collected content</li>
<li>Extract artwork links from account-liked content</li>
</ul> </ul>
<h2>Script Screenshot</h2> <li>Create Container</li>
<img src="static/screenshot/用户脚本截图1.png" alt=""> <ul>
<li>TUI Mode: <code>docker run --name ContainerName(optional) -p HostPort:5556 -v xhs_downloader_volume:/app/Volume -it &lt;image name&gt;</code></li>
<li>API Mode: <code>docker run --name ContainerName(optional) -p HostPort:5556 -v xhs_downloader_volume:/app/Volume -it &lt;image name&gt; python main.py api</code></li>
<li>MCP Mode: <code>docker run --name ContainerName(optional) -p HostPort:5556 -v xhs_downloader_volume:/app/Volume -it &lt;image name&gt; python main.py mcp</code></li>
<br><b>Note:</b> The <code>&lt;image name&gt;</code> here must be consistent with the image name you used in the first step (<code>joeanamier/xhs-downloader</code> or <code>ghcr.io/joeanamier/xhs-downloader</code>)
</ul>
<li>Run Container
<ul>
<li>Start Container: <code>docker start -i ContainerName/ContainerID</code></li>
<li>Restart Container: <code>docker restart -i ContainerName/ContainerID</code></li>
</ul>
</li>
</ol>
<p>When running the project via Docker, the <b>command line call mode</b> is not supported. The <b>clipboard reading</b> and <b>clipboard monitoring</b> functions are unavailable, but pasting content works fine. Please provide feedback if other features are not functioning properly!</p>
<h1>🛠 Command Line Mode</h1>
<p>The project supports command line mode. If you want to download specific images from a text and image works, you can use this mode to set the image sequence number you want to download!</p>
<p><strong>Note:</strong> When the <code>--index</code> parameter is not set, multiple works links can be passed in. All links must be enclosed in quotation marks and separated by spaces. When the <code>--index</code> parameter is set, multiple works links are not supported. Even if multiple links are passed in, the program will only process the first link!</p>
<p>The <code>bool</code> type parameters support setting with <code>true</code>, <code>false</code>, <code>1</code>, <code>0</code>, <code>yes</code>, <code>no</code>, <code>on</code> or <code>off</code> (case insensitive).</p>
<h2>Read Browser Cookies</h2>
<p>You can use the command line to <b>read cookies from browser and write them to the configuration file!</b></p>
<p>Command example: <code>python .\main.py --browser_cookie Chrome --update_settings</code></p>
<p>Compatibility note: The third-party module this feature depends on has not been updated for a long time and may not properly support the latest browser versions. If the feature is not working properly, please try obtaining cookies manually!</p>
<hr> <hr>
<img src="static/screenshot/用户脚本截图2.png" alt=""> <img src="static/screenshot/命令行模式截图EN1.png" alt="">
<h1>💻 Secondary Development</h1> <hr>
<p>If there are other requirements, you can call or modify the program refer to the comments in <code>main.py</code></p> <img src="static/screenshot/命令行模式截图EN2.png" alt="">
<pre> <h1>🖥 Server Mode</h1>
# Example links <p>Server modes include API mode and MCP mode!</p>
error_link = "https://github.com/JoeanAmier/XHS_Downloader" <h2>API Mode</h2>
demo_link = "https://www.xiaohongshu.com/explore/xxxxxxxxxx" <p><b>Start:</b> Run the command: <code>python .\main.py api</code></p>
multiple_links = f"{demo_link} {demo_link} {demo_link}" <p><b>Stop:</b> Press <code>Ctrl</code> + <code>C</code> to stop the server</p>
# Instance object <p>Open <code>http://127.0.0.1:5556/docs</code> or <code>http://127.0.0.1:5556/redoc</code>; you will see automatically generated interactive API documentation!</p>
work_path = "D:\\" # Artwork data/file save root path, default value: project root path <p><b>Request endpoint:</b>
folder_name = "Download" # Artwork file storage folder name (automatically created), default value: Download <code>/xhs/detail</code></p>
user_agent = "" # Request Header: User-Agent <p><b>Request method:</b>
cookie = "" # Xiaohongshu web version Cookie, no need to log in <code>POST</code></p>
proxy = None # Network proxy <p><b>Request format:</b>
timeout = 5 # Request data timeout limit, unit: seconds, default value: 10 <code>JSON</code></p>
chunk = 1024 * 1024 * 10 # When downloading files, the size of each data block obtained from the server each time, unit: bytes <p><b>Request parameters:</b></p>
max_retry = 2 # Maximum number of retries when requesting data fails, unit: seconds, default value: 5
record_data = False # Whether to record artwork data to a file
image_format = "WEBP" # Graphic artwork file download format, supports: PNG, WEBP
folder_mode = False # Whether to store each artwork's file in a separate folder
async with XHS() as xhs:
pass # Use default parameters
async with XHS(work_path=work_path,
folder_name=folder_name,
user_agent=user_agent,
cookie=cookie,
proxy=proxy,
timeout=timeout,
chunk=chunk,
max_retry=max_retry,
record_data=record_data,
image_format=image_format,
folder_mode=folder_mode,
) as xhs: # Use custom parameters
download = True # Whether to download artwork files, default value: False
# Return detailed information about the artwork, including download addresses
print(await xhs.extract(error_link, download)) # Return an empty dictionary when data retrieval fails
print(await xhs.extract(demo_link, download))
print(await xhs.extract(multiple_links, download)) # Support input of multiple artwork links
</pre>
<h1>⚙️ Configuration File</h1>
<p><code>settings.json</code> in the project's root directory, generated automatically on the first run, and allows customization of certain runtime parameters</p>
<p>If your computer doesn't have a suitable program to edit JSON files, it is recommended to use <a href="https://try8.cn/tool/format/json">JSON Online Tool</a> to edit the content of the configuration file</p>
<table> <table>
<thead> <thead>
<tr> <tr>
<th align="center">Parameters</th> <th align="center">Parameter</th>
<th align="center">Type</th> <th align="center">Type</th>
<th align="center">Meaning</th> <th align="center">Description</th>
<th align="center">Default</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">url</td>
<td align="center">str</td>
<td align="center">RedNote works link, auto-extraction, does not support multiple links; Required parameter</td>
<td align="center">None</td>
</tr>
<tr>
<td align="center">download</td>
<td align="center">bool</td>
<td align="center">Whether to download the works file; set to <code>true</code> will take more time; Optional parameter</td>
<td align="center">false</td>
</tr>
<tr>
<td align="center">index</td>
<td align="center">list[int]</td>
<td align="center">Download specific image files by index, only effective for text and image works; not effective when the <code>download</code> parameter is set to <code>false</code>; Optional parameter</td>
<td align="center">null</td>
</tr>
<tr>
<td align="center">cookie</td>
<td align="center">str</td>
<td align="center">Cookie used when requesting data; Optional parameter</td>
<td align="center">Settings cookie Value</td>
</tr>
<tr>
<td align="center">proxy</td>
<td align="center">str</td>
<td align="center">Proxy used when requesting data; Optional parameter</td>
<td align="center">Settings proxy Value</td>
</tr>
<tr>
<td align="center">skip</td>
<td align="center">bool</td>
<td align="center">Whether to skip works with download records; set to <code>true</code> will not return works data with download records; Optional parameter</td>
<td align="center">false</td>
</tr>
</tbody>
</table>
<p><b>Code example:</b></p>
<pre>
async def example_api():
"""通过 API 设置参数,适合二次开发"""
server = "http://127.0.0.1:5556/xhs/detail"
data = {
"url": "", # 必需参数
"download": True,
"index": [
3,
6,
9,
],
"proxy": "http://127.0.0.1:10808",
}
response = post(server, json=data, timeout=10)
print(response.json())
</pre>
<h2>MCP Mode</h2>
<p><b>Start:</b> Run the command: <code>python .\main.py mcp</code></p>
<p><b>Stop:</b> Press <code>Ctrl</code> + <code>C</code> to stop the server</p>
<h3>MCP Configuration Example</h3>
[//]: # (<h4>STDIO</h4>)
<h4>Streamable HTTP</h4>
<p><b>MCP URL:</b><code>http://127.0.0.1:5556/mcp/</code></p>
<img src="static/screenshot/MCP配置示例.png" alt="MCP Configuration Example">
<h3>MCP Invocation Example</h3>
<details>
<summary>MCP Function and Call Example (Click to Expand)</summary>
<h4><strong>Retrieve RedNote Works Information</strong></h4>
<img src="static/screenshot/MCP获取数据.png" alt="MCP Data Retrieval">
<hr>
<h4><strong>Download RedNote Works Files</strong></h4>
<p>When downloading images, you can specify the sequence numbers of the images to download. By default, post information is not returned. If you need the post information, please explicitly state so during the conversation.</p>
<img src="static/screenshot/MCP下载文件1.png" alt="MCP File Download">
<hr>
<img src="static/screenshot/MCP下载文件2.png" alt="MCP File Download">
</details>
<h1>📜 Others</h1>
<ul>
<li>Due to the date information carried in the links of RedNote works, using links obtained from previous dates may be subject to risk control. It is recommended to use the latest RedNote works links when downloading RedNote work files</li>
<li>Windows system requires running programs as an administrator to read Chromium, Chrome, Edge browser cookies</li>
<li>If the function to save works data to a file is enabled, the works data will be stored by default in the <code>./Volume/Download/ExploreData.db</code> file</li>
<li>The program's download records will be stored in the <code>./Volume/ExploreID.db</code> file</li>
<li>To prevent high-frequency requests from impacting the platform's servers, this project includes a built-in request delay mechanism</li>
</ul>
<h1 id="user-scripts">🕹 User Script</h1>
<p>If your browser has the <a href="https://www.tampermonkey.net/">Tampermonkey</a> extension installed, you can use the userscript to try the project's features!</p>
<p>Userscript links (right-click to copy the link): <a href="https://raw.githubusercontent.com/JoeanAmier/XHS-Downloader/refs/heads/master/static/XHS-Downloader.js">master branch</a>, <a href="https://raw.githubusercontent.com/JoeanAmier/XHS-Downloader/refs/heads/develop/static/XHS-Downloader.js">develop branch</a></p>
<img src="static/screenshot/脚本安装教程.png" alt="">
<hr>
<details>
<summary>View Tampermonkey userscript screenshots (click to expand)</summary>
<img src="static/screenshot/用户脚本截图1.png" alt="">
<hr>
<img src="static/screenshot/用户脚本截图2.png" alt="">
<hr>
<img src="static/screenshot/用户脚本截图3.png" alt="">
<hr>
<img src="static/screenshot/用户脚本截图4.png" alt="">
</details>
<p>Note: Using the XHS-Downloader user script to batch extract works links, in combination with the XHS-Downloader program, can achieve batch downloading of watermark-free works files!</p>
<h2>🌐 Connect to Server</h2>
<p>⭐ This project supports interaction with the main program through a browser userscript, enabling one-click push of download tasks.</p>
<ul><b>Function Description:</b>
<li>In the project program's configuration file, you need to set the <code>script_server</code> parameter to <code>true</code></li>
<li>Keep the project program running in the background, where it will act as a server to receive commands from the userscript (TUI, MCP, and API modes are all supported)</li>
<li>When you visit a post page in your browser, click the <code>Push Download Task</code> option in the userscript menu</li>
<li>The userscript will send the download task to the project program, which will handle and download the files</li>
</ul>
<h2>📜 Script Instructions</h2>
<ul>
<li>When downloading watermark-free works from Xiaohongshu, the script requires time to process the files. Please wait for a moment and do not click the download button multiple times.</li>
<li>Watermark-free image files are in PNG format; watermark-free video files are larger and may take longer to process. Page redirects may cause download failures.</li>
<li>When extracting links for posts, collects, likes, and board from an account, the script can automatically scroll the page until all works are loaded.</li>
<li>When extracting recommended works links, search works, and user links, the script can automatically scroll a specified number of times to load more content. The default number of page scrolls is 50.</li>
<li>The automatic scrolling page function is turned off by default; Users can freely open and modify the number of times the page is scrolled, and the modification will take effect immediately.</li>
<li>If the automatic page scroll feature is not enabled, users need to manually scroll the page to load more content before performing other actions.</li>
<li>Support packaging and downloading of work files; This feature is enabled by default, and works from multiple files will be downloaded in compressed file format</li>
<li>Using global proxy tools may cause script download failures. If there are issues, please try disabling the proxy tool. If necessary, contact the author for feedback.</li>
<li>XHS-Downloader userscript only implements the data collection functionality for visible content and does not include any paid or cracked features.</li>
</ul>
<p><strong>The automatic page scroll feature has been refactored and is turned off by default! Enabling this feature may be detected as automated behavior by Xiaohongshu, potentially resulting in account risk control or banning.</strong></p>
<h1>💻 Secondary Development</h1>
<p>If you have other needs, you can perform code calls or modifications based on the comments in <code>example.py</code>!</p>
<pre>
async def example():
"""通过代码设置参数,适合二次开发"""
# 示例链接
demo_link = "https://www.xiaohongshu.com/explore/XXX?xsec_token=XXX"
# 实例对象
work_path = "D:\\" # 作品数据/文件保存根路径,默认值:项目根路径
folder_name = "Download" # 作品文件储存文件夹名称自动创建默认值Download
name_format = "作品标题 作品描述"
user_agent = "" # User-Agent
cookie = "" # 小红书网页版 Cookie无需登录可选参数登录状态对数据采集有影响
proxy = None # 网络代理
timeout = 5 # 请求数据超时限制单位默认值10
chunk = 1024 * 1024 * 10 # 下载文件时,每次从服务器获取的数据块大小,单位:字节
max_retry = 2 # 请求数据失败时重试的最大次数单位默认值5
record_data = False # 是否保存作品数据至文件
image_format = "WEBP" # 图文作品文件下载格式支持AUTO、PNG、WEBP、JPEG、HEIC
folder_mode = False # 是否将每个作品的文件储存至单独的文件夹
image_download = True # 图文、图集作品文件下载开关
video_download = True # 视频作品文件下载开关
live_download = False # 图文动图文件下载开关
download_record = True # 是否记录下载成功的作品 ID
language = "zh_CN" # 设置程序提示语言
author_archive = True # 是否将每个作者的作品存至单独的文件夹
write_mtime = True # 是否将作品文件的 修改时间 修改为作品的发布时间
read_cookie = None # 读取浏览器 Cookie支持设置浏览器名称字符串或者浏览器序号整数设置为 None 代表不读取
# async with XHS() as xhs:
# pass # 使用默认参数
async with XHS(
work_path=work_path,
folder_name=folder_name,
name_format=name_format,
user_agent=user_agent,
cookie=cookie,
proxy=proxy,
timeout=timeout,
chunk=chunk,
max_retry=max_retry,
record_data=record_data,
image_format=image_format,
folder_mode=folder_mode,
image_download=image_download,
video_download=video_download,
live_download=live_download,
download_record=download_record,
language=language,
read_cookie=read_cookie,
author_archive=author_archive,
write_mtime=write_mtime,
) as xhs: # 使用自定义参数
download = True # 是否下载作品文件默认值False
# 返回作品详细信息,包括下载地址
# 获取数据失败时返回空字典
print(
await xhs.extract(
demo_link,
download,
index=[
1,
2,
5,
],
)
)
</pre>
<h1>📋 Read Clipboard</h1>
<p>The project uses <code>pyperclip</code> to implement clipboard reading functionality, which varies across different systems.</p>
<p>On Windows, no additional modules are needed.</p>
<p>On Mac, this module makes use of the pbcopy and pbpaste commands, which should come with the os.</p>
<p>On Linux, this module makes use of the xclip or xsel commands, which should come with the os. Otherwise run "sudo apt-get install xclip" or "sudo apt-get install xsel" (Note: xsel does not always seem to work.)</p>
<p>Otherwise on Linux, you will need the qtpy or PyQT5 modules installed.</p>
<h1>⚙️ Configuration File</h1>
<p>The <code>./Volume/settings.json</code> file in the project's root directory is automatically generated on the first run. You can use it to customize the program's operating parameters. If an invalid parameter value is set, the program will revert to its default value.</p>
<p>If you are unable to modify settings through the program's interface, you can edit this configuration file directly. If your computer lacks a suitable program for editing JSON files, we recommend using an <a href="https://www.toolhelper.cn/JSON/JSONFormat">online tool</a>. Remember to restart the software after making changes for them to take effect.</p>
<table>
<thead>
<tr>
<th align="center">Parameter</th>
<th align="center">Type</th>
<th align="center">Description</th>
<th align="center">Default Value</th> <th align="center">Default Value</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td align="center">mapping_data</td>
<td align="center">str: str</td>
<td align="center"><sup><a href="#author_archive">#</a></sup>Author alias mapping data, format: <code>author ID: author alias</code></td>
<td align="center">null</td>
</tr>
<tr>
<td align="center">work_path</td> <td align="center">work_path</td>
<td align="center">str</td> <td align="center">str</td>
<td align="center">Artwork data/file save root path</td> <td align="center">Root path for saving works data/files</td>
<td align="center">Project root path</td> <td align="center">Project root path/Volume</td>
</tr> </tr>
<tr> <tr>
<td align="center">folder_name</td> <td align="center">folder_name</td>
<td align="center">str</td> <td align="center">str</td>
<td align="center">Artwork file storage folder name</td> <td align="center">Name of the folder for storing works files</td>
<td align="center">Download</td> <td align="center">Download</td>
</tr> </tr>
<tr> <tr>
<td align="center">name_format</td>
<td align="center">str</td>
<td align="center"><sup><a href="#fields">#</a></sup>Format of works file name, separated by spaces between fields, supports fields: <code>收藏数量</code><code>评论数量</code><code>分享数量</code><code>点赞数量</code><code>作品标签</code><code>作品ID</code><code>作品标题</code><code>作品描述</code><code>作品类型</code><code>发布时间</code><code>最后更新时间</code><code>作者昵称</code><code>作者ID</code></td>
<td align="center"><code>发布时间 作者昵称 作品标题</code></td>
</tr>
<tr>
<td align="center">user_agent</td> <td align="center">user_agent</td>
<td align="center">str</td> <td align="center">str</td>
<td align="center">Request Header: User-Agent</td> <td align="center">Browser User Agent</td>
<td align="center">Default UA</td> <td align="center">Built-in Chrome User Agent</td>
</tr> </tr>
<tr> <tr>
<td align="center">cookie</td> <td align="center">cookie</td>
<td align="center">str</td> <td align="center">str</td>
<td align="center">Xiaohongshu web version Cookie<b>No need to log in, modification recommended</b></td> <td align="center">RedNote web version cookie, <b>No login required, non essential parameters!</b></td>
<td align="center">Default Cookie</td> <td align="center">None</td>
</tr> </tr>
<tr> <tr>
<td align="center">proxy</td> <td align="center">proxy</td>
@ -160,64 +413,237 @@ async with XHS(work_path=work_path,
<tr> <tr>
<td align="center">timeout</td> <td align="center">timeout</td>
<td align="center">int</td> <td align="center">int</td>
<td align="center">Request data timeout limit, unit: seconds</td> <td align="center">Request data timeout limit, in seconds</td>
<td align="center">10</td> <td align="center">10</td>
</tr> </tr>
<tr> <tr>
<td align="center">chunk</td> <td align="center">chunk</td>
<td align="center">int</td> <td align="center">int</td>
<td align="center">Size of each data block obtained from the server when downloading files, unit: bytes</td> <td align="center">Size of data chunk to fetch from the server each time when downloading files, in bytes</td>
<td align="center">1048576(1 MB)</td> <td align="center">2097152(2 MB)</td>
</tr> </tr>
<tr> <tr>
<td align="center">max_retry</td> <td align="center">max_retry</td>
<td align="center">int</td> <td align="center">int</td>
<td align="center">Maximum number of retries when requesting data fails, unit: seconds</td> <td align="center">Maximum number of retries when requesting data fails</td>
<td align="center">5</td> <td align="center">5</td>
</tr> </tr>
<tr> <tr>
<td align="center">record_data</td> <td align="center">record_data</td>
<td align="center">bool</td> <td align="center">bool</td>
<td align="center">Whether to record artwork data to <code>TXT</code> file</td> <td align="center">Whether to save works data to a file, saved in <code>SQLite</code> format</td>
<td align="center">false</td> <td align="center">false</td>
</tr> </tr>
<tr> <tr>
<td align="center">image_format</td> <td align="center">image_format</td>
<td align="center">str</td> <td align="center">str</td>
<td align="center">Graphic and text artwork file download format, support: <code>PNG</code><code>WEBP</code></td> <td align="center">Download format for image works files, supported: <code>AUTO</code><code>PNG</code><code>WEBP</code><code>JPEG</code><code>HEIC</code><br><strong>Some works do not have files in HEIC format, and the downloaded files may be in WEBP format</strong><br><strong>When set to<code>AUTO</code>, it represents dynamic format, and the actual format depends on the server's response data</strong></td>
<td align="center">PNG</td> <td align="center">PNG</td>
</tr> </tr>
<tr> <tr>
<td align="center">image_download</td>
<td align="center">bool</td>
<td align="center">Switch for downloading image and atlas works files</td>
<td align="center">true</td>
</tr>
<tr>
<td align="center">video_download</td>
<td align="center">bool</td>
<td align="center">Switch for downloading video works files</td>
<td align="center">true</td>
</tr>
<tr>
<td align="center">live_download</td>
<td align="center">bool</td>
<td align="center">Switch for downloading animated image files</td>
<td align="center">false</td>
</tr>
<tr>
<td align="center">folder_mode</td> <td align="center">folder_mode</td>
<td align="center">bool</td> <td align="center">bool</td>
<td align="center">Whether to store each artwork's file in a separate folder; folder names are consistent with file names</td> <td align="center">Whether to store each works files in a separate folder; the folder name matches the file name</td>
<td align="center">false</td>
</tr>
<tr>
<td align="center">download_record</td>
<td align="center">bool</td>
<td align="center">Do record the ID of successfully downloaded works? If enabled, the program will automatically skip downloading works with records</td>
<td align="center">true</td>
</tr>
<tr>
<td align="center">author_archive</td>
<td align="center">bool</td>
<td align="center"><sup><a href="#author_archive">#</a></sup>Whether to save each author's works into a separate folder; The folder name is <code>authorID_nickname</code></td>
<td align="center">false</td>
</tr>
<tr>
<td align="center">write_mtime</td>
<td align="center">bool</td>
<td align="center">Whether to modify the <code>modified time</code> attribute of the works file to the publication time of the works.</td>
<td align="center">false</td> <td align="center">false</td>
</tr> </tr>
<tr> <tr>
<td align="center">language</td> <td align="center">language</td>
<td align="center">str</td> <td align="center">str</td>
<td align="center">Set programming language, currently support: <code>zh_CN</code>, <code>en_GB</code></td> <td align="center">Set program language. Currently supported: <code>zh_CN</code>, <code>en_US</code></td>
<td align="center">zh_CN</td> <td align="center">zh_CN</td>
</tr> </tr>
<tr>
<td align="center">script_server</td>
<td align="center">bool</td>
<td align="center">Whether to enable the user script server for receiving download tasks from the browser user script (effective in TUI, MCP, and API modes)</td>
<td align="center">false</td>
</tr>
</tbody> </tbody>
</table> </table>
<hr>
<div id="fields">
<p>name_format instructions (Currently only supports Chinese values) :</p>
<ul>
<li><code>收藏数量</code>: Number of Collections</li>
<li><code>评论数量</code>: Number of Comments</li>
<li><code>分享数量</code>: Number of Shares</li>
<li><code>点赞数量</code>: Number of Likes</li>
<li><code>作品标签</code>: Works Tags</li>
<li><code>作品ID</code>: Works ID</li>
<li><code>作品标题</code>: Works Title</li>
<li><code>作品描述</code>: Works Description</li>
<li><code>作品类型</code>: Works Type</li>
<li><code>发布时间</code>: Publish Time</li>
<li><code>最后更新时间</code>: Last Updated Time</li>
<li><code>作者昵称</code>: Author Nickname</li>
<li><code>作者ID</code>: Author ID</li>
</ul>
</div>
<hr>
<div id="author_archive">
<p>When <code>author_archive</code> is set to <code>true</code>, the program will store each author's works in dedicated folders. If an author's nickname changes, the program automatically updates the nickname portion in existing downloaded filenames!</p>
<p>Additionally, you can configure author aliases through the <code>mapping_data</code> parameter. When an alias is set, the program will use your custom alias instead of the original nickname in filenames!</p>
</div>
<hr>
<p><b>Additional Notes: The parameters <code>user_agent</code> examples are provided for reference; Strongly recommend setting according to actual browser information!</b></p>
<img src="static/screenshot/请求头示例图.png" alt="">
<h1>🌐 Cookie</h1> <h1>🌐 Cookie</h1>
<p>Starting from version <code>2.2</code>, if there are no abnormalities in project functionality, there is no need to handle cookies separately!</p>
<ol> <ol>
<li>Open the browser (optional in incognito mode), visit any page on Xiaohongshu</li> <li>Open the browser (optional: start in incognito mode) and visit <code>https://www.xiaohongshu.com/explore</code></li>
<li>Press <code>F12</code> to open developer tools</li> <li>Log in to your RedNote account (can be skipped)</li>
<li>Click the <code>Console</code></li> <li>Press <code>F12</code> to open the developer tools</li>
<li>Input <code>document.cookie</code> then press Enter to confirm</li> <li>Select the <code>Network</code> tab</li>
<li>The output content is the Cookie</li> <li>Check <code>Preserve log</code></li>
<li>In the <code>Filter</code> input box, enter <code>cookie-name:web_session</code></li>
<li>Select the <code>Fetch/XHR</code> filter</li>
<li>Click on any piece of works on the RedNote page</li>
<li>In the <code>Network</code> tab, select any data packet (if no packets appear, repeat step 7)</li>
<li>Copy and paste the entire Cookie into the program or configuration file</li>
</ol> </ol>
<br> <br>
<img src="static/screenshot/获取Cookie示意图.png" alt=""> <img src="static/screenshot/获取Cookie示意图.png" alt="">
<h1>🗳 Download Records</h1>
<p>XHS-Downloader will store the IDs of downloaded works in a database. When downloading the same works again, XHS-Downloader will automatically skip the file download (even if the works file does not exist). If you want to re-download the works file, please delete the corresponding works ID from the database and then use XHS-Downloader to download the works file again!</p>
<p>This feature is enabled by default. If it is turned off, XHS-Downloader will check if the file exists. If the file exists, it will skip the download!</p>
<h2>Build of Executable File Guide</h2>
<details>
<summary>Build of Executable File Guide (Click to Expand)</summary>
This guide will walk you through forking this repository and executing GitHub Actions to automatically build and package
the program based on the latest source code!
---
## Steps to Use
### 1. Fork the Repository
1. Click the **Fork** button at the top right of the project repository to fork it to your personal GitHub account
2. Your forked repository address will look like this: `https://github.com/your-username/this-repo`
---
### 2. Enable GitHub Actions
1. Go to the page of your forked repository
2. Click the **Settings** tab at the top
3. Click the **Actions** tab on the right
4. Click the **General** option
5. Under **Actions permissions**, select **Allow all actions and reusable workflows** and click the **Save** button
---
### 3. Manually Trigger the Build Process
1. In your forked repository, click the **Actions** tab at the top
2. Find the workflow named **构建可执行文件**
3. Click the **Run workflow** button on the right:
- Select the **master** or **develop** branch
- Click **Run workflow**
---
### 4. Check the Build Progress
1. On the **Actions** page, you can see the execution records of the triggered workflow
2. Click on the run record to view detailed logs to check the build progress and status
---
### 5. Download the Build Result
1. Once the build is complete, go to the corresponding run record page
2. In the **Artifacts** section at the bottom of the page, you will see the built result file
3. Click to download and save it to your local machine to get the built program
---
## Notes
1. **Resource Usage**:
- GitHub provides free build environments for Actions, with a monthly usage limit (2000 minutes) for free-tier
users
2. **Code Modifications**:
- You are free to modify the code in your forked repository to customize the build process
- After making changes, you can trigger the build process again to get your customized version
3. **Stay in Sync with the Main Repository**:
- If the main repository is updated with new code or workflows, it is recommended that you periodically sync your
forked repository to get the latest features and fixes
---
## Frequently Asked Questions
### Q1: Why can't I trigger the workflow?
A: Please ensure that you have followed the steps to **Enable Actions**. Otherwise, GitHub will prevent the workflow
from running
### Q2: What should I do if the build process fails?
A:
- Check the run logs to understand the cause of the failure
- Ensure there are no syntax errors or dependency issues in the code
- If the problem persists, please open an issue on
the [Issues page](https://github.com/JoeanAmier/XHS-Downloader/issues)
### Q3: Can I directly use the Actions from the main repository?
A: Due to permission restrictions, you cannot directly trigger Actions from the main repository. Please use the forked
repository to execute the build process
</details>
<h1>⭐ Star History</h1>
<p>
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=JoeanAmier/XHS-Downloader&amp;type=Timeline"/>
</p>
<h1>♥️ Support the Project</h1> <h1>♥️ Support the Project</h1>
<p>If <b>XHS-Downloader</b> is helpful, please consider giving it a <b>Star</b> ⭐, thank you for your support!</p> <p>If <b>XHS-Downloader</b> has been helpful to you, please consider giving it a <b>Star</b> ⭐, Thank you for your support!</p>
<table> <table>
<thead> <thead>
<tr> <tr>
<th align="center">WeChat</th> <th align="center">微信(WeChat)</th>
<th align="center">Alipay</th> <th align="center">支付宝(Alipay)</th>
</tr> </tr>
</thead> </thead>
<tbody><tr> <tbody><tr>
@ -226,29 +652,79 @@ async with XHS(work_path=work_path,
</tr> </tr>
</tbody> </tbody>
</table> </table>
<p>If you wish, consider funding additional support for the <b>XHS-Downloader</b>!</p> <p>If you are willing, you may consider making a donation to provide additional support for <b>XHS-Downloader</b>!</p>
<h1>✉️ Contact us</h1> <h1>🌟 Contribution Guidelines</h1>
<p><strong>Welcome to contributing to this project! To keep the codebase clean, efficient, and easy to maintain, please read the following guidelines carefully to ensure that your contributions can be accepted and integrated smoothly.</strong></p>
<ul> <ul>
<li>QQ: 2437596031 (please inform intent)</li> <li>Before starting development, please pull the latest code from the <code>develop</code> branch as the basis for your modifications; this helps avoid merge conflicts and ensures your changes are based on the latest state of the project.</li>
<li>QQ Group: <a href="https://github.com/JoeanAmier/XHS-Downloader/blob/master/static/QQ%E7%BE%A4%E8%81%8A%E4%BA%8C%E7%BB%B4%E7%A0%81.png">Click to obtain the group QR code</a></li> <li>If your changes involve multiple unrelated features or issues, please split them into several independent commits or pull requests.</li>
<li>Email: yonglelolu@gmail.com</li> <li>Each pull request should focus on a single feature or fix as much as possible, to facilitate code review and testing.</li>
<li>Follow the existing coding style; make sure your code is consistent with the style already present in the project; please use the Ruff tool to maintain code formatting standards.</li>
<li>Write code that is easy to read; add appropriate annotation to help others understand your intentions.</li>
<li>Each commit should include a clear and concise commit message describing the changes made. The commit message should follow this format: <code>&lt;type&gt;: &lt;short description&gt;</code></li>
<li>When you are ready to submit a pull request, please prioritize submitting them to the <code>develop</code> branch; this provides maintainers with a buffer zone for additional testing and review before final merging into the <code>master</code> branch.</li>
<li>It is recommended to communicate with the author before starting development or when encountering questions to ensure alignment in direction and avoid redundant efforts or unnecessary commits.</li>
</ul> </ul>
<p> <p><strong>Reference materials:</strong></p>
<b>If you contact me via email, I may not be able to check and respond promptly. I will do my best to reply to your email within seven days. If there are urgent matters or you need a faster response, please contact me through other means. Thank you for your understanding!</b> <ul>
</p> <li><a href="https://www.contributor-covenant.org/version/2/1/code_of_conduct/">Contributor Covenant</a></li>
<p><b>If you're interested in DouYin / TikTok, you can check out my other open-source project <a href="https://github.com/JoeanAmier/TikTokDownloader">TikTokDownloader</a></b></p> <li><a href="https://opensource.guide/how-to-contribute/">How to Contribute to Open Source</a></li>
</ul>
<h1>✉️ Contact the Author</h1>
<ul>
<li>Author's Emailyonglelolu@foxmail.com</li>
<li>Author's WeChat: Downloader_Tools</li>
<li><b>Discord Community</b>: <a href="https://discord.com/invite/ZYtmgKud9Y">Click to Join the Community</a></li>
</ul>
<p><b>Other Open Source Projects by the Author:</b></p>
<ul>
<li><b>DouK-Downloader抖音、TikTok</b><a href="https://github.com/JoeanAmier/TikTokDownloader">https://github.com/JoeanAmier/TikTokDownloader</a></li>
<li><b>KS-Downloader快手、KuaiShou</b><a href="https://github.com/JoeanAmier/KS-Downloader">https://github.com/JoeanAmier/KS-Downloader</a></li>
</ul>
# 💰 Project Sponsorship
## DartNode
[![Powered by DartNode](static/DartNode_AD.png)](https://dartnode.com "Powered by DartNode - Free VPS for Open Source")
***
## ZMTO
<a href="https://www.zmto.com/"><img src="https://console.zmto.com/templates/2019/dist/images/logo_dark.svg" alt="ZMTO"></a>
<p><a href="https://www.zmto.com/">ZMTO</a>: A professional cloud infrastructure provider offering sophisticated solutions with reliable technology and expert support. We also empower qualified open source initiatives with enterprise-grade VPS infrastructure, driving sustainable development and innovation in the open source ecosystem. </p>
<h1>⚠️ Disclaimer</h1> <h1>⚠️ Disclaimer</h1>
<ul> <ol>
<li>Users decide on their own how to use this project and bear the risks themselves. The author is not responsible for any losses, liabilities, or risks incurred by users in the use of this project</li> <li>The user's use of this project is entirely at their own discretion and responsibility. The author assumes no liability for any losses, claims, or risks arising from the user's use of this project.</li>
<li>The code and functionalities provided by the author of this project are developed based on existing knowledge and technology. The author strives to ensure the correctness and security of the code but does not guarantee that the code is completely error-free or defect-free.</li> <li>The code and functionalities provided by the author of this project are based on current knowledge and technological developments. The author strives to ensure the correctness and security of the code according to existing technical capabilities but does not guarantee that the code is entirely free of errors or defects.</li>
<li>Users must strictly adhere to the provisions in <a href="https://github.com/JoeanAmier/XHS-Downloader/blob/master/LICENSE">GNU <li>All third-party libraries, plugins, or services relied upon by this project follow their respective open-source or commercial licenses. Users must review and comply with those license agreements. The author assumes no responsibility for the stability, security, or compliance of third-party components.</li>
General Public License v3.0</a> , and appropriately mention the use of code adhering <a <li>Users must strictly comply with the requirements of the <a href="https://github.com/JoeanAmier/XHS-Downloader/blob/master/LICENSE">GNU General Public License v3.0</a> when using this project and properly indicate that the code was used under the <a href="https://github.com/JoeanAmier/XHS-Downloader/blob/master/LICENSE">GNU General Public License v3.0</a>.</li>
href="https://github.com/JoeanAmier/XHS-Downloader/blob/master/LICENSE">GNU General Public License <li>When using the code and features of this project, users must independently research relevant laws and regulations and ensure their actions are legal and compliant. Any legal liabilities or risks arising from violations of laws and regulations shall be borne solely by the user.</li>
v3.0</a>. <li>Users must not use this tool to engage in any activities that infringe intellectual property rights, including but not limited to downloading or distributing copyright-protected content without authorization. The developers do not participate in, support, or endorse any unauthorized acquisition or distribution of illegal content.</li>
</li> <li>This project assumes no responsibility for the compliance of any data processing activities (including collection, storage, and transmission) conducted by users. Users must comply with relevant laws and regulations and ensure that their processing activities are lawful and proper. Legal liabilities resulting from non-compliant operations shall be borne by the user.</li>
<li>Under no circumstances shall users associate the author of this project, contributors, or other related parties with the user's usage behavior, or demand that they be held responsible for any losses or damages incurred by the user's use of this project.</li> <li>Under no circumstances may users associate the author, contributors, or other related parties of this project with their usage of the project, nor may they hold these parties responsible for any loss or damage arising from such usage.</li>
<li>Users must independently study relevant laws and regulations when using the code and functionalities of this project and ensure that their usage is legal and compliant. Users are solely responsible for any legal liability and risks resulting from violations of laws and regulations.</li>
<li>The author of this project will not provide a paid version of the XHS-Downloader project, nor will they offer any commercial services related to the XHS-Downloader project.</li> <li>The author of this project will not provide a paid version of the XHS-Downloader project, nor will they offer any commercial services related to the XHS-Downloader project.</li>
<li>Any secondary development, modification, or compilation of the program based on this project is unrelated to the original author. The original author is not responsible for any consequences related to secondary development or its results. Users should take full responsibility for any situations that may arise from secondary development on their own.</li> <li>Any secondary development, modification, or compilation based on this project is unrelated to the original author. The original author assumes no liability for any consequences resulting from such secondary development. Users bear full responsibility for all outcomes arising from such modifications.</li>
</ul> <li>This project grants no patent licenses; if the use of this project leads to patent disputes or infringement, the user bears all associated risks and responsibilities. Without written authorization from the author or rights holder, users may not use this project for any commercial promotion, marketing, or re-licensing.</li>
<li>The author reserves the right to terminate service to any user who violates this disclaimer at any time and may require them to destroy all obtained code and derivative works.</li>
<li>The author reserves the right to update this disclaimer at any time without prior notice. Continued use of the project constitutes acceptance of the revised terms.</li>
</ol>
<b>Before using the code and functionalities of this project, please carefully consider and accept the above disclaimer. If you have any questions or disagree with the statement, please do not use the code and functionalities of this project. If you use the code and functionalities of this project, it is considered that you fully understand and accept the above disclaimer, and willingly assume all risks and consequences associated with the use of this project.</b> <b>Before using the code and functionalities of this project, please carefully consider and accept the above disclaimer. If you have any questions or disagree with the statement, please do not use the code and functionalities of this project. If you use the code and functionalities of this project, it is considered that you fully understand and accept the above disclaimer, and willingly assume all risks and consequences associated with the use of this project.</b>
# 💡 Project References
* https://github.com/encode/httpx/
* https://github.com/tiangolo/fastapi
* https://github.com/textualize/textual/
* https://github.com/pyinstaller/pyinstaller
* https://github.com/zbowling/beartype-pyinstaller-repro
* https://github.com/jlowin/fastmcp
* https://github.com/omnilib/aiosqlite
* https://github.com/carpedm20/emoji/
* https://github.com/asweigart/pyperclip
* https://github.com/lxml/lxml
* https://github.com/yaml/pyyaml
* https://github.com/pallets/click/
* https://github.com/encode/uvicorn
* https://github.com/Tinche/aiofiles

118
example.py Normal file
View File

@ -0,0 +1,118 @@
from asyncio import run
from pyperclip import paste
from httpx import post
from rich import print
from source import XHS
async def example():
"""通过代码设置参数,适合二次开发"""
# 示例链接
demo_link = "https://www.xiaohongshu.com/explore/XXX?xsec_token=XXX"
# 实例对象
work_path = "D:\\" # 作品数据/文件保存根路径,默认值:项目根路径
folder_name = "Download" # 作品文件储存文件夹名称自动创建默认值Download
name_format = "作品标题 作品描述"
user_agent = "" # User-Agent
cookie = "" # 小红书网页版 Cookie无需登录可选参数登录状态对数据采集有影响
proxy = None # 网络代理
timeout = 5 # 请求数据超时限制单位默认值10
chunk = 1024 * 1024 * 10 # 下载文件时,每次从服务器获取的数据块大小,单位:字节
max_retry = 2 # 请求数据失败时重试的最大次数单位默认值5
record_data = False # 是否保存作品数据至文件
image_format = "WEBP" # 图文作品文件下载格式支持AUTO、PNG、WEBP、JPEG、HEIC
folder_mode = False # 是否将每个作品的文件储存至单独的文件夹
image_download = True # 图文、图集作品文件下载开关
video_download = True # 视频作品文件下载开关
live_download = False # 图文动图文件下载开关
download_record = True # 是否记录下载成功的作品 ID
language = "zh_CN" # 设置程序提示语言
author_archive = True # 是否将每个作者的作品存至单独的文件夹
write_mtime = True # 是否将作品文件的 修改时间 修改为作品的发布时间
read_cookie = None # 读取浏览器 Cookie支持设置浏览器名称字符串或者浏览器序号整数设置为 None 代表不读取
# async with XHS() as xhs:
# pass # 使用默认参数
async with XHS(
work_path=work_path,
folder_name=folder_name,
name_format=name_format,
user_agent=user_agent,
cookie=cookie,
proxy=proxy,
timeout=timeout,
chunk=chunk,
max_retry=max_retry,
record_data=record_data,
image_format=image_format,
folder_mode=folder_mode,
image_download=image_download,
video_download=video_download,
live_download=live_download,
download_record=download_record,
language=language,
read_cookie=read_cookie,
author_archive=author_archive,
write_mtime=write_mtime,
) as xhs: # 使用自定义参数
download = True # 是否下载作品文件默认值False
# 返回作品详细信息,包括下载地址
# 获取数据失败时返回空字典
print(
await xhs.extract(
demo_link,
download,
index=[
1,
2,
5,
],
)
)
async def example_api():
"""通过 API 设置参数,适合二次开发"""
server = "http://127.0.0.1:5556/xhs/detail"
data = {
"url": "", # 必需参数
"download": True,
"index": [
3,
6,
9,
],
"proxy": "http://127.0.0.1:10808",
}
response = post(server, json=data, timeout=10)
print(response.json())
async def test():
url = "" or paste()
if not url:
return
async with XHS(
download_record=False,
# image_format="PNG",
# image_format="WEBP",
# image_format="JPEG",
# image_format="HEIC",
# image_format="AVIF",
# image_format="AUTO",
) as xhs:
print(
await xhs.extract(
url,
# download=True,
)
)
if __name__ == "__main__":
# run(example())
# run(example_api())
run(test())

View File

@ -1,5 +1,30 @@
# 贡献指南 # 命令参考
* 如果想要贡献支持更多语言,请参考 `zh_CN``en_GB` 的文件夹层级结构,复制 `locale/zh_CN/LC_MESSAGES/xhs.po` 文件并编辑翻译。 **运行命令前,确保已经安装了 `gettext` 软件包,并配置好环境变量。**
**Before running the command, ensure that the `gettext` package is installed and the environment variables are properly
configured.**
* `xgettext --files-from=py_files.txt -d xhs -o xhs.pot`
* `mkdir zh_CN\LC_MESSAGES`
* `msginit -l zh_CN -o zh_CN/LC_MESSAGES/xhs.po -i xhs.pot`
* `mkdir en_US\LC_MESSAGES`
* `msginit -l en_US -o en_US/LC_MESSAGES/xhs.po -i xhs.pot`
* `msgmerge -U zh_CN/LC_MESSAGES/xhs.po xhs.pot`
* `msgmerge -U en_US/LC_MESSAGES/xhs.po xhs.pot`
# 翻译贡献指南
* 如果想要贡献支持更多语言,请在终端切换至 `locale` 文件夹,运行命令
`msginit -l 语言代码 -o 语言代码/LC_MESSAGES/xhs.po -i xhs.pot`
生成 po 文件并编辑翻译。
* 如果想要贡献改进翻译结果,请直接编辑 `xhs.po` 文件内容。 * 如果想要贡献改进翻译结果,请直接编辑 `xhs.po` 文件内容。
* 不需要提交 `xhs.mo` 文件,提交 `xhs.po` 文件后,作者会转换格式并合并。 * 仅需提交 `xhs.po` 文件,作者会转换格式并合并。
# Translation Contribution Guide
* If you want to contribute support for more languages, please switch to the `locale` folder in the terminal and run the
command `msginit -l language_code -o language_code/LC_MESSAGES/xhs.po -i xhs.pot` to generate the po file and edit the
translation.
* If you want to contribute to improving the translation, please directly edit the content of the `xhs.po` file.
* Only the `xhs.po` file needs to be submitted, and the author will convert the format and merge it.

Binary file not shown.

View File

@ -1,233 +0,0 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Language: en_GB\n"
msgid "免责声明\n"
msgstr "Disclaimer about XHS-Downloader:\n"
"\n"
"1. The user decides on their own use of this project and assumes all risks. The author is not responsible for any losses, liabilities, or risks incurred by the user in using this project.\n"
"2. The code and features provided by the author of this project are developed based on existing knowledge and technology. The author strives to ensure the correctness and security of the code but does not guarantee that the code is entirely free of errors or defects.\n"
"3. The user must strictly adhere to the requirements of the GNU General Public License v3.0 when using this project and appropriately acknowledge the use of code licensed under the GNU General Public License v3.0.\n"
"4. Under no circumstances may the user associate the author, contributors, or other relevant parties of this project with the user's actions, nor demand them to be held responsible for any losses or damages incurred by the user in using this project.\n"
"5. The user must independently research relevant laws and regulations when using the code and features of this project, ensuring that their use is legal and compliant. Any legal responsibilities and risks arising from violations of laws and regulations are the sole responsibility of the user.\n"
"6. The author of this project will not offer a paid version of the XHS-Downloader project and will not provide any commercial services related to the XHS-Downloader project.\n"
"7. Any secondary development, modification, or compilation of programs based on this project is not associated with the original author. The original author is not responsible for any consequences related to secondary development actions or their results. The user is solely responsible for all situations that may arise from secondary development.\n"
"\n"
"Before using the code and features of this project, please carefully consider and accept the above disclaimers. If you have any questions or do not agree with the statements above, please refrain from using the code and features of this project. If you proceed to use the code and features of this project, it will be considered that you fully understand and accept the disclaimers mentioned above, and willingly assume all risks and consequences associated with using this project.\n"
msgid "提取作品文件下载地址失败"
msgstr "Failed to extract the download address for the Xiaohongshu works files"
msgid "提取小红书作品链接失败"
msgstr "Failed to extract the links for Xiaohongshu works"
msgid "未输入任何小红书作品链接"
msgstr "No Xiaohongshu works links provided"
msgid "下载小红书作品文件失败"
msgstr "Failed to download the Xiaohongshu works files"
msgid "正在检查新版本,请稍等..."
msgstr "Checking for new version, please wait..."
msgid "当前版本为开发版, 可更新至正式版"
msgstr "The current version is a development version, and can be updated to the official version"
msgid "当前已是最新开发版"
msgstr "You are already using the latest development version"
msgid "当前已是最新正式版"
msgstr "You are already using the latest official version"
msgid "检测新版本失败"
msgstr "Failed to check for a new version"
msgid "开源协议"
msgstr "Open Source License"
msgid "项目地址"
msgstr "Project Address"
msgid "请输入小红书图文/视频作品链接"
msgstr "Please enter the link to the Xiaohongshu image/text or video works"
msgid "多个链接之间使用空格分隔"
msgstr "Separate multiple links with spaces"
msgid "下载无水印作品文件"
msgstr "Download images/video files"
msgid "读取剪贴板"
msgstr "Read the clipboard"
msgid "清空输入框"
msgstr "Clear the input box"
msgid "退出程序"
msgstr "Exit the program"
msgid "检查更新"
msgstr "Check for updates"
msgid "程序设置"
msgstr "Settings"
msgid "作品数据 / 文件保存根路径"
msgstr "Root path for saving works data / files"
msgid "作品文件储存文件夹名称"
msgstr "Name of the folder for storing works files"
msgid "小红书网页版 Cookie"
msgstr "Xiaohongshu Web Cookie"
msgid "网络代理"
msgstr "Network proxy"
msgid "记录作品数据"
msgstr "Record works data"
msgid "图片下载格式"
msgstr "Image download format"
msgid "作品文件夹归档模式"
msgstr "Folder archiving mode"
msgid "程序语言"
msgstr "Program language"
msgid "启动本地服务器"
msgstr "Start local server"
msgid "程序根路径"
msgstr "Program root path"
msgid "小红书网页版 Cookie无需登录参数已设置"
msgstr "Xiaohongshu web version cookie, no login required, parameters have been set"
msgid "小红书网页版 Cookie无需登录参数未设置"
msgstr "Xiaohongshu web version cookie, no login required, parameters not set"
msgid "默认 User-Agent"
msgstr "Default User-Agent"
msgid "不使用代理"
msgstr "No proxy"
msgid "保存配置"
msgstr "Save configuration"
msgid "放弃更改"
msgstr "Discard changes"
msgid "程序处理中..."
msgstr "Processing..."
msgid "已启动监听剪贴板模式"
msgstr "Currently in monitoring clipboard mode"
msgid "程序会自动读取并提取剪贴板中的小红书作品链接,并自动下载链接对应的作品文件,如需关闭,请点击关闭按钮,或者向剪贴板写入 “close” 文本!"
msgstr "The program will automatically read and extract the link to Xiaohongshu's works from the clipboard, and automatically download the corresponding work file. If you want to close it, please click the close button or write the \"close\" text to the clipboard!"
msgid "退出监听剪贴板模式"
msgstr "Exit monitoring clipboard mode"
msgid "请输入待删除的小红书作品链接或作品 ID"
msgstr "Please enter the link or ID of the Xiaohongshu works to be deleted"
msgid "支持输入作品 ID 或包含作品 ID 的作品链接,多个链接或 ID 之间使用空格分隔"
msgstr "Support input of works ID or links containing works ID, with multiple links or IDs separated by spaces"
msgid "删除指定作品 ID"
msgstr "Delete specified works ID"
msgid "返回首页"
msgstr "return"
msgid "小红书作品链接"
msgstr "Link to Xiaohongshu works"
msgid "下载指定序号的图片文件,仅对图文作品生效;多个序号输入示例:\"1 3 5 7\""
msgstr "Download image files with specified serial numbers, only effective for image works; Example of multiple serial numbers input: \"1 3 5 7\""
msgid "小红书网页版 Cookie无需登录"
msgstr "Xiaohongshu web version cookie, no need to log in"
msgid "请求数据超时限制,单位:秒"
msgstr "Network request timeout limit, in seconds"
msgid "下载文件时,每次从服务器获取的数据块大小,单位:字节"
msgstr "When downloading a file, the size of the data block obtained from the server each time, in bytes"
msgid "请求数据失败时,重试的最大次数"
msgstr "The maximum number of retries when data request fails"
msgid "是否记录作品数据至文件"
msgstr "Record works data to file"
msgid "图文作品文件下载格式支持PNG、WEBP"
msgstr "Image works file download format, supporting: PNG, WEBP"
msgid "是否将每个作品的文件储存至单独的文件夹"
msgstr "Do you need to store the files of each works in a separate folder"
msgid "设置程序语言目前支持zh_CN、en_GB"
msgstr "Set program language, currently supports: zh_CN, en_GB"
msgid "读取指定配置文件"
msgstr "Read specified configuration file"
msgid "是否更新配置文件"
msgstr "Do you need to update the configuration file"
msgid "查看详细参数说明"
msgstr "View detailed parameter descriptions"
msgid "网络异常,请求 {0} 失败"
msgstr "Network error, failed to access {0}"
msgid "{0} 文件已存在,跳过下载"
msgstr "{0} already exists, skipping download"
msgid "文件 {0} 下载成功"
msgstr "file {0} download successful"
msgid "网络异常,{0} 下载失败"
msgstr "Network error, {0} download failed"
msgid "共 {0} 个小红书作品待处理..."
msgstr "{0} works from Xiaohongshu are awaiting processing..."
msgid "开始处理作品:{0}"
msgstr "Start processing the works: {0}"
msgid "{0} 获取数据失败"
msgstr "{0} failed to retrieve data"
msgid "{0} 提取数据失败"
msgstr "{0} failed to extract data"
msgid "作品处理完成:{0}"
msgstr "works processing completed: {0}"
msgid "检测到新版本:{0}.{1}"
msgstr "New version detected: {0}.{1}"
msgid "作品 {0} 存在下载记录,跳过下载"
msgstr "works {0} has a download record, skipping download"
msgid "从指定的浏览器读取小红书网页版 Cookie需要关闭对应的浏览器支持1 Chrome, 2 Chromium, 3 Opera, 4 Opera GX, 5 Brave, 6 Edge, 7 Vivaldi, 8 Firefox, 9 LibreWolf, 10 Safari输入浏览器类型或序号"
msgstr "To read the Xiaohongshu web version cookie from the specified browser, the corresponding browser needs to be closed. Supports: 1 Chrome, 2 Chromium, 3 Opera, 4 Opera GX, 5 Brave, 6 Edge, 7 Vivaldi, 8 Firefox, 9 LibreWolf, 10 Safari, enter the browser type or serial number"
msgid "查看 XHS-Downloader 版本"
msgstr "View XHS Downloader Version"
msgid "如果 XHS-Downloader 对您有帮助,请考虑为它点个 Star感谢您的支持"
msgstr "If XHS-Downloader is helpful to you, please consider giving it Star. Thank you for your support!"
msgid "作者的其他开源项目"
msgstr "Other open-source projects of the author"
msgid "文件 {0} 请求失败,响应码 {1}"
msgstr "File {0} request failed with response code {1}"

Binary file not shown.

View File

@ -0,0 +1,704 @@
# English translations for XHS-Downloader package.
# Copyright (C) 2024 THE XHS-Downloader'S COPYRIGHT HOLDER
# This file is distributed under the same license as the XHS-Downloader package.
# FIRST AUTHOR <yonglelolu@foxmail.com>, 2024.
#
msgid ""
msgstr ""
"Project-Id-Version: XHS-Downloader 2.7\n"
"Report-Msgid-Bugs-To: <yonglelolu@foxmail.com>\n"
"POT-Creation-Date: 2025-08-10 23:34+0800\n"
"PO-Revision-Date: 2024-12-22 14:14+0800\n"
"Last-Translator: <yonglelolu@foxmail.com>\n"
"Language-Team: English\n"
"Language: en_US\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:181
#, python-brace-format
msgid "作品 {0} 存在下载记录,跳过下载"
msgstr "works {0} has a download record, skip download"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:198
msgid "提取作品文件下载地址失败"
msgstr "Failed to extract the download address for the RedNote works files"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:228
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:255
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:598
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:785
msgid "提取小红书作品链接失败"
msgstr "Failed to extract the links for RedNote works"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:230
#, python-brace-format
msgid "共 {0} 个小红书作品待处理..."
msgstr "{0} works from RedNote are awaiting processing..."
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:317
#, python-brace-format
msgid "作品 {0} 存在下载记录,跳过处理"
msgstr "Works {0} has a download record, skip processing"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:320
#, python-brace-format
msgid "开始处理作品:{0}"
msgstr "Start processing the works: {0}"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:329
#, python-brace-format
msgid "{0} 获取数据失败"
msgstr "{0} failed to retrieve data"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:334
#, python-brace-format
msgid "{0} 提取数据失败"
msgstr "{0} failed to extract data"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:336
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:83
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\explore.py:79
msgid "视频"
msgstr "video"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:339
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:91
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\explore.py:80
msgid "图文"
msgstr "image"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:340
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:92
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\explore.py:79
msgid "图集"
msgstr "LivePhoto"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:344
#, python-brace-format
msgid "未知的作品类型:{0}"
msgstr "Unknown works type: {0}"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:349
#, python-brace-format
msgid "作品处理完成:{0}"
msgstr "works processing completed: {0}"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:427
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\monitor.py:57
msgid ""
"程序会自动读取并提取剪贴板中的小红书作品链接,并自动下载链接对应的作品文件,"
"如需关闭,请点击关闭按钮,或者向剪贴板写入 “close” 文本!"
msgstr ""
"The program will automatically read and extract the link to RedNote works "
"from the clipboard, and automatically download the corresponding work file. "
"If you want to close it, please click the close button or write the "
"\"close\" text to the clipboard!"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:569
msgid "跳转至项目 GitHub 仓库"
msgstr "Jump to the project's GitHub repository"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:570
msgid "重定向至项目 GitHub 仓库主页"
msgstr "Redirect to the project's GitHub repository homepage"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:578
msgid "获取作品数据及下载地址"
msgstr "Fetch works data and download links"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:610
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:795
msgid "获取小红书作品数据成功"
msgstr "Successfully obtained data on RedNote works"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:612
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:797
msgid "获取小红书作品数据失败"
msgstr "Failed to obtain data on RedNote works"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:682
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:727
msgid "小红书作品链接"
msgstr "Link to RedNote works"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:730
msgid "指定需要下载的图文作品序号"
msgstr "Specify the serial number of the images works to be downloaded"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:734
msgid "是否需要返回作品信息数据"
msgstr "Whether to return works information data"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:748
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:753
msgid "作品文件下载任务执行完毕"
msgstr "Works file download task completed"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:758
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:763
msgid "作品文件下载任务未执行"
msgstr "Works file download task not executed"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:133
msgid "视频作品下载功能已关闭,跳过下载"
msgstr "The video download function has been turned off, skip download"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:150
msgid "图文作品下载功能已关闭,跳过下载"
msgstr "The image download function has been turned off, skip download"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:185
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:196
#, python-brace-format
msgid "{0} 文件已存在,跳过下载"
msgstr "{0} already exists, skipping download"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:242
#, python-brace-format
msgid "文件 {0} 缓存异常,重新下载"
msgstr "File {0} cache exception, download again"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:270
#, python-brace-format
msgid "文件 {0} 下载成功"
msgstr "file {0} download successful"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:276
#, python-brace-format
msgid "网络异常,{0} 下载失败,错误信息: {1}"
msgstr "Network error, {0} download failed, error message: {1}"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:353
#, python-brace-format
msgid "文件 {0} 格式判断失败,错误信息:{1}"
msgstr "Format recognition failed for file {0}, error message: {1}"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\explore.py:53
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\explore.py:58
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\explore.py:77
msgid "未知"
msgstr "unknown"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\request.py:65
#, python-brace-format
msgid "网络异常,{0} 请求失败: {1}"
msgstr "Network error, {0} request failed: {1}"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:124
msgid "小红书作品链接,多个链接使用空格分隔"
msgstr "RedNote works links, separate multiple links with spaces"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:131
msgid ""
"下载指定序号的图片文件,仅对图文/图集作品生效;多个序号输入示例:\"1 3 5 7\""
msgstr ""
"Download images files with specified serial numbers, only effective for images "
"works; Example of multiple serial numbers input: \"1 3 5 7\""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:136
msgid "作品数据/文件保存根路径"
msgstr "Root path for saving works data / files"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:137
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:40
msgid "作品文件储存文件夹名称"
msgstr "Name of the folder for storing works files"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:138
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:49
msgid "作品文件名称格式"
msgstr "Format of works file name"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:140
msgid "小红书网页版 Cookie无需登录"
msgstr "RedNote web version cookie, no need to log in"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:141
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:78
msgid "网络代理"
msgstr "Network proxy"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:142
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:88
msgid "请求数据超时限制,单位:秒"
msgstr "Network request timeout limit, in seconds"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:148
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:98
msgid "下载文件时,每次从服务器获取的数据块大小,单位:字节"
msgstr ""
"When downloading a file, the size of the data block obtained from the server "
"each time, in bytes"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:151
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:108
msgid "请求数据失败时,重试的最大次数"
msgstr "The maximum number of retries when data request fails"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:152
msgid "是否记录作品数据至文件"
msgstr "Record works data to file"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:157
msgid "图文作品文件下载格式支持PNG、WEBP"
msgstr "Image works file download format, supporting: PNG, WEBP"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:159
msgid "动态图片下载开关"
msgstr "LivePhoto download switch"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:160
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:149
msgid "作品下载记录开关"
msgstr "Download record switch"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:165
msgid "是否将每个作品的文件储存至单独的文件夹"
msgstr "Whether to save each work's files into separate folders"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:171
msgid "是否将每个作者的作品储存至单独的文件夹"
msgstr "Whether to save each author's works into separate folders"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:178
msgid "是否将作品文件的修改时间属性修改为作品的发布时间"
msgstr ""
"Would you like to set the file's modified time attribute to match the work's "
"publication time"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:182
msgid "设置程序语言目前支持zh_CN、en_US"
msgstr "Set the programming language, currently supports: zh_CN、en_US"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:183
msgid "读取指定配置文件"
msgstr "Read specified configuration file"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:190
#, python-brace-format
msgid "从指定的浏览器读取小红书网页版 Cookie支持{0}; 输入浏览器名称或序号"
msgstr ""
"Read RedNote web version cookies from the specified browser, supporting: "
"{0}; Enter browser name or serial number"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:203
msgid "是否更新配置文件"
msgstr "Do you need to update the configuration file"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:204
msgid "查看详细参数说明"
msgstr "View detailed parameter descriptions"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:205
msgid "查看 XHS-Downloader 版本"
msgstr "View XHS Downloader Version"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\expansion\browser.py:53
#, python-brace-format
msgid ""
"读取指定浏览器的 Cookie 并写入配置文件\n"
"Windows 系统需要以管理员身份运行程序才能读取 Chromium、Chrome、Edge 浏览器 "
"Cookie\n"
"{options}\n"
"请输入浏览器名称或序号:"
msgstr ""
"Read cookies from the specified browser and write them to the configuration "
"file\n"
"The Windows system requires running programs as an administrator to read "
"Chromium, Chrome, Edge browser cookies!\n"
"{options}\n"
"Please enter your browser name or serial number:"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\expansion\browser.py:63
msgid "未选择浏览器!"
msgstr "Browser not selected!"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\expansion\browser.py:75
msgid "浏览器名称或序号输入错误!"
msgstr "Browser name or serial number input error!"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\expansion\browser.py:81
msgid "获取 Cookie 失败,未找到 Cookie 数据!"
msgstr "Failed to retrieve cookie, no cookie data found!"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\expansion\browser.py:119
msgid "从浏览器读取 Cookie 功能不支持当前平台!"
msgstr ""
"The cookie reading function from the browser is not supported on the current "
"platform!"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\expansion\cleaner.py:45
msgid "不受支持的操作系统类型,可能无法正常去除非法字符!"
msgstr ""
"Unsupported operating system type, may not be able to remove illegal "
"characters properly!"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\manager.py:232
#, python-brace-format
msgid "代理 {0} 测试成功"
msgstr "Agent {0} tested successfully"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\manager.py:236
#, python-brace-format
msgid "代理 {0} 测试超时"
msgstr "Agent {0} test timeout"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\manager.py:244
#, python-brace-format
msgid "代理 {0} 测试失败:{1}"
msgstr "Agent {0} test failed: {1}"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:57
#, python-brace-format
msgid "{old_folder} 文件夹不存在,跳过处理"
msgstr "{old_folder} directory does not exist, skipping processing"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:86
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:108
msgid "文件夹"
msgstr "folder"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:91
#, python-brace-format
msgid "文件夹 {old_folder} 已重命名为 {new_folder}"
msgstr "The folder {old_folder} has been renamed to {new_folder}"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:113
#, python-brace-format
msgid "文件夹 {old_} 重命名为 {new_}"
msgstr "The folder {old_} has been renamed to {new_}"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:186
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:201
msgid "文件"
msgstr "file"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:191
#, python-brace-format
msgid "文件 {old_file} 重命名为 {new_file}"
msgstr "The file {old_file} has been renamed to {new_file}"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:210
#, python-brace-format
msgid "{type} {old}被占用,重命名失败: {error}"
msgstr "{type} {old} is occupied, renaming failed: {error}"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:219
#, python-brace-format
msgid "{type} {new}名称重复,重命名失败: {error}"
msgstr "{type} {new} already exists, renaming failed: {error}"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:228
#, python-brace-format
msgid "处理{type} {old}时发生预期之外的错误: {error}"
msgstr "An unexpected error occurred while processing {type} {old}: {error}"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\tools.py:31
msgid ""
"如需重新尝试处理该对象,请关闭所有正在访问该对象的窗口或程序,然后直接按下回"
"车键!\n"
"如需跳过处理该对象,请输入任意字符后按下回车键!"
msgstr ""
"If you want to retry processing this object, please close all windows or "
"programs currently accessing it, then press Enter directly!\n"
"If you want to skip processing this object, please enter any character and "
"then press Enter!"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:20
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:29
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\monitor.py:21
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:15
msgid "退出程序"
msgstr "Quit"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:21
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:30
msgid "检查更新"
msgstr "Update"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:22
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\record.py:35
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:16
msgid "返回首页"
msgstr "Return"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:35
msgid "如果 XHS-Downloader 对您有帮助,请考虑为它点个 Star感谢您的支持"
msgstr ""
"If XHS-Downloader is helpful to you, please consider giving it Star. Thank "
"you for your support!"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:42
msgid "Discord 社区"
msgstr "Discord Community"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:46
msgid "邀请链接:"
msgstr "Invitation link: "
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:48
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:61
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:70
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:56
msgid "点击访问"
msgstr "Click to visit"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:51
msgid "作者的其他开源项目"
msgstr "Other open-source projects of the author"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:31
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:212
msgid "程序设置"
msgstr "Settings"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:32
msgid "下载记录"
msgstr "Record"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:33
msgid "开启监听"
msgstr "Monitor"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:34
msgid "关于项目"
msgstr "About"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:49
msgid "开源协议: "
msgstr "Open source protocol: "
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:52
msgid "项目地址: "
msgstr "Repository link: "
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:59
msgid "请输入小红书图文/视频作品链接"
msgstr "Please enter the link to the RedNote image or video works"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:62
msgid "多个链接之间使用空格分隔"
msgstr "Separate multiple links with spaces"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:64
msgid "下载无水印作品文件"
msgstr "Download images/video files"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:65
msgid "读取剪贴板"
msgstr "Read the clipboard"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:66
msgid "清空输入框"
msgstr "Clear the input box"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:81
msgid "免责声明\n"
msgstr ""
"Disclaimer for XHS-Downloader:\n"
"\n"
"1.The use of this project is entirely at the user's own discretion and "
"risk. The author assumes no responsibility or liability of any kind for any "
"loss, damage, or risk arising from the user's use of this project.\n"
"2.The code and functionalities provided by the author of this project are "
"developed based on current knowledge and technology. The author makes every "
"effort to ensure the correctness and security of the code according to "
"current technical standards but does not guarantee that the code is "
"completely free of errors or defects.\n"
"3.All third-party libraries, plugins, or services used by this project "
"follow their original open-source or commercial licenses. Users must review "
"and comply with these license agreements accordingly. The author assumes no "
"responsibility for the stability, security, or compliance of any third-party "
"components.\n"
"4.When using this project, users must strictly comply with the requirements "
"of the GNU General Public License v3.0 and clearly indicate in appropriate "
"places that the code was used under the GNU General Public License v3.0.\n"
"5.When using the code and functionalities of this project, users must "
"independently research relevant laws and regulations and ensure that their "
"usage is legal and compliant. Any legal liabilities or risks arising from "
"violations of laws and regulations shall be borne solely by the user.\n"
"6.Users must not use this tool to engage in any activities that infringe "
"intellectual property rights, including but not limited to downloading or "
"distributing copyrighted content without authorization. Developers do not "
"participate in, support, or endorse the acquisition or distribution of any "
"illegal or unauthorized content.\n"
"7.This project assumes no responsibility for the compliance of data "
"processing activities (including collection, storage, and transmission) "
"performed by users. Users must comply with relevant laws and regulations and "
"ensure that such activities are lawful and proper. Legal liabilities "
"resulting from non-compliant operations shall be borne by the user.\n"
"8.Under no circumstances may users associate the author, contributors, or "
"other related parties of this project with their usage of the project, nor "
"may they hold these parties liable for any loss or damage resulting from "
"such usage.\n"
"9.The author of this project will not provide a paid version of the XHS-"
"Downloader project, nor will they offer any commercial services related to "
"it.\n"
"10.Any secondary development, modification, or compilation based on this "
"project is unrelated to the original author. The original author assumes no "
"liability for any consequences resulting from such secondary development. "
"Users bear full responsibility for all outcomes arising from such "
"modifications.\n"
"11.This project does not grant users any patent licenses. If the use of "
"this project leads to patent disputes or infringement, the user assumes all "
"associated risks and responsibilities. Without written authorization from "
"the author or rights holder, users may not use this project for any "
"commercial promotion, advertising, or re-licensing.\n"
"12.The author reserves the right to terminate service to any user who "
"violates this disclaimer at any time and may require them to destroy all "
"obtained code and derivative works.\n"
"13.The author reserves the right to update this disclaimer at any time "
"without prior notice. Continued use of the project constitutes acceptance of "
"the revised terms.\n"
"\n"
"Before using the code and functionalities of this project, please carefully "
"consider and accept the above disclaimer. If you have any questions or "
"disagree with the above statements, please do not use the code and "
"functionalities of this project. If you do use the code and functionalities "
"of this project, it shall be deemed that you have fully understood and "
"accepted the above disclaimer and voluntarily assume all risks and "
"consequences associated with its use.\n"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:94
msgid "未输入任何小红书作品链接"
msgstr "No RedNote works links provided"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:124
msgid "下载小红书作品文件失败"
msgstr "Failed to download the RedNote works files"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\loading.py:19
msgid "程序处理中..."
msgstr "Processing..."
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\monitor.py:22
msgid "关闭监听"
msgstr "Close"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\monitor.py:34
msgid "已启动监听剪贴板模式"
msgstr "Currently in monitoring clipboard mode"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\monitor.py:36
msgid "退出监听剪贴板模式"
msgstr "Exit monitoring clipboard mode"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\record.py:23
msgid "请输入待删除的小红书作品链接或作品 ID"
msgstr "Please enter the link or ID of the RedNote works to be deleted"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\record.py:26
msgid ""
"支持输入作品 ID 或包含作品 ID 的作品链接,多个链接或 ID 之间使用空格分隔"
msgstr ""
"Support input of works ID or links containing works ID, with multiple links "
"or IDs separated by spaces"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\record.py:32
msgid "删除指定作品 ID"
msgstr "Delete specified works ID"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\record.py:47
msgid "删除下载记录成功"
msgstr "Successfully deleted download record"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:30
msgid "作品数据 / 文件保存根路径"
msgstr "Root path for saving works data / files"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:35
msgid "程序根路径"
msgstr "Program root path"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:64
msgid "内置 Chrome User Agent"
msgstr "Chrome User Agent"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:69
msgid "小红书网页版 Cookie"
msgstr "RedNote Web Cookie"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:83
msgid "不使用代理"
msgstr "No proxy"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:120
msgid "记录作品详细数据"
msgstr "Record works data"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:125
msgid "作品归档保存模式"
msgstr "Works Archiving Mode"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:130
msgid "视频作品下载开关"
msgstr "Video download switch"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:135
msgid "图文作品下载开关"
msgstr "Image download switch"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:144
msgid "动图文件下载开关"
msgstr "LivePhoto download switch"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:154
msgid "作者归档保存模式"
msgstr "Author Archiving Mode"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:159
msgid "更新文件修改时间"
msgstr "Update File Modification Time"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:167
msgid "图片下载格式"
msgstr "Image download format"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:171
msgid "程序语言"
msgstr "Program language"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:194
msgid "保存配置"
msgstr "Save configuration"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:198
msgid "放弃更改"
msgstr "Discard changes"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:208
msgid "小红书网页版 Cookie无需登录参数已设置"
msgstr ""
"RedNote web version cookie, no login required, parameters have been set"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:209
msgid "小红书网页版 Cookie无需登录参数未设置"
msgstr "RedNote web version cookie, no login required, parameters not set"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\update.py:26
msgid "正在检查新版本,请稍等..."
msgstr "Checking for new version, please wait..."
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\update.py:46
#, python-brace-format
msgid "检测到新版本:{0}.{1}"
msgstr "Detected new version: {0} {1}"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\update.py:54
msgid "当前版本为开发版, 可更新至正式版"
msgstr "Detected a new official version"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\update.py:59
msgid "当前已是最新开发版"
msgstr "You are already using the latest development version"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\update.py:64
msgid "当前已是最新正式版"
msgstr "You are already using the latest official version"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\update.py:71
msgid "检测新版本失败"
msgstr "Failed to check for a new version"

17
locale/generate_path.py Normal file
View File

@ -0,0 +1,17 @@
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
def find_python_files(dir_, file):
with open(file, "w", encoding="utf-8") as f:
for py_file in dir_.rglob("*.py"): # 递归查找所有 .py 文件
f.write(str(py_file) + "\n") # 写入文件路径
# 设置源目录和输出文件
source_directory = ROOT.joinpath("source") # 源目录
output_file = "py_files.txt" # 输出文件名
find_python_files(source_directory, output_file)
print(f"所有 .py 文件路径已保存到 {output_file}")

View File

@ -1,15 +1,12 @@
from pathlib import Path from pathlib import Path
from subprocess import run from subprocess import run
__all__ = []
ROOT = Path(__file__).resolve().parent ROOT = Path(__file__).resolve().parent
def scan_directory(): def scan_directory():
return [ return [
item.joinpath("LC_MESSAGES/xhs.po") item.joinpath("LC_MESSAGES/xhs.po") for item in ROOT.iterdir() if item.is_dir()
for item in ROOT.iterdir()
if item.is_dir()
] ]
@ -19,7 +16,7 @@ def generate_map(files: list[Path]):
def generate_mo(maps: list[tuple[Path, Path]]): def generate_mo(maps: list[tuple[Path, Path]]):
for i, j in maps: for i, j in maps:
command = f"msgfmt \"{i}\" -o \"{j}\"" command = f'msgfmt --check -o "{j}" "{i}"'
print(run(command, shell=True, text=True)) print(run(command, shell=True, text=True))

610
locale/xhs.pot Normal file
View File

@ -0,0 +1,610 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: XHS-Downloader 2.7\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-08-10 23:34+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:181
#, python-brace-format
msgid "作品 {0} 存在下载记录,跳过下载"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:198
msgid "提取作品文件下载地址失败"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:228
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:255
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:598
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:785
msgid "提取小红书作品链接失败"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:230
#, python-brace-format
msgid "共 {0} 个小红书作品待处理..."
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:317
#, python-brace-format
msgid "作品 {0} 存在下载记录,跳过处理"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:320
#, python-brace-format
msgid "开始处理作品:{0}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:329
#, python-brace-format
msgid "{0} 获取数据失败"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:334
#, python-brace-format
msgid "{0} 提取数据失败"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:336
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:83
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\explore.py:79
msgid "视频"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:339
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:91
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\explore.py:80
msgid "图文"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:340
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:92
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\explore.py:79
msgid "图集"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:344
#, python-brace-format
msgid "未知的作品类型:{0}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:349
#, python-brace-format
msgid "作品处理完成:{0}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:427
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\monitor.py:57
msgid ""
"程序会自动读取并提取剪贴板中的小红书作品链接,并自动下载链接对应的作品文件,"
"如需关闭,请点击关闭按钮,或者向剪贴板写入 “close” 文本!"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:569
msgid "跳转至项目 GitHub 仓库"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:570
msgid "重定向至项目 GitHub 仓库主页"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:578
msgid "获取作品数据及下载地址"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:610
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:795
msgid "获取小红书作品数据成功"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:612
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:797
msgid "获取小红书作品数据失败"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:682
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:727
msgid "小红书作品链接"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:730
msgid "指定需要下载的图文作品序号"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:734
msgid "是否需要返回作品信息数据"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:748
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:753
msgid "作品文件下载任务执行完毕"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:758
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:763
msgid "作品文件下载任务未执行"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:133
msgid "视频作品下载功能已关闭,跳过下载"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:150
msgid "图文作品下载功能已关闭,跳过下载"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:185
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:196
#, python-brace-format
msgid "{0} 文件已存在,跳过下载"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:242
#, python-brace-format
msgid "文件 {0} 缓存异常,重新下载"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:270
#, python-brace-format
msgid "文件 {0} 下载成功"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:276
#, python-brace-format
msgid "网络异常,{0} 下载失败,错误信息: {1}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:353
#, python-brace-format
msgid "文件 {0} 格式判断失败,错误信息:{1}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\explore.py:53
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\explore.py:58
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\explore.py:77
msgid "未知"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\request.py:65
#, python-brace-format
msgid "网络异常,{0} 请求失败: {1}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:124
msgid "小红书作品链接,多个链接使用空格分隔"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:131
msgid ""
"下载指定序号的图片文件,仅对图文/图集作品生效;多个序号输入示例:\"1 3 5 7\""
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:136
msgid "作品数据/文件保存根路径"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:137
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:40
msgid "作品文件储存文件夹名称"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:138
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:49
msgid "作品文件名称格式"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:140
msgid "小红书网页版 Cookie无需登录"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:141
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:78
msgid "网络代理"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:142
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:88
msgid "请求数据超时限制,单位:秒"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:148
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:98
msgid "下载文件时,每次从服务器获取的数据块大小,单位:字节"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:151
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:108
msgid "请求数据失败时,重试的最大次数"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:152
msgid "是否记录作品数据至文件"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:157
msgid "图文作品文件下载格式支持PNG、WEBP"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:159
msgid "动态图片下载开关"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:160
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:149
msgid "作品下载记录开关"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:165
msgid "是否将每个作品的文件储存至单独的文件夹"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:171
msgid "是否将每个作者的作品储存至单独的文件夹"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:178
msgid "是否将作品文件的修改时间属性修改为作品的发布时间"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:182
msgid "设置程序语言目前支持zh_CN、en_US"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:183
msgid "读取指定配置文件"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:190
#, python-brace-format
msgid "从指定的浏览器读取小红书网页版 Cookie支持{0}; 输入浏览器名称或序号"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:203
msgid "是否更新配置文件"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:204
msgid "查看详细参数说明"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:205
msgid "查看 XHS-Downloader 版本"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\expansion\browser.py:53
#, python-brace-format
msgid ""
"读取指定浏览器的 Cookie 并写入配置文件\n"
"Windows 系统需要以管理员身份运行程序才能读取 Chromium、Chrome、Edge 浏览器 "
"Cookie\n"
"{options}\n"
"请输入浏览器名称或序号:"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\expansion\browser.py:63
msgid "未选择浏览器!"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\expansion\browser.py:75
msgid "浏览器名称或序号输入错误!"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\expansion\browser.py:81
msgid "获取 Cookie 失败,未找到 Cookie 数据!"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\expansion\browser.py:119
msgid "从浏览器读取 Cookie 功能不支持当前平台!"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\expansion\cleaner.py:45
msgid "不受支持的操作系统类型,可能无法正常去除非法字符!"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\manager.py:232
#, python-brace-format
msgid "代理 {0} 测试成功"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\manager.py:236
#, python-brace-format
msgid "代理 {0} 测试超时"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\manager.py:244
#, python-brace-format
msgid "代理 {0} 测试失败:{1}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:57
#, python-brace-format
msgid "{old_folder} 文件夹不存在,跳过处理"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:86
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:108
msgid "文件夹"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:91
#, python-brace-format
msgid "文件夹 {old_folder} 已重命名为 {new_folder}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:113
#, python-brace-format
msgid "文件夹 {old_} 重命名为 {new_}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:186
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:201
msgid "文件"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:191
#, python-brace-format
msgid "文件 {old_file} 重命名为 {new_file}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:210
#, python-brace-format
msgid "{type} {old}被占用,重命名失败: {error}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:219
#, python-brace-format
msgid "{type} {new}名称重复,重命名失败: {error}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:228
#, python-brace-format
msgid "处理{type} {old}时发生预期之外的错误: {error}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\tools.py:31
msgid ""
"如需重新尝试处理该对象,请关闭所有正在访问该对象的窗口或程序,然后直接按下回"
"车键!\n"
"如需跳过处理该对象,请输入任意字符后按下回车键!"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:20
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:29
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\monitor.py:21
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:15
msgid "退出程序"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:21
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:30
msgid "检查更新"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:22
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\record.py:35
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:16
msgid "返回首页"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:35
msgid "如果 XHS-Downloader 对您有帮助,请考虑为它点个 Star感谢您的支持"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:42
msgid "Discord 社区"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:46
msgid "邀请链接:"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:48
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:61
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:70
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:56
msgid "点击访问"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:51
msgid "作者的其他开源项目"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:31
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:212
msgid "程序设置"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:32
msgid "下载记录"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:33
msgid "开启监听"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:34
msgid "关于项目"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:49
msgid "开源协议: "
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:52
msgid "项目地址: "
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:59
msgid "请输入小红书图文/视频作品链接"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:62
msgid "多个链接之间使用空格分隔"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:64
msgid "下载无水印作品文件"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:65
msgid "读取剪贴板"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:66
msgid "清空输入框"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:81
msgid "免责声明\n"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:94
msgid "未输入任何小红书作品链接"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:124
msgid "下载小红书作品文件失败"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\loading.py:19
msgid "程序处理中..."
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\monitor.py:22
msgid "关闭监听"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\monitor.py:34
msgid "已启动监听剪贴板模式"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\monitor.py:36
msgid "退出监听剪贴板模式"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\record.py:23
msgid "请输入待删除的小红书作品链接或作品 ID"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\record.py:26
msgid ""
"支持输入作品 ID 或包含作品 ID 的作品链接,多个链接或 ID 之间使用空格分隔"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\record.py:32
msgid "删除指定作品 ID"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\record.py:47
msgid "删除下载记录成功"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:30
msgid "作品数据 / 文件保存根路径"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:35
msgid "程序根路径"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:64
msgid "内置 Chrome User Agent"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:69
msgid "小红书网页版 Cookie"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:83
msgid "不使用代理"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:120
msgid "记录作品详细数据"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:125
msgid "作品归档保存模式"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:130
msgid "视频作品下载开关"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:135
msgid "图文作品下载开关"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:144
msgid "动图文件下载开关"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:154
msgid "作者归档保存模式"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:159
msgid "更新文件修改时间"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:167
msgid "图片下载格式"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:171
msgid "程序语言"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:194
msgid "保存配置"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:198
msgid "放弃更改"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:208
msgid "小红书网页版 Cookie无需登录参数已设置"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:209
msgid "小红书网页版 Cookie无需登录参数未设置"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\update.py:26
msgid "正在检查新版本,请稍等..."
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\update.py:46
#, python-brace-format
msgid "检测到新版本:{0}.{1}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\update.py:54
msgid "当前版本为开发版, 可更新至正式版"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\update.py:59
msgid "当前已是最新开发版"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\update.py:64
msgid "当前已是最新正式版"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\update.py:71
msgid "检测新版本失败"
msgstr ""

Binary file not shown.

View File

@ -1,233 +1,648 @@
# Chinese translations for XHS-Downloader package
# Copyright (C) 2024 THE XHS-Downloader'S COPYRIGHT HOLDER
# This file is distributed under the same license as the XHS-Downloader package.
# FIRST AUTHOR <yonglelolu@foxmail.com>, 2024.
#
msgid "" msgid ""
msgstr "" msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Project-Id-Version: XHS-Downloader 2.7\n"
"Report-Msgid-Bugs-To: <yonglelolu@foxmail.com>\n"
"POT-Creation-Date: 2025-08-10 23:34+0800\n"
"PO-Revision-Date: 2024-12-22 14:14+0800\n"
"Last-Translator: <yonglelolu@foxmail.com>\n"
"Language-Team: Chinese (simplified)\n"
"Language: zh_CN\n" "Language: zh_CN\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
msgid "免责声明\n" #: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:181
msgstr "关于 XHS-Downloader 的 免责声明:\n" #, python-brace-format
"\n"
"1.使用者对本项目的使用由使用者自行决定,并自行承担风险。作者对使用者使用本项目所产生的任何损失、责任、或风险概不负责。\n"
"2.本项目的作者提供的代码和功能是基于现有知识和技术的开发成果。作者尽力确保代码的正确性和安全性,但不保证代码完全没有错误或缺陷。\n"
"3.使用者在使用本项目时必须严格遵守 GNU General Public License v3.0 的要求,并在适当的地方注明使用了 GNU General Public License v3.0 的代码。\n"
"4.使用者在任何情况下均不得将本项目的作者、贡献者或其他相关方与使用者的使用行为联系起来,或要求其对使用者使用本项目所产生的任何损失或损害负责。\n"
"5.使用者在使用本项目的代码和功能时,必须自行研究相关法律法规,并确保其使用行为合法合规。任何因违反法律法规而导致的法律责任和风险,均由使用者自行承担。\n"
"6.本项目的作者不会提供 XHS-Downloader 项目的付费版本,也不会提供与 XHS-Downloader 项目相关的任何商业服务。\n"
"7.基于本项目进行的任何二次开发、修改或编译的程序与原创作者无关,原创作者不承担与二次开发行为或其结果相关的任何责任,使用者应自行对因二次开发可能带来的各种情况负全部责任。\n"
"\n"
"在使用本项目的代码和功能之前,请您认真考虑并接受以上免责声明。如果您对上述声明有任何疑问或不同意,请不要使用本项目的代码和功能。如果您使用了本项目的代码和功能,则视为您已完全理解并接受上述免责声明,并自愿承担使用本项目的一切风险和后果。\n"
msgid "提取作品文件下载地址失败"
msgstr ""
msgid "提取小红书作品链接失败"
msgstr ""
msgid "未输入任何小红书作品链接"
msgstr ""
msgid "下载小红书作品文件失败"
msgstr ""
msgid "正在检查新版本,请稍等..."
msgstr ""
msgid "当前版本为开发版, 可更新至正式版"
msgstr ""
msgid "当前已是最新开发版"
msgstr ""
msgid "当前已是最新正式版"
msgstr ""
msgid "检测新版本失败"
msgstr ""
msgid "开源协议"
msgstr ""
msgid "项目地址"
msgstr ""
msgid "请输入小红书图文/视频作品链接"
msgstr ""
msgid "多个链接之间使用空格分隔"
msgstr ""
msgid "下载无水印作品文件"
msgstr ""
msgid "读取剪贴板"
msgstr ""
msgid "清空输入框"
msgstr ""
msgid "退出程序"
msgstr ""
msgid "检查更新"
msgstr ""
msgid "程序设置"
msgstr ""
msgid "作品数据 / 文件保存根路径"
msgstr ""
msgid "作品文件储存文件夹名称"
msgstr ""
msgid "小红书网页版 Cookie"
msgstr ""
msgid "网络代理"
msgstr ""
msgid "记录作品数据"
msgstr ""
msgid "图片下载格式"
msgstr ""
msgid "作品文件夹归档模式"
msgstr ""
msgid "程序语言"
msgstr ""
msgid "启动本地服务器"
msgstr ""
msgid "程序根路径"
msgstr ""
msgid "小红书网页版 Cookie无需登录参数已设置"
msgstr ""
msgid "小红书网页版 Cookie无需登录参数未设置"
msgstr ""
msgid "默认 User-Agent"
msgstr ""
msgid "不使用代理"
msgstr ""
msgid "保存配置"
msgstr ""
msgid "放弃更改"
msgstr ""
msgid "程序处理中..."
msgstr ""
msgid "已启动监听剪贴板模式"
msgstr ""
msgid "程序会自动读取并提取剪贴板中的小红书作品链接,并自动下载链接对应的作品文件,如需关闭,请点击关闭按钮,或者向剪贴板写入 “close” 文本!"
msgstr ""
msgid "退出监听剪贴板模式"
msgstr ""
msgid "请输入待删除的小红书作品链接或作品 ID"
msgstr ""
msgid "支持输入作品 ID 或包含作品 ID 的作品链接,多个链接或 ID 之间使用空格分隔"
msgstr ""
msgid "删除指定作品 ID"
msgstr ""
msgid "返回首页"
msgstr ""
msgid "小红书作品链接"
msgstr ""
msgid "下载指定序号的图片文件,仅对图文作品生效;多个序号输入示例:\"1 3 5 7\""
msgstr ""
msgid "小红书网页版 Cookie无需登录"
msgstr ""
msgid "请求数据超时限制,单位:秒"
msgstr ""
msgid "下载文件时,每次从服务器获取的数据块大小,单位:字节"
msgstr ""
msgid "请求数据失败时,重试的最大次数"
msgstr ""
msgid "是否记录作品数据至文件"
msgstr ""
msgid "图文作品文件下载格式支持PNG、WEBP"
msgstr ""
msgid "是否将每个作品的文件储存至单独的文件夹"
msgstr ""
msgid "设置程序语言目前支持zh_CN、en_GB"
msgstr ""
msgid "读取指定配置文件"
msgstr ""
msgid "是否更新配置文件"
msgstr ""
msgid "查看详细参数说明"
msgstr ""
msgid "网络异常,请求 {0} 失败"
msgstr ""
msgid "{0} 文件已存在,跳过下载"
msgstr ""
msgid "文件 {0} 下载成功"
msgstr ""
msgid "网络异常,{0} 下载失败"
msgstr ""
msgid "共 {0} 个小红书作品待处理..."
msgstr ""
msgid "开始处理作品:{0}"
msgstr ""
msgid "{0} 获取数据失败"
msgstr ""
msgid "{0} 提取数据失败"
msgstr ""
msgid "作品处理完成:{0}"
msgstr ""
msgid "检测到新版本:{0}.{1}"
msgstr ""
msgid "作品 {0} 存在下载记录,跳过下载" msgid "作品 {0} 存在下载记录,跳过下载"
msgstr "" msgstr ""
msgid "从指定的浏览器读取小红书网页版 Cookie需要关闭对应的浏览器支持1 Chrome, 2 Chromium, 3 Opera, 4 Opera GX, 5 Brave, 6 Edge, 7 Vivaldi, 8 Firefox, 9 LibreWolf, 10 Safari输入浏览器类型或序号" #: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:198
msgid "提取作品文件下载地址失败"
msgstr "" msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:228
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:255
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:598
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:785
msgid "提取小红书作品链接失败"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:230
#, python-brace-format
msgid "共 {0} 个小红书作品待处理..."
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:317
#, python-brace-format
msgid "作品 {0} 存在下载记录,跳过处理"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:320
#, python-brace-format
msgid "开始处理作品:{0}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:329
#, python-brace-format
msgid "{0} 获取数据失败"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:334
#, python-brace-format
msgid "{0} 提取数据失败"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:336
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:83
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\explore.py:79
msgid "视频"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:339
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:91
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\explore.py:80
msgid "图文"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:340
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:92
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\explore.py:79
msgid "图集"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:344
#, python-brace-format
msgid "未知的作品类型:{0}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:349
#, python-brace-format
msgid "作品处理完成:{0}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:427
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\monitor.py:57
msgid ""
"程序会自动读取并提取剪贴板中的小红书作品链接,并自动下载链接对应的作品文件,"
"如需关闭,请点击关闭按钮,或者向剪贴板写入 “close” 文本!"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:569
msgid "跳转至项目 GitHub 仓库"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:570
msgid "重定向至项目 GitHub 仓库主页"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:578
msgid "获取作品数据及下载地址"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:610
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:795
msgid "获取小红书作品数据成功"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:612
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:797
msgid "获取小红书作品数据失败"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:682
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:727
msgid "小红书作品链接"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:730
msgid "指定需要下载的图文作品序号"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:734
msgid "是否需要返回作品信息数据"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:748
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:753
msgid "作品文件下载任务执行完毕"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:758
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\app.py:763
msgid "作品文件下载任务未执行"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:133
msgid "视频作品下载功能已关闭,跳过下载"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:150
msgid "图文作品下载功能已关闭,跳过下载"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:185
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:196
#, python-brace-format
msgid "{0} 文件已存在,跳过下载"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:242
#, python-brace-format
msgid "文件 {0} 缓存异常,重新下载"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:270
#, python-brace-format
msgid "文件 {0} 下载成功"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:276
#, python-brace-format
msgid "网络异常,{0} 下载失败,错误信息: {1}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\download.py:353
#, python-brace-format
msgid "文件 {0} 格式判断失败,错误信息:{1}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\explore.py:53
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\explore.py:58
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\explore.py:77
msgid "未知"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\application\request.py:65
#, python-brace-format
msgid "网络异常,{0} 请求失败: {1}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:124
msgid "小红书作品链接,多个链接使用空格分隔"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:131
msgid ""
"下载指定序号的图片文件,仅对图文/图集作品生效;多个序号输入示例:\"1 3 5 7\""
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:136
msgid "作品数据/文件保存根路径"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:137
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:40
msgid "作品文件储存文件夹名称"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:138
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:49
msgid "作品文件名称格式"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:140
msgid "小红书网页版 Cookie无需登录"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:141
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:78
msgid "网络代理"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:142
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:88
msgid "请求数据超时限制,单位:秒"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:148
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:98
msgid "下载文件时,每次从服务器获取的数据块大小,单位:字节"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:151
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:108
msgid "请求数据失败时,重试的最大次数"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:152
msgid "是否记录作品数据至文件"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:157
msgid "图文作品文件下载格式支持PNG、WEBP"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:159
msgid "动态图片下载开关"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:160
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:149
msgid "作品下载记录开关"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:165
msgid "是否将每个作品的文件储存至单独的文件夹"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:171
msgid "是否将每个作者的作品储存至单独的文件夹"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:178
msgid "是否将作品文件的修改时间属性修改为作品的发布时间"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:182
msgid "设置程序语言目前支持zh_CN、en_US"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:183
msgid "读取指定配置文件"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:190
#, python-brace-format
msgid "从指定的浏览器读取小红书网页版 Cookie支持{0}; 输入浏览器名称或序号"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:203
msgid "是否更新配置文件"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:204
msgid "查看详细参数说明"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\CLI\main.py:205
msgid "查看 XHS-Downloader 版本" msgid "查看 XHS-Downloader 版本"
msgstr "" msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\expansion\browser.py:53
#, python-brace-format
msgid ""
"读取指定浏览器的 Cookie 并写入配置文件\n"
"Windows 系统需要以管理员身份运行程序才能读取 Chromium、Chrome、Edge 浏览器 "
"Cookie\n"
"{options}\n"
"请输入浏览器名称或序号:"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\expansion\browser.py:63
msgid "未选择浏览器!"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\expansion\browser.py:75
msgid "浏览器名称或序号输入错误!"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\expansion\browser.py:81
msgid "获取 Cookie 失败,未找到 Cookie 数据!"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\expansion\browser.py:119
msgid "从浏览器读取 Cookie 功能不支持当前平台!"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\expansion\cleaner.py:45
msgid "不受支持的操作系统类型,可能无法正常去除非法字符!"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\manager.py:232
#, python-brace-format
msgid "代理 {0} 测试成功"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\manager.py:236
#, python-brace-format
msgid "代理 {0} 测试超时"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\manager.py:244
#, python-brace-format
msgid "代理 {0} 测试失败:{1}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:57
#, python-brace-format
msgid "{old_folder} 文件夹不存在,跳过处理"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:86
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:108
msgid "文件夹"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:91
#, python-brace-format
msgid "文件夹 {old_folder} 已重命名为 {new_folder}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:113
#, python-brace-format
msgid "文件夹 {old_} 重命名为 {new_}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:186
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:201
msgid "文件"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:191
#, python-brace-format
msgid "文件 {old_file} 重命名为 {new_file}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:210
#, python-brace-format
msgid "{type} {old}被占用,重命名失败: {error}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:219
#, python-brace-format
msgid "{type} {new}名称重复,重命名失败: {error}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\mapping.py:228
#, python-brace-format
msgid "处理{type} {old}时发生预期之外的错误: {error}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\module\tools.py:31
msgid ""
"如需重新尝试处理该对象,请关闭所有正在访问该对象的窗口或程序,然后直接按下回"
"车键!\n"
"如需跳过处理该对象,请输入任意字符后按下回车键!"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:20
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:29
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\monitor.py:21
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:15
msgid "退出程序"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:21
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:30
msgid "检查更新"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:22
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\record.py:35
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:16
msgid "返回首页"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:35
msgid "如果 XHS-Downloader 对您有帮助,请考虑为它点个 Star感谢您的支持" msgid "如果 XHS-Downloader 对您有帮助,请考虑为它点个 Star感谢您的支持"
msgstr "" msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:42
msgid "Discord 社区"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:46
msgid "邀请链接:"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:48
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:61
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:70
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:56
msgid "点击访问"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\about.py:51
msgid "作者的其他开源项目" msgid "作者的其他开源项目"
msgstr "" msgstr ""
msgid "文件 {0} 请求失败,响应码 {1}" #: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:31
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:212
msgid "程序设置"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:32
msgid "下载记录"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:33
msgid "开启监听"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:34
msgid "关于项目"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:49
msgid "开源协议: "
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:52
msgid "项目地址: "
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:59
msgid "请输入小红书图文/视频作品链接"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:62
msgid "多个链接之间使用空格分隔"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:64
msgid "下载无水印作品文件"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:65
msgid "读取剪贴板"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:66
msgid "清空输入框"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:81
msgid "免责声明\n"
msgstr ""
"关于 XHS-Downloader 的 免责声明:\n"
"\n"
"1.使用者对本项目的使用由使用者自行决定,并自行承担风险。作者对使用者使用本项"
"目所产生的任何损失、责任、或风险概不负责。\n"
"2.本项目的作者提供的代码和功能是基于现有知识和技术的开发成果。作者按现有技术"
"水平努力确保代码的正确性和安全性,但不保证代码完全没有错误或缺陷。\n"
"3.本项目依赖的所有第三方库、插件或服务各自遵循其原始开源或商业许可,使用者需"
"自行查阅并遵守相应协议,作者不对第三方组件的稳定性、安全性及合规性承担任何责"
"任。\n"
"4.使用者在使用本项目时必须严格遵守 GNU General Public License v3.0 的要求,"
"并在适当的地方注明使用了 GNU General Public License v3.0 的代码。\n"
"5.使用者在使用本项目的代码和功能时,必须自行研究相关法律法规,并确保其使用行"
"为合法合规。任何因违反法律法规而导致的法律责任和风险,均由使用者自行承担。\n"
"6.使用者不得使用本工具从事任何侵犯知识产权的行为,包括但不限于未经授权下载、"
"传播受版权保护的内容,开发者不参与、不支持、不认可任何非法内容的获取或分"
"发。\n"
"7.本项目不对使用者涉及的数据收集、存储、传输等处理活动的合规性承担责任。使用"
"者应自行遵守相关法律法规,确保处理行为合法正当;因违规操作导致的法律责任由使"
"用者自行承担。\n"
"8.使用者在任何情况下均不得将本项目的作者、贡献者或其他相关方与使用者的使用行"
"为联系起来,或要求其对使用者使用本项目所产生的任何损失或损害负责。\n"
"9.本项目的作者不会提供 XHS-Downloader 项目的付费版本,也不会提供与 XHS-"
"Downloader 项目相关的任何商业服务。\n"
"10.基于本项目进行的任何二次开发、修改或编译的程序与原创作者无关,原创作者不"
"承担与二次开发行为或其结果相关的任何责任,使用者应自行对因二次开发可能带来的"
"各种情况负全部责任。\n"
"11.本项目不授予使用者任何专利许可;若使用本项目导致专利纠纷或侵权,使用者自"
"行承担全部风险和责任。未经作者或权利人书面授权,不得使用本项目进行任何商业宣"
"传、推广或再授权。\n"
"12.作者保留随时终止向任何违反本声明的使用者提供服务的权利,并可能要求其销毁"
"已获取的代码及衍生作品。\n"
"13.作者保留在不另行通知的情况下更新本声明的权利,使用者持续使用即视为接受修"
"订后的条款。\n"
"\n"
"在使用本项目的代码和功能之前,请您认真考虑并接受以上免责声明。如果您对上述声"
"明有任何疑问或不同意,请不要使用本项目的代码和功能。如果您使用了本项目的代码"
"和功能,则视为您已完全理解并接受上述免责声明,并自愿承担使用本项目的一切风险"
"和后果。\n"
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:94
msgid "未输入任何小红书作品链接"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\index.py:124
msgid "下载小红书作品文件失败"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\loading.py:19
msgid "程序处理中..."
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\monitor.py:22
msgid "关闭监听"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\monitor.py:34
msgid "已启动监听剪贴板模式"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\monitor.py:36
msgid "退出监听剪贴板模式"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\record.py:23
msgid "请输入待删除的小红书作品链接或作品 ID"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\record.py:26
msgid ""
"支持输入作品 ID 或包含作品 ID 的作品链接,多个链接或 ID 之间使用空格分隔"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\record.py:32
msgid "删除指定作品 ID"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\record.py:47
msgid "删除下载记录成功"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:30
msgid "作品数据 / 文件保存根路径"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:35
msgid "程序根路径"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:64
msgid "内置 Chrome User Agent"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:69
msgid "小红书网页版 Cookie"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:83
msgid "不使用代理"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:120
msgid "记录作品详细数据"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:125
msgid "作品归档保存模式"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:130
msgid "视频作品下载开关"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:135
msgid "图文作品下载开关"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:144
msgid "动图文件下载开关"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:154
msgid "作者归档保存模式"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:159
msgid "更新文件修改时间"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:167
msgid "图片下载格式"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:171
msgid "程序语言"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:194
msgid "保存配置"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:198
msgid "放弃更改"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:208
msgid "小红书网页版 Cookie无需登录参数已设置"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\setting.py:209
msgid "小红书网页版 Cookie无需登录参数未设置"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\update.py:26
msgid "正在检查新版本,请稍等..."
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\update.py:46
#, python-brace-format
msgid "检测到新版本:{0}.{1}"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\update.py:54
msgid "当前版本为开发版, 可更新至正式版"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\update.py:59
msgid "当前已是最新开发版"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\update.py:64
msgid "当前已是最新正式版"
msgstr ""
#: C:\Users\You\PycharmProjects\XHS-Downloader\source\TUI\update.py:71
msgid "检测新版本失败"
msgstr "" msgstr ""

94
main.py
View File

@ -1,59 +1,59 @@
from asyncio import run from asyncio import run
from asyncio.exceptions import CancelledError
from contextlib import suppress
from sys import argv from sys import argv
from source import Settings
from source import XHS from source import XHS
from source import XHSDownloader from source import XHSDownloader
from source import cli from source import cli
async def example(): async def app():
"""通过代码设置参数,适合二次开发"""
# 示例链接
error_link = "https://github.com/JoeanAmier/XHS_Downloader"
demo_link = "https://www.xiaohongshu.com/explore/xxxxxxxxxx"
multiple_links = f"{demo_link} {demo_link} {demo_link}"
# 实例对象
work_path = "D:\\" # 作品数据/文件保存根路径,默认值:项目根路径
folder_name = "Download" # 作品文件储存文件夹名称自动创建默认值Download
user_agent = "" # 请求头 User-Agent可选参数
cookie = "" # 小红书网页版 Cookie无需登录必需参数
proxy = None # 网络代理
timeout = 5 # 请求数据超时限制单位默认值10
chunk = 1024 * 1024 * 10 # 下载文件时,每次从服务器获取的数据块大小,单位:字节
max_retry = 2 # 请求数据失败时重试的最大次数单位默认值5
record_data = False # 是否保存作品数据至文件
image_format = "WEBP" # 图文作品文件下载格式支持PNG、WEBP
folder_mode = False # 是否将每个作品的文件储存至单独的文件夹
async with XHS() as xhs:
pass # 使用默认参数
async with XHS(work_path=work_path,
folder_name=folder_name,
user_agent=user_agent,
cookie=cookie,
proxy=proxy,
timeout=timeout,
chunk=chunk,
max_retry=max_retry,
record_data=record_data,
image_format=image_format,
folder_mode=folder_mode,
) as xhs: # 使用自定义参数
download = True # 是否下载作品文件默认值False
# 返回作品详细信息,包括下载地址
# 获取数据失败时返回空字典
print(await xhs.extract(error_link, download, ))
print(await xhs.extract(demo_link, download, ))
# 支持传入多个作品链接
print(await xhs.extract(multiple_links, download, ))
async def main():
async with XHSDownloader() as xhs: async with XHSDownloader() as xhs:
await xhs.run_async() await xhs.run_async()
if __name__ == '__main__': async def api_server(
if len(argv) > 1: host="0.0.0.0",
cli() port=5556,
else: log_level="info",
run(main()) ):
async with XHS(**Settings().run()) as xhs:
await xhs.run_api_server(
host,
port,
log_level,
)
async def mcp_server(
transport="streamable-http",
host="0.0.0.0",
port=5556,
log_level="INFO",
):
async with XHS(**Settings().run()) as xhs:
await xhs.run_mcp_server(
transport=transport,
host=host,
port=port,
log_level=log_level,
)
if __name__ == "__main__":
with suppress(
KeyboardInterrupt,
CancelledError,
):
# TODO: 重构优化
if len(argv) == 1:
run(app())
elif argv[1].upper() == "API":
run(api_server())
elif argv[1].upper() == "MCP":
run(mcp_server())
# run(mcp_server("stdio"))
else:
cli()

117
pyproject.toml Normal file
View File

@ -0,0 +1,117 @@
[project]
name = "XHS-Downloader"
version = "2.7"
description = "小红书XiaoHongShu、RedNote链接提取/作品采集工具:提取账号发布、收藏、点赞、专辑作品链接;提取搜索结果作品、用户链接;采集小红书作品信息;提取小红书作品下载地址;下载小红书无水印作品文件"
authors = [
{ name = "JoeanAmier", email = "yonglelolu@foxmail.com" },
]
readme = "README.md"
license = "GPL-3.0"
requires-python = ">=3.12,<3.13"
dependencies = [
"aiofiles>=25.1.0",
"aiosqlite>=0.21.0",
"click>=8.3.1",
"emoji>=2.15.0",
"fastapi>=0.124.2",
"fastmcp>=2.14.0",
"httpx[socks]>=0.28.1",
"lxml>=6.0.2",
"pyperclip>=1.11.0",
"pyyaml>=6.0.3",
"rookiepy>=0.5.6",
"textual>=6.8.0",
"uvicorn>=0.38.0",
"websockets>=15.0.1",
]
[project.urls]
Repository = "https://github.com/JoeanAmier/XHS-Downloader"
[tool.uv.pip]
index-url = "https://mirrors.ustc.edu.cn/pypi/simple"
[tool.ruff]
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]
# Same as Black.
line-length = 88
indent-width = 4
# Assume Python 3.12
target-version = "py312"
[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E4", "E7", "E9", "F"]
ignore = []
# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"
# Like Black, indent with spaces, rather than tabs.
indent-style = "space"
# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false
# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"
# Enable auto-formatting of code examples in docstrings. Markdown,
# reStructuredText code/literal blocks and doctests are all supported.
#
# This is currently disabled by default, but it is planned for this
# to be opt-out in the future.
docstring-code-format = false
# Set the line length limit used when formatting code snippets in
# docstrings.
#
# This only has an effect when the `docstring-code-format` setting is
# enabled.
docstring-code-line-length = "dynamic"
[dependency-groups]
dev = [
"pyinstaller>=6.17.0",
"textual-dev>=1.7.0",
]

View File

@ -1,8 +1,30 @@
aiohttp>=3.9.1 # This file was autogenerated by uv via the following command:
textual>=0.47.1 # uv pip compile pyproject.toml --no-deps --no-strip-extras -o requirements.txt
pyperclip>=1.8.2 aiofiles==25.1.0
lxml>=5.1.0 # via xhs-downloader (pyproject.toml)
PyYAML>=6.0.1 aiosqlite==0.21.0
aiosqlite>=0.20.0 # via xhs-downloader (pyproject.toml)
click>=8.1.7 click==8.3.1
browser_cookie3>=0.19.1 # via xhs-downloader (pyproject.toml)
emoji==2.15.0
# via xhs-downloader (pyproject.toml)
fastapi==0.124.2
# via xhs-downloader (pyproject.toml)
fastmcp>=2.14.0
# via xhs-downloader (pyproject.toml)
httpx[socks]==0.28.1
# via xhs-downloader (pyproject.toml)
lxml==6.0.2
# via xhs-downloader (pyproject.toml)
pyperclip==1.11.0
# via xhs-downloader (pyproject.toml)
pyyaml==6.0.3
# via xhs-downloader (pyproject.toml)
rookiepy==0.5.6
# via xhs-downloader (pyproject.toml)
textual==6.8.0
# via xhs-downloader (pyproject.toml)
uvicorn==0.38.0
# via xhs-downloader (pyproject.toml)
websockets==15.0.1
# via xhs-downloader (pyproject.toml)

View File

@ -23,7 +23,7 @@ from source.module import (
PROJECT, PROJECT,
) )
from source.module import Settings from source.module import Settings
from source.module import Translate from source.translation import switch_language, _
__all__ = ["cli"] __all__ = ["cli"]
@ -39,15 +39,17 @@ def check_value(function):
class CLI: class CLI:
def __init__(self, ctx: Context, **kwargs): def __init__(self, ctx: Context, **kwargs):
# print(kwargs)
self.ctx = ctx self.ctx = ctx
self.url = kwargs.pop("url") self.url = ctx.params.pop("url")
self.index = self.__format_index(kwargs.pop("index")) self.index = self.__format_index(ctx.params.pop("index"))
self.path = kwargs.pop("settings") self.path = ctx.params.pop("settings")
self.update = kwargs.pop("update_settings") self.update = ctx.params.pop("update_settings")
# print(kwargs)
self.settings = Settings(self.__check_settings_path()) self.settings = Settings(self.__check_settings_path())
self.parameter = self.settings.run() | self.__clean_params(kwargs) self.parameter = (
self.settings.run()
| self.__clean_params(ctx.params)
| {"script_server": False}
)
self.APP = XHS(**self.parameter) self.APP = XHS(**self.parameter)
async def __aenter__(self): async def __aenter__(self):
@ -101,41 +103,107 @@ class CLI:
@staticmethod @staticmethod
@check_value @check_value
def read_cookie(ctx: Context, param, value) -> str: def read_cookie(ctx: Context, param, value) -> str:
if len(value) == 1: return BrowserCookie.get(
value = int(value) value,
return BrowserCookie.get(value, domain="xiaohongshu.com") domains=[
"xiaohongshu.com",
],
)
@staticmethod @staticmethod
@check_value @check_value
def help_(ctx: Context, param, value) -> None: def help_(ctx: Context, param, value) -> None:
_ = Translate("").message()
table = Table(highlight=True, box=None, show_header=True) table = Table(highlight=True, box=None, show_header=True)
# 添加表格的列名 # 添加表格的列名
table.add_column("parameter", no_wrap=True, style="bold") table.add_column("parameter", no_wrap=True, style="bold")
table.add_column("abbreviation", no_wrap=True, style="bold") table.add_column("abbreviation", no_wrap=True, style="bold")
table.add_column("type", no_wrap=True, style="bold") table.add_column("type", no_wrap=True, style="bold")
table.add_column("description", no_wrap=True, ) table.add_column(
"description",
no_wrap=True,
)
options = ( options = (
("--url", "-u", "str", _("小红书作品链接")), ("--url", "-u", "str", _("小红书作品链接,多个链接使用空格分隔")),
("--index", "-i", "str", _("下载指定序号的图片文件,仅对图文作品生效;多个序号输入示例:\"1 3 5 7\"")), (
("--work_path", "-wp", "str", _("作品数据 / 文件保存根路径")), "--index",
"-i",
"str",
fill(
_(
'下载指定序号的图片文件,仅对图文/图集作品生效;多个序号输入示例:"1 3 5 7"'
),
width=55,
),
),
("--work_path", "-wp", "str", _("作品数据/文件保存根路径")),
("--folder_name", "-fn", "str", _("作品文件储存文件夹名称")), ("--folder_name", "-fn", "str", _("作品文件储存文件夹名称")),
("--user_agent", "-ua", "str", _("User-Agent")), ("--name_format", "-nf", "str", _("作品文件名称格式")),
("--user_agent", "-ua", "str", "User-Agent"),
("--cookie", "-ck", "str", _("小红书网页版 Cookie无需登录")), ("--cookie", "-ck", "str", _("小红书网页版 Cookie无需登录")),
("--proxy", "-p", "str", _("网络代理")), ("--proxy", "-p", "str", _("网络代理")),
("--timeout", "-t", "int", _("请求数据超时限制,单位:秒")), ("--timeout", "-t", "int", _("请求数据超时限制,单位:秒")),
("--chunk", "-c", "int", _("下载文件时,每次从服务器获取的数据块大小,单位:字节")), (
"--chunk",
"-c",
"int",
fill(
_("下载文件时,每次从服务器获取的数据块大小,单位:字节"), width=55
),
),
("--max_retry", "-mr", "int", _("请求数据失败时,重试的最大次数")), ("--max_retry", "-mr", "int", _("请求数据失败时,重试的最大次数")),
("--record_data", "-rd", "bool", _("是否记录作品数据至文件")), ("--record_data", "-rd", "bool", _("是否记录作品数据至文件")),
("--image_format", "-if", "choice", _("图文作品文件下载格式支持PNG、WEBP")), (
("--folder_mode", "-fm", "bool", _("是否将每个作品的文件储存至单独的文件夹")), "--image_format",
("--language", "-l", "choice", _("设置程序语言目前支持zh_CN、en_GB")), "-if",
"choice",
_("图文作品文件下载格式支持PNG、WEBP"),
),
("--live_download", "-ld", "bool", _("动态图片下载开关")),
("--download_record", "-dr", "bool", _("作品下载记录开关")),
(
"--folder_mode",
"-fm",
"bool",
_("是否将每个作品的文件储存至单独的文件夹"),
),
(
"--author_archive",
"-aa",
"bool",
_("是否将每个作者的作品储存至单独的文件夹"),
),
(
"--write_mtime",
"-wm",
"bool",
fill(
_("是否将作品文件的修改时间属性修改为作品的发布时间"),
width=55,
),
),
("--language", "-l", "choice", _("设置程序语言目前支持zh_CN、en_US")),
("--settings", "-s", "str", _("读取指定配置文件")), ("--settings", "-s", "str", _("读取指定配置文件")),
("--browser_cookie", "-bc", "choice", (
fill(_("从指定的浏览器读取小红书网页版 Cookie需要关闭对应的浏览器支持1 Chrome, 2 Chromium, 3 Opera, 4 Opera GX, " "--browser_cookie",
"5 Brave, 6 Edge, 7 Vivaldi, 8 Firefox, 9 LibreWolf, 10 Safari输入浏览器类型或序号"), width=45)), "-bc",
"choice",
fill(
_(
"从指定的浏览器读取小红书网页版 Cookie支持{0}; 输入浏览器名称或序号"
).format(
", ".join(
f"{i}: {j}"
for i, j in enumerate(
BrowserCookie.SUPPORT_BROWSER.keys(),
start=1,
)
)
),
width=55,
),
),
("--update_settings", "-us", "flag", _("是否更新配置文件")), ("--update_settings", "-us", "flag", _("是否更新配置文件")),
("--help", "-h", "flag", _("查看详细参数说明")), ("--help", "-h", "flag", _("查看详细参数说明")),
("--version", "-v", "flag", _("查看 XHS-Downloader 版本")), ("--version", "-v", "flag", _("查看 XHS-Downloader 版本")),
@ -149,49 +217,155 @@ class CLI:
table, table,
border_style="bold", border_style="bold",
title="XHS-Downloader CLI Parameters", title="XHS-Downloader CLI Parameters",
title_align="left")) title_align="left",
ctx.exit() )
)
@command(name="XHS-Downloader", help=PROJECT) @command(name="XHS-Downloader", help=PROJECT)
@option("--url", "-u", ) @option(
@option("--index", "-i", ) "--url",
@option("--work_path", "-u",
"-wp", )
type=Path(file_okay=False), @option(
) "--index",
@option("--folder_name", "-fn", ) "-i",
@option("--user_agent", "-ua", ) )
@option("--cookie", "-ck", ) @option(
@option("--proxy", "-p", ) "--work_path",
@option("--timeout", "-t", type=int, ) "-wp",
@option("--chunk", "-c", type=int, ) type=Path(file_okay=False),
@option("--max_retry", "-mr", type=int, ) )
@option("--record_data", "-rd", type=bool, ) @option(
@option("--image_format", "-if", type=Choice(["png", "PNG", "webp", "WEBP"]), ) "--folder_name",
@option("--folder_mode", "-fm", type=bool, ) "-fn",
@option("--language", "-l", )
type=Choice(["zh_CN", "en_GB"]), ) @option(
@option("--settings", "-s", type=Path(dir_okay=False), ) "--name_format",
@option("--browser_cookie", "-bc", "-nf",
type=Choice(list(BrowserCookie.SUPPORT_BROWSER.keys()) + [str(i) for i in range(1, 11)]), )
callback=CLI.read_cookie, ) @option(
@option("--update_settings", "-us", type=bool, "--user_agent",
is_flag=True, ) "-ua",
@option("-h", )
is_flag=True, @option(
is_eager=True, "--cookie",
expose_value=False, "-ck",
callback=CLI.help_, ) )
@option("--version", "-v", @option(
is_flag=True, "--proxy",
is_eager=True, "-p",
expose_value=False, )
callback=CLI.version, ) @option(
"--timeout",
"-t",
type=int,
)
@option(
"--chunk",
"-c",
type=int,
)
@option(
"--max_retry",
"-mr",
type=int,
)
@option(
"--record_data",
"-rd",
type=bool,
)
@option(
"--image_format",
"-if",
type=Choice(["png", "PNG", "webp", "WEBP"]),
)
@option(
"--live_download",
"-ld",
type=bool,
)
@option(
"--download_record",
"-dr",
type=bool,
)
@option(
"--folder_mode",
"-fm",
type=bool,
)
@option(
"--author_archive",
"-aa",
type=bool,
)
@option(
"--write_mtime",
"-wm",
type=bool,
)
@option(
"--language",
"-l",
type=Choice(["zh_CN", "en_US"]),
)
@option(
"--settings",
"-s",
type=Path(dir_okay=False),
)
@option(
"--browser_cookie",
"-bc",
type=Choice(
list(BrowserCookie.SUPPORT_BROWSER.keys())
+ [str(i) for i in range(1, len(BrowserCookie.SUPPORT_BROWSER) + 1)]
),
callback=CLI.read_cookie,
)
@option(
"--update_settings",
"-us",
type=bool,
is_flag=True,
)
@option(
"-h",
"--help",
is_flag=True,
)
@option(
"--version",
"-v",
is_flag=True,
is_eager=True,
expose_value=False,
callback=CLI.version,
)
@pass_context @pass_context
def cli(ctx, **kwargs): def cli(ctx, help, language, **kwargs):
# Step 1: 切换语言
if language:
switch_language(language)
# Step 2: 如果请求了帮助信息,则显示帮助并退出
if help:
ctx.obj = kwargs # 保留当前上下文的参数
CLI.help_(ctx, None, help)
return
# Step 3: 主逻辑
async def main(): async def main():
async with CLI(ctx, **kwargs) as xhs: async with CLI(ctx, **kwargs) as xhs:
await xhs.run() await xhs.run()
run(main()) run(main())
if __name__ == "__main__":
from click.testing import CliRunner
runner = CliRunner()
result = runner.invoke(cli, ["-l", "en_US", "-u", ""])

View File

@ -1,3 +1,3 @@
from .app import XHSDownloader from .app import XHSDownloader
__all__ = ['XHSDownloader'] __all__ = ["XHSDownloader"]

View File

@ -1,53 +1,84 @@
from typing import Callable
from rich.text import Text from rich.text import Text
from textual.app import ComposeResult from textual.app import ComposeResult
from textual.binding import Binding from textual.binding import Binding
from textual.screen import Screen from textual.screen import Screen
from textual.widgets import Footer from textual.widgets import Footer, Header, Label, Link
from textual.widgets import Header
from textual.widgets import Label
from source.module import ( from ..module import (
INFO,
MASTER,
PROJECT, PROJECT,
PROMPT, PROMPT,
MASTER,
INFO,
) )
from ..translation import _
__all__ = ["About"] __all__ = ["About"]
class About(Screen): class About(Screen):
BINDINGS = [ BINDINGS = [
Binding( Binding(key="Q", action="quit", description=_("退出程序")),
key="q", Binding(key="U", action="update", description=_("检查更新")),
action="quit", Binding(key="B", action="back", description=_("返回首页")),
description="退出程序/Quit"),
Binding(
key="u",
action="check_update_about",
description="检查更新/Update"),
Binding(
key="b",
action="index",
description="返回首页/Back"),
] ]
def __init__(self, message: Callable[[str], str]): def __init__(
self,
):
super().__init__() super().__init__()
self.message = message
def compose(self) -> ComposeResult: def compose(self) -> ComposeResult:
yield Header() yield Header()
yield Label(Text(self.message("如果 XHS-Downloader 对您有帮助,请考虑为它点个 Star感谢您的支持"), style=INFO), yield Label(
classes="prompt", ) Text(
yield Label(Text(self.message("作者的其他开源项目"), style=PROMPT), classes="prompt", ) _(
yield Label(Text("TikTokDownloader (抖音 / TikTok)", style=MASTER), classes="prompt", ) "如果 XHS-Downloader 对您有帮助,请考虑为它点个 Star感谢您的支持"
yield Label("https://github.com/JoeanAmier/TikTokDownloader") ),
yield Label(Text("KS-Downloader (快手)", style=MASTER), classes="prompt", ) style=INFO,
yield Label("https://github.com/JoeanAmier/KS-Downloader") ),
classes="prompt",
)
yield Label(
Text(_("Discord 社区"), style=PROMPT),
classes="prompt",
)
yield Link(
_("邀请链接:") + "https://discord.com/invite/ZYtmgKud9Y",
url="https://discord.com/invite/ZYtmgKud9Y",
tooltip=_("点击访问"),
)
yield Label(
Text(_("作者的其他开源项目"), style=PROMPT),
classes="prompt",
)
yield Label(
Text("DouK-Downloader (抖音 / TikTok)", style=MASTER),
classes="prompt",
)
yield Link(
"https://github.com/JoeanAmier/TikTokDownloader",
url="https://github.com/JoeanAmier/TikTokDownloader",
tooltip=_("点击访问"),
)
yield Label(
Text("KS-Downloader (快手)", style=MASTER),
classes="prompt",
)
yield Link(
"https://github.com/JoeanAmier/KS-Downloader",
url="https://github.com/JoeanAmier/KS-Downloader",
tooltip=_("点击访问"),
)
yield Footer() yield Footer()
def on_mount(self) -> None: def on_mount(self) -> None:
self.title = PROJECT self.title = PROJECT
async def action_quit(self) -> None:
await self.app.action_quit()
async def action_back(self) -> None:
await self.app.action_back()
async def action_update(self):
await self.app.run_action("update")

View File

@ -1,18 +1,13 @@
from typing import Callable
from textual.app import App from textual.app import App
from textual.widgets import RichLog
from source.application import XHS from ..application import XHS
from source.module import ( from ..module import (
ROOT, ROOT,
Settings,
) )
from source.module import Settings
from source.module import Translate
from .about import About from .about import About
from .index import Index from .index import Index
from .loading import Loading from .loading import Loading
from .monitor import Monitor
from .record import Record from .record import Record
from .setting import Setting from .setting import Setting
from .update import Update from .update import Update
@ -21,13 +16,12 @@ __all__ = ["XHSDownloader"]
class XHSDownloader(App): class XHSDownloader(App):
CSS_PATH = ROOT.joinpath("static/XHS-Downloader.tcss") CSS_PATH = ROOT.parent.joinpath("static/XHS-Downloader.tcss")
SETTINGS = Settings(ROOT) SETTINGS = Settings(ROOT)
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.parameter: dict self.parameter: dict
self.message: Callable[[str], str]
self.APP: XHS self.APP: XHS
self.__initialization() self.__initialization()
@ -40,19 +34,33 @@ class XHSDownloader(App):
def __initialization(self) -> None: def __initialization(self) -> None:
self.parameter = self.SETTINGS.run() self.parameter = self.SETTINGS.run()
self.message = Translate(self.parameter["language"]).message() self.APP = XHS(
self.APP = XHS(**self.parameter, transition=self.message) **self.parameter,
_print=False,
)
async def on_mount(self) -> None: async def on_mount(self) -> None:
self.theme = "nord"
self.install_screen( self.install_screen(
Setting( Setting(
self.parameter, self.parameter,
self.message), ),
name="setting") name="setting",
self.install_screen(Index(self.APP, self.message), name="index") )
self.install_screen(Loading(self.message), name="loading") self.install_screen(
self.install_screen(About(self.message), name="about") Index(
self.install_screen(Record(self.APP, self.message), name="record") self.APP,
),
name="index",
)
self.install_screen(Loading(), name="loading")
self.install_screen(About(), name="about")
self.install_screen(
Record(
self.APP,
),
name="record",
)
await self.push_screen("index") await self.push_screen("index")
async def action_settings(self): async def action_settings(self):
@ -62,51 +70,53 @@ class XHSDownloader(App):
await self.push_screen("setting", save_settings) await self.push_screen("setting", save_settings)
async def action_about(self):
await self.push_screen("about")
async def action_index(self):
await self.push_screen("index")
async def action_record(self):
await self.push_screen("record")
async def refresh_screen(self): async def refresh_screen(self):
self.pop_screen() await self.action_back()
await self.close_database() await self.close_database()
await self.APP.close() await self.APP.close()
self.__initialization() self.__initialization()
await self.__aenter__() await self.__aenter__()
await self.APP.switch_script_server()
self.uninstall_screen("index") self.uninstall_screen("index")
self.uninstall_screen("setting") self.uninstall_screen("setting")
self.uninstall_screen("loading") self.uninstall_screen("loading")
self.uninstall_screen("about") self.uninstall_screen("about")
self.uninstall_screen("record") self.uninstall_screen("record")
self.install_screen(Index(self.APP, self.message), name="index") self.install_screen(
Index(
self.APP,
),
name="index",
)
self.install_screen( self.install_screen(
Setting( Setting(
self.parameter, self.parameter,
self.message), ),
name="setting") name="setting",
self.install_screen(Loading(self.message), name="loading") )
self.install_screen(About(self.message), name="about") self.install_screen(Loading(), name="loading")
self.install_screen(Record(self.APP, self.message), name="record") self.install_screen(About(), name="about")
self.install_screen(
Record(
self.APP,
),
name="record",
)
await self.push_screen("index") await self.push_screen("index")
def update_result(self, tip: str) -> None: def update_result(self, args: tuple[str, str]) -> None:
log = self.query_one(RichLog) self.notify(
log.write(tip) args[0],
log.write(">" * 50) severity=args[1],
)
async def action_check_update(self): async def action_update(self):
await self.push_screen(Update(self.APP, self.message), callback=self.update_result) await self.push_screen(
Update(
async def action_check_update_about(self): self.APP,
await self.push_screen("index") ),
await self.action_check_update() callback=self.update_result,
)
async def action_monitor(self):
await self.push_screen(Monitor(self.APP, self.message))
async def close_database(self): async def close_database(self):
await self.APP.id_recorder.cursor.close() await self.APP.id_recorder.cursor.close()

View File

@ -1,100 +1,102 @@
from typing import Callable
from pyperclip import paste from pyperclip import paste
from rich.text import Text from rich.text import Text
from textual import on from textual import on, work
from textual import work
from textual.app import ComposeResult from textual.app import ComposeResult
from textual.binding import Binding from textual.binding import Binding
from textual.containers import HorizontalScroll from textual.containers import HorizontalScroll, ScrollableContainer
from textual.containers import ScrollableContainer
from textual.screen import Screen from textual.screen import Screen
from textual.widgets import Button from textual.widgets import Button, Footer, Header, Input, Label, Link, RichLog
from textual.widgets import Footer
from textual.widgets import Header
from textual.widgets import Input
from textual.widgets import Label
from textual.widgets import RichLog
from source.application import XHS from ..application import XHS
from source.module import ( from ..module import (
ERROR,
GENERAL,
LICENCE,
MASTER,
PROJECT, PROJECT,
PROMPT, PROMPT,
MASTER,
ERROR,
WARNING,
LICENCE,
REPOSITORY, REPOSITORY,
GENERAL, WARNING,
) )
from ..translation import _
from .monitor import Monitor
__all__ = ["Index"] __all__ = ["Index"]
class Index(Screen): class Index(Screen):
BINDINGS = [ BINDINGS = [
Binding(key="q", action="quit", description="退出程序/Quit"), Binding(key="Q", action="quit", description=_("退出程序")),
Binding(key="u", action="check_update", description="检查更新/Update"), Binding(key="U", action="update", description=_("检查更新")),
Binding(key="s", action="settings", description="程序设置/Settings"), Binding(key="S", action="settings", description=_("程序设置")),
Binding(key="r", action="record", description="下载记录/Record"), Binding(key="R", action="record", description=_("下载记录")),
Binding(key="m", action="monitor", description="开启监听/Monitor"), Binding(key="M", action="monitor", description=_("开启监听")),
Binding(key="a", action="about", description="关于项目/About"), Binding(key="A", action="about", description=_("关于项目")),
] ]
def __init__(self, app: XHS, message: Callable[[str], str]): def __init__(
self,
app: XHS,
):
super().__init__() super().__init__()
self.xhs = app self.xhs = app
self.message = message
self.url = None self.url = None
self.tip = None self.tip = None
def compose(self) -> ComposeResult: def compose(self) -> ComposeResult:
yield Header() yield Header()
yield ScrollableContainer( yield ScrollableContainer(
Label( Label(Text(_("开源协议: ") + LICENCE, style=MASTER)),
Link(
Text( Text(
f"{self.message("开源协议")}: {LICENCE}", _("项目地址: ") + REPOSITORY,
style=MASTER) style=MASTER,
),
url=REPOSITORY,
tooltip=_("点击访问"),
), ),
Label( Label(
Text( Text(_("请输入小红书图文/视频作品链接"), style=PROMPT),
f"{self.message("项目地址")}{REPOSITORY}", classes="prompt",
style=MASTER)
), ),
Label( Input(placeholder=_("多个链接之间使用空格分隔")),
Text(
self.message("请输入小红书图文/视频作品链接"),
style=PROMPT), classes="prompt",
),
Input(placeholder=self.message("多个链接之间使用空格分隔")),
HorizontalScroll( HorizontalScroll(
Button(self.message("下载无水印作品文件"), id="deal"), Button(_("下载无水印作品文件"), id="deal"),
Button(self.message("读取剪贴板"), id="paste"), Button(_("读取剪贴板"), id="paste"),
Button(self.message("清空输入框"), id="reset"), Button(_("清空输入框"), id="reset"),
), ),
) )
yield RichLog(markup=True, wrap=True) yield RichLog(
markup=True,
wrap=True,
auto_scroll=True,
)
yield Footer() yield Footer()
def on_mount(self) -> None: def on_mount(self) -> None:
self.title = PROJECT self.title = PROJECT
self.url = self.query_one(Input) self.url = self.query_one(Input)
self.tip = self.query_one(RichLog) self.tip = self.query_one(RichLog)
self.xhs.print.func = self.tip
self.tip.write( self.tip.write(
Text( Text(_("免责声明\n") + f"\n{'>' * 50}", style=MASTER),
self.message("免责声明\n") + scroll_end=True,
f"\n{ )
">" * self.xhs.manager.print_proxy_tip()
50}",
style=MASTER), scroll_end=False)
@on(Button.Pressed, "#deal") @on(Button.Pressed, "#deal")
async def deal_button(self): async def deal_button(self):
if self.url.value: if self.url.value:
self.deal() self.deal()
else: else:
self.tip.write(Text(self.message("未输入任何小红书作品链接"), style=WARNING)) self.tip.write(
self.tip.write(Text(">" * 50, style=GENERAL)) Text(_("未输入任何小红书作品链接"), style=WARNING),
scroll_end=True,
)
self.tip.write(
Text(">" * 50, style=GENERAL),
scroll_end=True,
)
@on(Button.Pressed, "#reset") @on(Button.Pressed, "#reset")
def reset_button(self): def reset_button(self):
@ -104,12 +106,47 @@ class Index(Screen):
def paste_button(self): def paste_button(self):
self.query_one(Input).value = paste() self.query_one(Input).value = paste()
@work() @work(exclusive=True)
async def deal(self): async def deal(self):
await self.app.push_screen("loading") await self.app.push_screen("loading")
if any(await self.xhs.extract(self.url.value, True, log=self.tip)): if any(
await self.xhs.extract(
self.url.value,
True,
data=False,
)
):
self.url.value = "" self.url.value = ""
else: else:
self.tip.write(Text(self.message("下载小红书作品文件失败"), style=ERROR)) self.tip.write(
self.tip.write(Text(">" * 50, style=GENERAL)) Text(_("下载小红书作品文件失败"), style=ERROR),
self.app.pop_screen() animate=True,
scroll_end=True,
)
self.tip.write(
Text(">" * 50, style=GENERAL),
scroll_end=True,
)
await self.app.action_back()
async def action_quit(self) -> None:
await self.app.action_quit()
async def action_update(self) -> None:
await self.app.run_action("update")
async def action_settings(self):
await self.app.run_action("settings")
async def action_monitor(self):
await self.app.push_screen(
Monitor(
self.xhs,
)
)
async def action_about(self):
await self.app.push_screen("about")
async def action_record(self):
await self.app.push_screen("record")

View File

@ -1,22 +1,22 @@
from typing import Callable
from textual.app import ComposeResult from textual.app import ComposeResult
from textual.containers import Grid from textual.containers import Grid
from textual.screen import ModalScreen from textual.screen import ModalScreen
from textual.widgets import Label from textual.widgets import Label, LoadingIndicator
from textual.widgets import LoadingIndicator
from ..translation import _
__all__ = ["Loading"] __all__ = ["Loading"]
class Loading(ModalScreen): class Loading(ModalScreen):
def __init__(self, message: Callable[[str], str]): def __init__(
self,
):
super().__init__() super().__init__()
self.message = message
def compose(self) -> ComposeResult: def compose(self) -> ComposeResult:
yield Grid( yield Grid(
Label(self.message("程序处理中...")), Label(_("程序处理中...")),
LoadingIndicator(), LoadingIndicator(),
classes="loading", classes="loading",
) )

View File

@ -1,62 +1,58 @@
from typing import Callable
from rich.text import Text from rich.text import Text
from textual import on from textual import on, work
from textual import work
from textual.app import ComposeResult from textual.app import ComposeResult
from textual.binding import Binding from textual.binding import Binding
from textual.screen import Screen from textual.screen import Screen
from textual.widgets import Button from textual.widgets import Button, Footer, Header, Label, RichLog
from textual.widgets import Footer
from textual.widgets import Header
from textual.widgets import Label
from textual.widgets import RichLog
from source.application import XHS from ..application import XHS
from source.module import ( from ..module import (
PROJECT,
MASTER,
INFO, INFO,
PROJECT,
) )
from ..translation import _
__all__ = ["Monitor"] __all__ = ["Monitor"]
class Monitor(Screen): class Monitor(Screen):
BINDINGS = [ BINDINGS = [
Binding(key="q", action="quit", description="退出程序/Quit"), Binding(key="Q", action="quit", description=_("退出程序")),
Binding(key="c", action="close", description="关闭监听/Close"), Binding(key="C", action="close", description=_("关闭监听")),
] ]
def __init__(self, app: XHS, message: Callable[[str], str]): def __init__(
self,
app: XHS,
):
super().__init__() super().__init__()
self.xhs = app self.xhs = app
self.message = message
def compose(self) -> ComposeResult: def compose(self) -> ComposeResult:
yield Header() yield Header()
yield Label(Text(self.message("已启动监听剪贴板模式"), style=INFO), classes="prompt") yield Label(Text(_("已启动监听剪贴板模式"), style=INFO), classes="prompt")
yield RichLog(markup=True, wrap=True) yield RichLog(markup=True, wrap=True)
yield Button(self.message("退出监听剪贴板模式"), id="close") yield Button(_("退出监听剪贴板模式"), id="close")
yield Footer() yield Footer()
@on(Button.Pressed, "#close") @on(Button.Pressed, "#close")
def close_button(self): async def close_button(self):
self.action_close() await self.action_close()
@work() @work(exclusive=True)
async def run_monitor(self): async def run_monitor(self):
await self.xhs.monitor(download=True, log=self.query_one(RichLog)) await self.xhs.monitor()
self.action_close() await self.action_close()
def on_mount(self) -> None: def on_mount(self) -> None:
self.title = PROJECT self.title = PROJECT
self.query_one(RichLog).write( self.xhs.print.func = self.query_one(RichLog)
Text(self.message(
"程序会自动读取并提取剪贴板中的小红书作品链接,并自动下载链接对应的作品文件,如需关闭,请点击关闭按钮,或者向剪贴板写入 “close” 文本!"),
style=MASTER))
self.run_monitor() self.run_monitor()
def action_close(self): async def action_close(self):
self.xhs.stop_monitor() self.xhs.stop_monitor()
self.app.pop_screen() await self.app.action_back()
async def action_quit(self) -> None:
await self.action_close()
await self.app.action_quit()

View File

@ -1,39 +1,49 @@
from typing import Callable
from textual import on from textual import on
from textual.app import ComposeResult from textual.app import ComposeResult
from textual.containers import Grid from textual.containers import Grid, HorizontalScroll
from textual.containers import HorizontalScroll
from textual.screen import ModalScreen from textual.screen import ModalScreen
from textual.widgets import Button from textual.widgets import Button, Input, Label
from textual.widgets import Input
from textual.widgets import Label
from source.application import XHS from ..application import XHS
from ..translation import _
__all__ = ["Record"] __all__ = ["Record"]
class Record(ModalScreen): class Record(ModalScreen):
def __init__(
def __init__(self, app: XHS, message: Callable[[str], str]): self,
app: XHS,
):
super().__init__() super().__init__()
self.xhs = app self.xhs = app
self.message = message
def compose(self) -> ComposeResult: def compose(self) -> ComposeResult:
yield Grid( yield Grid(
Label(self.message("请输入待删除的小红书作品链接或作品 ID"), classes="prompt"), Label(_("请输入待删除的小红书作品链接或作品 ID"), classes="prompt"),
Input(placeholder=self.message("支持输入作品 ID 或包含作品 ID 的作品链接,多个链接或 ID 之间使用空格分隔"), Input(
id="id", ), placeholder=_(
"支持输入作品 ID 或包含作品 ID 的作品链接,多个链接或 ID 之间使用空格分隔"
),
id="id",
),
HorizontalScroll( HorizontalScroll(
Button(self.message("删除指定作品 ID"), id="enter", ), Button(
Button(self.message("返回首页"), id="close"), ), _("删除指定作品 ID"),
id="enter",
),
Button(_("返回首页"), id="close"),
),
id="record", id="record",
) )
async def delete(self, text: str): async def delete(self, text: str):
text = await self.xhs.extract_links(
text,
)
text = self.xhs.extract_id(text)
await self.xhs.id_recorder.delete(text) await self.xhs.id_recorder.delete(text)
self.app.notify(_("删除下载记录成功"))
@on(Button.Pressed, "#enter") @on(Button.Pressed, "#enter")
async def save_settings(self): async def save_settings(self):

View File

View File

@ -1,105 +1,259 @@
from typing import Callable
from textual import on from textual import on
from textual.app import ComposeResult from textual.app import ComposeResult
from textual.binding import Binding from textual.binding import Binding
from textual.containers import Container from textual.containers import Container, ScrollableContainer
from textual.containers import ScrollableContainer
from textual.screen import Screen from textual.screen import Screen
from textual.widgets import Button from textual.widgets import Button, Checkbox, Footer, Header, Input, Label, Select
from textual.widgets import Checkbox
from textual.widgets import Footer from ..translation import _
from textual.widgets import Header
from textual.widgets import Input
from textual.widgets import Label
from textual.widgets import Select
__all__ = ["Setting"] __all__ = ["Setting"]
class Setting(Screen): class Setting(Screen):
BINDINGS = [ BINDINGS = [
Binding(key="q", action="quit", description="退出程序/Quit"), Binding(key="Q", action="quit", description=_("退出程序")),
Binding(key="b", action="index", description="返回首页/Back"), Binding(key="B", action="index", description=_("返回首页")),
] ]
def __init__(self, data: dict, message: Callable[[str], str]): def __init__(
self,
data: dict,
):
super().__init__() super().__init__()
self.data = data self.data = data
self.message = message
def compose(self) -> ComposeResult: def compose(self) -> ComposeResult:
yield Header() yield Header()
yield ScrollableContainer( yield ScrollableContainer(
Label(self.message("作品数据 / 文件保存根路径"), classes="params", ), Label(
Input(self.data["work_path"], placeholder=self.message("程序根路径"), valid_empty=True, _("作品数据 / 文件保存根路径"),
id="work_path", ), classes="params",
Label(self.message("作品文件储存文件夹名称"), classes="params", ), ),
Input(self.data["folder_name"], placeholder="Download", id="folder_name", ), Input(
Label(self.message("User-Agent"), classes="params", ), self.data["work_path"],
Input(self.data["user_agent"], placeholder=self.message("默认 User-Agent"), valid_empty=True, placeholder=_("程序根路径"),
id="user_agent", ), valid_empty=True,
Label(self.message("小红书网页版 Cookie"), classes="params", ), id="work_path",
Input(placeholder=self.__check_cookie(), valid_empty=True, id="cookie", ), ),
Label(self.message("网络代理"), classes="params", ), Label(
Input(self.data["proxy"], placeholder=self.message("不使用代理"), valid_empty=True, id="proxy", ), _("作品文件储存文件夹名称"),
Label(self.message("请求数据超时限制,单位:秒"), classes="params", ), classes="params",
Input(str(self.data["timeout"]), placeholder="10", type="integer", id="timeout", ), ),
Label(self.message("下载文件时,每次从服务器获取的数据块大小,单位:字节"), classes="params", ), Input(
Input(str(self.data["chunk"]), placeholder="1048576", type="integer", id="chunk", ), self.data["folder_name"],
Label(self.message("请求数据失败时,重试的最大次数"), classes="params", ), placeholder="Download",
Input(str(self.data["max_retry"]), placeholder="5", type="integer", id="max_retry", ), id="folder_name",
),
Label(
_("作品文件名称格式"),
classes="params",
),
Input(
self.data["name_format"],
placeholder="发布时间 作者昵称 作品标题",
valid_empty=True,
id="name_format",
),
Label(
"User-Agent",
classes="params",
),
Input(
self.data["user_agent"],
placeholder=_("内置 Chrome User Agent"),
valid_empty=True,
id="user_agent",
),
Label(
_("小红书网页版 Cookie"),
classes="params",
),
Input(
placeholder=self.__check_cookie(),
valid_empty=True,
id="cookie",
),
Label(
_("网络代理"),
classes="params",
),
Input(
self.data["proxy"],
placeholder=_("不使用代理"),
valid_empty=True,
id="proxy",
),
Label(
_("请求数据超时限制,单位:秒"),
classes="params",
),
Input(
str(self.data["timeout"]),
placeholder="10",
type="integer",
id="timeout",
),
Label(
_("下载文件时,每次从服务器获取的数据块大小,单位:字节"),
classes="params",
),
Input(
str(self.data["chunk"]),
placeholder="1048576",
type="integer",
id="chunk",
),
Label(
_("请求数据失败时,重试的最大次数"),
classes="params",
),
Input(
str(self.data["max_retry"]),
placeholder="5",
type="integer",
id="max_retry",
),
Label(),
Container( Container(
Label("", classes="params", ), Checkbox(
Label("", classes="params", ), _("记录作品详细数据"),
Label(self.message("图片下载格式"), classes="params", ), id="record_data",
Label(self.message("程序语言"), classes="params", ), value=self.data["record_data"],
),
Checkbox(
_("作品归档保存模式"),
id="folder_mode",
value=self.data["folder_mode"],
),
Checkbox(
_("视频作品下载开关"),
id="video_download",
value=self.data["video_download"],
),
Checkbox(
_("图文作品下载开关"),
id="image_download",
value=self.data["image_download"],
),
classes="horizontal-layout",
),
Label(),
Container(
Checkbox(
_("动图文件下载开关"),
id="live_download",
value=self.data["live_download"],
),
Checkbox(
_("作品下载记录开关"),
id="download_record",
value=self.data["download_record"],
),
Checkbox(
_("作者归档保存模式"),
id="author_archive",
value=self.data["author_archive"],
),
Checkbox(
_("更新文件修改时间"),
id="write_mtime",
value=self.data["write_mtime"],
),
classes="horizontal-layout",
),
Label(),
Container(
Checkbox(
_("脚本服务器开关"),
id="script_server",
value=self.data["script_server"],
),
classes="horizontal-layout", classes="horizontal-layout",
), ),
Container( Container(
Checkbox(self.message("记录作品数据"), id="record_data", value=self.data["record_data"], ), Label(
Checkbox(self.message("作品文件夹归档模式"), id="folder_mode", value=self.data["folder_mode"], ), _("图片下载格式"),
Select.from_values( classes="params",
("PNG", "WEBP"), ),
value=self.data["image_format"], Label(
allow_blank=False, _("程序语言"),
id="image_format"), classes="params",
Select.from_values(["zh_CN", "en_GB"], ),
value=self.data["language"], classes="horizontal-layout",
allow_blank=False, ),
id="language", ), Label(),
classes="horizontal-layout"),
Container( Container(
Button(self.message("保存配置"), id="save", ), Select.from_values(
Button(self.message("放弃更改"), id="abandon", ), ("AUTO", "PNG", "WEBP", "JPEG", "HEIC"),
classes="settings_button", ), value=self.data["image_format"].upper(),
allow_blank=False,
id="image_format",
),
Select.from_values(
["zh_CN", "en_US"],
value=self.data["language"],
allow_blank=False,
id="language",
),
classes="horizontal-layout",
),
Container(
Button(
_("保存配置"),
id="save",
),
Button(
_("放弃更改"),
id="abandon",
),
classes="settings_button",
),
) )
yield Footer() yield Footer()
def __check_cookie(self) -> str: def __check_cookie(self) -> str:
if self.data["cookie"]: if self.data["cookie"]:
return self.message("小红书网页版 Cookie无需登录参数已设置") return _("小红书网页版 Cookie无需登录参数已设置")
return self.message("小红书网页版 Cookie无需登录参数未设置") return _("小红书网页版 Cookie无需登录参数未设置")
def on_mount(self) -> None: def on_mount(self) -> None:
self.title = self.message("程序设置") self.title = _("程序设置")
@on(Button.Pressed, "#save") @on(Button.Pressed, "#save")
def save_settings(self): def save_settings(self):
self.dismiss({ self.dismiss(
"work_path": self.query_one("#work_path").value, {
"folder_name": self.query_one("#folder_name").value, "mapping_data": self.data.get("mapping_data", {}),
"user_agent": self.query_one("#user_agent").value, "work_path": self.query_one("#work_path").value,
"cookie": self.query_one("#cookie").value or self.data["cookie"], "folder_name": self.query_one("#folder_name").value,
"proxy": self.query_one("#proxy").value or None, "name_format": self.query_one("#name_format").value,
"timeout": int(self.query_one("#timeout").value), "user_agent": self.query_one("#user_agent").value,
"chunk": int(self.query_one("#chunk").value), "cookie": self.query_one("#cookie").value or self.data["cookie"],
"max_retry": int(self.query_one("#max_retry").value), "proxy": self.query_one("#proxy").value or None,
"record_data": self.query_one("#record_data").value, "timeout": int(self.query_one("#timeout").value),
"image_format": self.query_one("#image_format").value, "chunk": int(self.query_one("#chunk").value),
"folder_mode": self.query_one("#folder_mode").value, "max_retry": int(self.query_one("#max_retry").value),
"language": self.query_one("#language").value, "record_data": self.query_one("#record_data").value,
}) "image_format": self.query_one("#image_format").value,
"folder_mode": self.query_one("#folder_mode").value,
"language": self.query_one("#language").value,
"image_download": self.query_one("#image_download").value,
"video_download": self.query_one("#video_download").value,
"live_download": self.query_one("#live_download").value,
"download_record": self.query_one("#download_record").value,
"author_archive": self.query_one("#author_archive").value,
"write_mtime": self.query_one("#write_mtime").value,
"script_server": self.query_one("#script_server").value,
}
)
@on(Button.Pressed, "#abandon") @on(Button.Pressed, "#abandon")
def reset(self): def reset(self):
self.dismiss(self.data) self.dismiss(self.data)
async def action_quit(self) -> None:
await self.app.action_quit()
async def action_index(self):
await self.app.action_back()

View File

@ -1,65 +1,92 @@
from typing import Callable
from aiohttp import ClientTimeout
from rich.text import Text
from textual import work from textual import work
from textual.app import ComposeResult from textual.app import ComposeResult
from textual.containers import Grid from textual.containers import Grid
from textual.screen import ModalScreen from textual.screen import ModalScreen
from textual.widgets import Label from textual.widgets import Label, LoadingIndicator
from textual.widgets import LoadingIndicator
from source.application import XHS from ..application import XHS
from source.module import ( from ..module import (
VERSION_MAJOR,
VERSION_MINOR,
VERSION_BETA,
ERROR,
WARNING,
INFO,
RELEASES, RELEASES,
) )
from ..translation import _
__all__ = ["Update"] __all__ = ["Update"]
class Update(ModalScreen): class Update(ModalScreen):
def __init__(self, app: XHS, message: Callable[[str], str]): def __init__(
self,
app: XHS,
):
super().__init__() super().__init__()
self.xhs = app self.xhs = app
self.message = message
def compose(self) -> ComposeResult: def compose(self) -> ComposeResult:
yield Grid( yield Grid(
Label(self.message("正在检查新版本,请稍等...")), Label(_("正在检查新版本,请稍等...")),
LoadingIndicator(), LoadingIndicator(),
classes="loading", classes="loading",
) )
@work() @work(exclusive=True)
async def check_update(self) -> None: async def check_update(self) -> None:
try: try:
url = await self.xhs.html.request_url(RELEASES, False, None, timeout=ClientTimeout(connect=5)) url = await self.xhs.html.request_url(
latest_major, latest_minor = map( RELEASES,
int, url.split("/")[-1].split(".", 1)) False,
if latest_major > VERSION_MAJOR or latest_minor > VERSION_MINOR: timeout=5,
tip = Text(f"{self.message("检测到新版本:{0}.{1}").format( )
VERSION_MAJOR, VERSION_MINOR)}\n{RELEASES}", style=WARNING) version = url.split("/")[-1]
elif latest_minor == VERSION_MINOR and VERSION_BETA: match self.compare_versions(
tip = Text( f"{XHS.VERSION_MAJOR}.{XHS.VERSION_MINOR}", version, XHS.VERSION_BETA
f"{self.message("当前版本为开发版, 可更新至正式版")}\n{RELEASES}", ):
style=WARNING) case 4:
elif VERSION_BETA: args = (
tip = Text( _("检测到新版本:{0}.{1}").format(
self.message("当前已是最新开发版"), XHS.VERSION_MAJOR,
style=WARNING) XHS.VERSION_MINOR,
else: ),
tip = Text( "warning",
self.message("当前已是最新正式版"), )
style=INFO) case 3:
args = (
_("当前版本为开发版, 可更新至正式版"),
"warning",
)
case 2:
args = (
_("当前已是最新开发版"),
"warning",
)
case 1:
args = (
_("当前已是最新正式版"),
"information",
)
case _:
raise ValueError
except ValueError: except ValueError:
tip = Text(self.message("检测新版本失败"), style=ERROR) args = (
self.dismiss(tip) _("检测新版本失败"),
"error",
)
self.dismiss(args)
def on_mount(self) -> None: def on_mount(self) -> None:
self.check_update() self.check_update()
@staticmethod
def compare_versions(
current_version: str, target_version: str, is_development: bool
) -> int:
current_major, current_minor = map(int, current_version.split("."))
target_major, target_minor = map(int, target_version.split("."))
if target_major > current_major:
return 4
if target_major == current_major:
if target_minor > current_minor:
return 4
if target_minor == current_minor:
return 3 if is_development else 1
return 2

View File

@ -1,5 +1,11 @@
from .CLI import cli from .CLI import cli
from .TUI import XHSDownloader from .TUI import XHSDownloader
from .application import XHS from .application import XHS
from .module import Settings
__all__ = ['XHS', 'XHSDownloader', 'cli'] __all__ = [
"XHS",
"XHSDownloader",
"cli",
"Settings",
]

File diff suppressed because it is too large Load Diff

View File

@ -1,135 +1,279 @@
from asyncio import gather from asyncio import Semaphore, gather
from pathlib import Path from pathlib import Path
from typing import TYPE_CHECKING, Any
from aiohttp import ClientError from aiofiles import open
from httpx import HTTPError
from source.module import ERROR from ..expansion import CacheError
from source.module import Manager
from source.module import logging
from source.module import retry as re_download
__all__ = ['Download'] # from ..module import WARNING
from ..module import (
ERROR,
FILE_SIGNATURES,
FILE_SIGNATURES_LENGTH,
MAX_WORKERS,
logging,
# sleep_time,
)
from ..module import retry as re_download
from ..translation import _
if TYPE_CHECKING:
from httpx import AsyncClient
from ..module import Manager
__all__ = ["Download"]
class Download: class Download:
SEMAPHORE = Semaphore(MAX_WORKERS)
CONTENT_TYPE_MAP = { CONTENT_TYPE_MAP = {
"image/png": "png", "image/png": "png",
"image/jpeg": "jpg", "image/jpeg": "jpeg",
"image/webp": "webp", "image/webp": "webp",
"application/octet-stream": "", "video/mp4": "mp4",
"video/quicktime": "mov", "video/quicktime": "mov",
"audio/mp4": "m4a",
"audio/mpeg": "mp3",
} }
def __init__(self, manager: Manager, ): def __init__(
self,
manager: "Manager",
):
self.manager = manager self.manager = manager
self.print = manager.print
self.folder = manager.folder self.folder = manager.folder
self.temp = manager.temp self.temp = manager.temp
self.proxy = manager.proxy
self.chunk = manager.chunk self.chunk = manager.chunk
self.session = manager.download_session self.client: "AsyncClient" = manager.download_client
self.headers = manager.blank_headers
self.retry = manager.retry self.retry = manager.retry
self.message = manager.message
self.folder_mode = manager.folder_mode self.folder_mode = manager.folder_mode
self.video_format = "mp4" self.video_format = "mp4"
self.live_format = "mp4"
self.image_format = manager.image_format self.image_format = manager.image_format
self.image_format_list = (
"jpeg",
"png",
"webp",
"avif",
"heic",
)
self.image_download = manager.image_download
self.video_download = manager.video_download
self.live_download = manager.live_download
self.author_archive = manager.author_archive
self.write_mtime = manager.write_mtime
async def run(self, urls: list, index: list | tuple | None, name: str, type_: str, log, bar) -> tuple[Path, tuple]: async def run(
path = self.__generate_path(name) self,
match type_: urls: list,
case "视频": lives: list,
tasks = self.__ready_download_video(urls, path, name, log) index: list | tuple | None,
case "图文": nickname: str,
tasks = self.__ready_download_image( filename: str,
urls, index, path, name, log) type_: str,
case _: mtime: int,
raise ValueError ) -> tuple[Path, list[Any]]:
path = self.__generate_path(nickname, filename)
if type_ == _("视频"):
tasks = self.__ready_download_video(
urls,
path,
filename,
)
elif type_ in {
_("图文"),
_("图集"),
}:
tasks = self.__ready_download_image(
urls,
lives,
index,
path,
filename,
)
else:
raise ValueError
tasks = [ tasks = [
self.__download( self.__download(
url, url,
path, path,
name, name,
format_, format_,
log, mtime,
bar) for url, )
name, for url, name, format_ in tasks
format_ in tasks] ]
result = await gather(*tasks) tasks = await gather(*tasks)
return path, result return path, tasks # 未解之谜
def __generate_path(self, name: str): def __generate_path(self, nickname: str, filename: str):
path = self.manager.archive(self.folder, name, self.folder_mode) if self.author_archive:
folder = self.folder.joinpath(nickname)
folder.mkdir(exist_ok=True)
else:
folder = self.folder
path = self.manager.archive(folder, filename, self.folder_mode)
path.mkdir(exist_ok=True) path.mkdir(exist_ok=True)
return path return path
def __ready_download_video( def __ready_download_video(
self, self,
urls: list[str], urls: list[str],
path: Path, path: Path,
name: str, name: str,
log) -> list: ) -> list:
if any(path.glob(f"{name}.*")): if not self.video_download:
logging(log, self.message("{0} 文件已存在,跳过下载").format(name)) logging(self.print, _("视频作品下载功能已关闭,跳过下载"))
return []
if self.__check_exists_path(
path,
f"{name}.{self.video_format}",
):
return [] return []
return [(urls[0], name, self.video_format)] return [(urls[0], name, self.video_format)]
def __ready_download_image( def __ready_download_image(
self, self,
urls: list[str], urls: list[str],
index: list | tuple | None, lives: list[str],
path: Path, index: list | tuple | None,
name: str, path: Path,
log) -> list: name: str,
) -> list:
tasks = [] tasks = []
for i, j in enumerate(urls, start=1): if not self.image_download:
logging(self.print, _("图文作品下载功能已关闭,跳过下载"))
return tasks
for i, j in enumerate(zip(urls, lives), start=1):
if index and i not in index: if index and i not in index:
continue continue
file = f"{name}_{i}" file = f"{name}_{i}"
if any(path.glob(f"{file}.*")): if not any(
logging( self.__check_exists_path(
log, self.message( path,
"{0} 文件已存在,跳过下载").format(name)) f"{file}.{s}",
)
for s in self.image_format_list
):
tasks.append([j[0], file, self.image_format])
if (
not self.live_download
or not j[1]
or self.__check_exists_path(
path,
f"{file}.{self.live_format}",
)
):
continue continue
tasks.append([j, file, self.image_format]) tasks.append([j[1], file, self.live_format])
return tasks return tasks
@re_download def __check_exists_glob(
async def __download(self, url: str, path: Path, name: str, format_: str, log, bar): self,
try: path: Path,
async with self.session.get(url, proxy=self.proxy) as response: name: str,
if response.status != 200: ) -> bool:
logging( if any(path.glob(name)):
log, self.message("链接 {0} 请求失败,响应码 {1}").format( logging(self.print, _("{0} 文件已存在,跳过下载").format(name))
url, response.status), style=ERROR)
return False
suffix = self.__extract_type(
response.headers.get("Content-Type")) or format_
temp = self.temp.joinpath(name)
real = path.joinpath(f"{name}.{suffix}")
# self.__create_progress(
# bar, int(
# response.headers.get(
# 'content-length', 0)) or None)
with temp.open("wb") as f:
async for chunk in response.content.iter_chunked(self.chunk):
f.write(chunk)
# self.__update_progress(bar, len(chunk))
self.manager.move(temp, real)
# self.__create_progress(bar, None)
logging(log, self.message("文件 {0} 下载成功").format(name))
return True return True
except ClientError as error: return False
self.manager.delete(temp)
# self.__create_progress(bar, None) def __check_exists_path(
logging(log, str(error), ERROR) self,
logging( path: Path,
log, self.message( name: str,
"网络异常,{0} 下载失败").format(name), ERROR) ) -> bool:
return False if path.joinpath(name).exists():
logging(self.print, _("{0} 文件已存在,跳过下载").format(name))
return True
return False
@re_download
async def __download(
self,
url: str,
path: Path,
name: str,
format_: str,
mtime: int,
):
async with self.SEMAPHORE:
headers = self.headers.copy()
temp = self.temp.joinpath(f"{name}.{format_}")
self.__update_headers_range(
headers,
temp,
)
try:
async with self.client.stream(
"GET",
url,
headers=headers,
) as response:
# await sleep_time()
if response.status_code == 416:
raise CacheError(
_("文件 {0} 缓存异常,重新下载").format(temp.name),
)
response.raise_for_status()
# self.__create_progress(
# bar,
# int(
# response.headers.get(
# 'content-length', 0)) or None,
# )
async with open(temp, "ab") as f:
async for chunk in response.aiter_bytes(self.chunk):
await f.write(chunk)
# self.__update_progress(bar, len(chunk))
real = await self.__suffix_with_file(
temp,
path,
name,
# suffix,
format_,
)
self.manager.move(
temp,
real,
mtime,
self.write_mtime,
)
# self.__create_progress(bar, None)
logging(self.print, _("文件 {0} 下载成功").format(real.name))
return True
except HTTPError as error:
# self.__create_progress(bar, None)
logging(
self.print,
_("网络异常,{0} 下载失败,错误信息: {1}").format(
name, repr(error)
),
ERROR,
)
return False
except CacheError as error:
self.manager.delete(temp)
logging(
self.print,
str(error),
ERROR,
)
return False
@staticmethod @staticmethod
def __create_progress(bar, total: int | None): def __create_progress(
bar,
total: int | None,
completed=0,
):
if bar: if bar:
bar.update(total=total) bar.update(total=total, completed=completed)
@staticmethod @staticmethod
def __update_progress(bar, advance: int): def __update_progress(bar, advance: int):
@ -139,3 +283,55 @@ class Download:
@classmethod @classmethod
def __extract_type(cls, content: str) -> str: def __extract_type(cls, content: str) -> str:
return cls.CONTENT_TYPE_MAP.get(content, "") return cls.CONTENT_TYPE_MAP.get(content, "")
async def __head_file(
self,
url: str,
headers: dict[str, str],
suffix: str,
) -> tuple[int, str]:
"""未使用"""
response = await self.client.head(
url,
headers=headers,
)
# await sleep_time()
response.raise_for_status()
suffix = self.__extract_type(response.headers.get("Content-Type")) or suffix
length = response.headers.get("Content-Length", 0)
return int(length), suffix
@staticmethod
def __get_resume_byte_position(file: Path) -> int:
return file.stat().st_size if file.is_file() else 0
def __update_headers_range(
self,
headers: dict[str, str],
file: Path,
) -> int:
headers["Range"] = f"bytes={(p := self.__get_resume_byte_position(file))}-"
return p
async def __suffix_with_file(
self,
temp: Path,
path: Path,
name: str,
default_suffix: str,
) -> Path:
try:
async with open(temp, "rb") as f:
file_start = await f.read(FILE_SIGNATURES_LENGTH)
for offset, signature, suffix in FILE_SIGNATURES:
if file_start[offset : offset + len(signature)] == signature:
return path.joinpath(f"{name}.{suffix}")
except Exception as error:
logging(
self.print,
_("文件 {0} 格式判断失败,错误信息:{1}").format(
temp.name, repr(error)
),
ERROR,
)
return path.joinpath(f"{name}.{default_suffix}")

View File

@ -1,13 +1,13 @@
from datetime import datetime from datetime import datetime
from source.expansion import Namespace from ..expansion import Namespace
from ..translation import _
__all__ = ['Explore'] __all__ = ["Explore"]
class Explore: class Explore:
time_format = "%Y-%m-%d_%H:%M:%S" time_format = "%Y-%m-%d_%H:%M:%S"
explore_type = {"video": "视频", "normal": "图文"}
def run(self, data: Namespace) -> dict: def run(self, data: Namespace) -> dict:
return self.__extract_data(data) return self.__extract_data(data)
@ -24,10 +24,8 @@ class Explore:
@staticmethod @staticmethod
def __extract_interact_info(container: dict, data: Namespace) -> None: def __extract_interact_info(container: dict, data: Namespace) -> None:
container["收藏数量"] = data.safe_extract( container["收藏数量"] = data.safe_extract("interactInfo.collectedCount", "-1")
"interactInfo.collectedCount", "-1") container["评论数量"] = data.safe_extract("interactInfo.commentCount", "-1")
container["评论数量"] = data.safe_extract(
"interactInfo.commentCount", "-1")
container["分享数量"] = data.safe_extract("interactInfo.shareCount", "-1") container["分享数量"] = data.safe_extract("interactInfo.shareCount", "-1")
container["点赞数量"] = data.safe_extract("interactInfo.likedCount", "-1") container["点赞数量"] = data.safe_extract("interactInfo.likedCount", "-1")
@ -35,34 +33,48 @@ class Explore:
def __extract_tags(container: dict, data: Namespace): def __extract_tags(container: dict, data: Namespace):
tags = data.safe_extract("tagList", []) tags = data.safe_extract("tagList", [])
container["作品标签"] = " ".join( container["作品标签"] = " ".join(
Namespace.object_extract( Namespace.object_extract(i, "name") for i in tags
i, "name") for i in tags) )
def __extract_info(self, container: dict, data: Namespace): def __extract_info(self, container: dict, data: Namespace):
container["作品ID"] = data.safe_extract("noteId") container["作品ID"] = data.safe_extract("noteId")
container["作品链接"] = f"https://www.xiaohongshu.com/explore/{ container["作品链接"] = (
container["作品ID"]}" f"https://www.xiaohongshu.com/explore/{container['作品ID']}"
)
container["作品标题"] = data.safe_extract("title") container["作品标题"] = data.safe_extract("title")
container["作品描述"] = data.safe_extract("desc") container["作品描述"] = data.safe_extract("desc")
container["作品类型"] = self.explore_type.get( container["作品类型"] = self.__classify_works(data)
data.safe_extract("type"), "未知") # container["IP归属地"] = data.safe_extract("ipLocation")
container["IP归属地"] = data.safe_extract("ipLocation")
def __extract_time(self, container: dict, data: Namespace): def __extract_time(self, container: dict, data: Namespace):
container["发布时间"] = datetime.fromtimestamp( container["发布时间"] = (
time / datetime.fromtimestamp(time / 1000).strftime(self.time_format)
1000).strftime( if (time := data.safe_extract("time"))
self.time_format) if ( else _("未知")
time := data.safe_extract("time")) else "未知" )
container["最后更新时间"] = datetime.fromtimestamp( container["最后更新时间"] = (
last / datetime.fromtimestamp(last / 1000).strftime(self.time_format)
1000).strftime( if (last := data.safe_extract("lastUpdateTime"))
self.time_format) if ( else _("未知")
last := data.safe_extract("lastUpdateTime")) else "未知" )
container["时间戳"] = (
(time / 1000) if (time := data.safe_extract("time")) else None
)
@staticmethod @staticmethod
def __extract_user(container: dict, data: Namespace): def __extract_user(container: dict, data: Namespace):
container["作者昵称"] = data.safe_extract("user.nickname") container["作者昵称"] = data.safe_extract("user.nickname")
container["作者ID"] = data.safe_extract("user.userId") container["作者ID"] = data.safe_extract("user.userId")
container["作者链接"] = f"https://www.xiaohongshu.com/user/profile/{ container["作者链接"] = (
container["作者ID"]}" f"https://www.xiaohongshu.com/user/profile/{container['作者ID']}"
)
@staticmethod
def __classify_works(data: Namespace) -> str:
type_ = data.safe_extract("type")
list_ = data.safe_extract("imageList", [])
if type_ not in {"video", "normal"} or len(list_) == 0:
return _("未知")
if type_ == "video":
return _("视频") if len(list_) == 1 else _("图集")
return _("图文")

View File

@ -1,35 +1,60 @@
from source.expansion import Namespace from source.expansion import Namespace
from .request import Html from .request import Html
__all__ = ['Image'] __all__ = ["Image"]
class Image: class Image:
@classmethod @classmethod
def get_image_link(cls, data: Namespace, format_: str) -> list: def get_image_link(cls, data: Namespace, format_: str) -> tuple[list, list]:
images = data.safe_extract("imageList", []) images = data.safe_extract("imageList", [])
live_link = cls.__get_live_link(images)
token_list = [ token_list = [
cls.__extract_image_token( cls.__extract_image_token(Namespace.object_extract(i, "urlDefault"))
Namespace.object_extract( for i in images
i, "urlDefault")) for i in images] ]
match format_: match format_:
case "png": case "png" | "webp" | "jpeg" | "heic" | "avif":
return [Html.format_url(cls.__generate_png_link(i)) return [
for i in token_list] Html.format_url(
case "webp": cls.__generate_fixed_link(
return [Html.format_url(cls.__generate_webp_link(i)) i,
for i in token_list] format_,
)
)
for i in token_list
], live_link
case "auto":
return [
Html.format_url(cls.__generate_auto_link(i)) for i in token_list
], live_link
case _: case _:
raise ValueError raise ValueError
@staticmethod @staticmethod
def __generate_webp_link(token: str) -> str: def __generate_auto_link(token: str) -> str:
return f"https://sns-img-bd.xhscdn.com/{token}" return f"https://sns-img-bd.xhscdn.com/{token}"
@staticmethod @staticmethod
def __generate_png_link(token: str) -> str: def __generate_fixed_link(
return f"https://ci.xiaohongshu.com/{token}?imageView2/2/w/format/png" token: str,
format_: str,
) -> str:
return f"https://ci.xiaohongshu.com/{token}?imageView2/format/{format_}"
@staticmethod @staticmethod
def __extract_image_token(url: str) -> str: def __extract_image_token(url: str) -> str:
return "/".join(url.split("/")[5:]).split("!")[0] return "/".join(url.split("/")[5:]).split("!")[0]
@staticmethod
def __get_live_link(items: list) -> list:
return [
(
Html.format_url(
Namespace.object_extract(item, "stream.h264[0].masterUrl")
)
or None
)
for item in items
]

View File

@ -1,43 +1,137 @@
from aiohttp import ClientError from typing import TYPE_CHECKING
from source.module import ERROR from httpx import HTTPError
from source.module import Manager from httpx import get
from source.module import logging
from source.module import retry from ..module import ERROR, Manager, logging, retry, sleep_time
from ..translation import _
if TYPE_CHECKING:
from ..module import Manager
__all__ = ["Html"] __all__ = ["Html"]
class Html: class Html:
def __init__(self, manager: Manager, ): def __init__(
self.proxy = manager.proxy self,
manager: "Manager",
):
self.print = manager.print
self.retry = manager.retry self.retry = manager.retry
self.message = manager.message self.client = manager.request_client
self.session = manager.request_session self.headers = manager.headers
self.timeout = manager.timeout
@retry @retry
async def request_url( async def request_url(
self, self,
url: str, url: str,
content=True, content=True,
log=None, cookie: str = None,
**kwargs, proxy: str = None,
**kwargs,
) -> str: ) -> str:
if not url.startswith("http"):
url = f"https://{url}"
headers = self.update_cookie(
cookie,
)
try: try:
async with self.session.get( match bool(proxy):
url, case False:
proxy=self.proxy, response = await self.__request_url_get(
**kwargs, url,
) as response: headers,
if response.status != 200: **kwargs,
return "" )
return await response.text() if content else str(response.url) await sleep_time()
except ClientError as error: response.raise_for_status()
logging(log, str(error), ERROR) return response.text if content else str(response.url)
case True:
response = await self.__request_url_get_proxy(
url,
headers,
proxy,
**kwargs,
)
await sleep_time()
response.raise_for_status()
return response.text if content else str(response.url)
case _:
raise ValueError
except HTTPError as error:
logging( logging(
log, self.message("网络异常,请求 {0} 失败").format(url), ERROR) self.print,
_("网络异常,{0} 请求失败: {1}").format(url, repr(error)),
ERROR,
)
return "" return ""
@staticmethod @staticmethod
def format_url(url: str) -> str: def format_url(url: str) -> str:
return bytes(url, "utf-8").decode("unicode_escape") return bytes(url, "utf-8").decode("unicode_escape")
def update_cookie(
self,
cookie: str = None,
) -> dict:
return self.headers | {"Cookie": cookie} if cookie else self.headers.copy()
async def __request_url_head(
self,
url: str,
headers: dict,
**kwargs,
):
return await self.client.head(
url,
headers=headers,
**kwargs,
)
async def __request_url_head_proxy(
self,
url: str,
headers: dict,
proxy: str,
**kwargs,
):
return await self.client.head(
url,
headers=headers,
proxy=proxy,
follow_redirects=True,
verify=False,
timeout=self.timeout,
**kwargs,
)
async def __request_url_get(
self,
url: str,
headers: dict,
**kwargs,
):
return await self.client.get(
url,
headers=headers,
**kwargs,
)
async def __request_url_get_proxy(
self,
url: str,
headers: dict,
proxy: str,
**kwargs,
):
return get(
url,
headers=headers,
proxy=proxy,
follow_redirects=True,
verify=False,
timeout=self.timeout,
**kwargs,
)

View File

@ -1,7 +1,7 @@
from source.expansion import Namespace from source.expansion import Namespace
from .request import Html from .request import Html
__all__ = ['Video'] __all__ = ["Video"]
class Video: class Video:
@ -13,5 +13,8 @@ class Video:
@classmethod @classmethod
def get_video_link(cls, data: Namespace) -> list: def get_video_link(cls, data: Namespace) -> list:
return [Html.format_url(f"https://sns-video-hw.xhscdn.com/{t}")] if ( return (
t := data.safe_extract(".".join(cls.VIDEO_LINK))) else [] [Html.format_url(f"https://sns-video-bd.xhscdn.com/{t}")]
if (t := data.safe_extract(".".join(cls.VIDEO_LINK)))
else []
)

View File

@ -1,5 +1,10 @@
from .browser import BrowserCookie from .browser import BrowserCookie
from .cleaner import Cleaner
from .converter import Converter from .converter import Converter
from .error import CacheError
from .file_folder import file_switch
from .file_folder import remove_empty_directories
from .namespace import Namespace from .namespace import Namespace
from .truncate import beautify_string
__all__ = ["Converter", "Namespace", "BrowserCookie", ] from .truncate import trim_string
from .truncate import truncate_string

View File

@ -1,62 +1,119 @@
from browser_cookie3 import ( from contextlib import suppress
from sys import platform
from rich.console import Console
from rookiepy import (
arc,
brave,
chrome, chrome,
chromium, chromium,
opera,
opera_gx,
brave,
edge, edge,
vivaldi,
firefox, firefox,
librewolf, librewolf,
safari, opera,
BrowserCookieError, opera_gx,
vivaldi,
) )
try:
from source.translation import _
except ImportError:
_ = lambda s: s
__all__ = ["BrowserCookie"] __all__ = ["BrowserCookie"]
class BrowserCookie: class BrowserCookie:
SUPPORT_BROWSER = { SUPPORT_BROWSER = {
"chrome": chrome, "Arc": (arc, "Linux, macOS, Windows"),
"chromium": chromium, "Chrome": (chrome, "Linux, macOS, Windows"),
"opera": opera, "Chromium": (chromium, "Linux, macOS, Windows"),
"opera_gx": opera_gx, "Opera": (opera, "Linux, macOS, Windows"),
"brave": brave, "OperaGX": (opera_gx, "macOS, Windows"),
"edge": edge, "Brave": (brave, "Linux, macOS, Windows"),
"vivaldi": vivaldi, "Edge": (edge, "Linux, macOS, Windows"),
"firefox": firefox, "Vivaldi": (vivaldi, "Linux, macOS, Windows"),
"librewolf": librewolf, "Firefox": (firefox, "Linux, macOS, Windows"),
"safari": safari, "LibreWolf": (librewolf, "Linux, macOS, Windows"),
"Chrome": chrome,
"Chromium": chromium,
"Opera": opera,
"Opera_gx": opera_gx,
"Brave": brave,
"Edge": edge,
"Vivaldi": vivaldi,
"Firefox": firefox,
"Librewolf": librewolf,
"Safari": safari,
} }
@classmethod @classmethod
def get(cls, browser: str | int, domain: str) -> str: def run(
browser = cls.__browser_object(browser) cls,
domains: list[str],
console: Console = None,
) -> str | None:
console = console or Console()
options = "\n".join(
f"{i}. {k}: {v[1]}"
for i, (k, v) in enumerate(cls.SUPPORT_BROWSER.items(), start=1)
)
if browser := console.input(
_(
"读取指定浏览器的 Cookie 并写入配置文件\n"
"Windows 系统需要以管理员身份运行程序才能读取 Chromium、Chrome、Edge 浏览器 Cookie\n"
"{options}\n请输入浏览器名称或序号:"
).format(options=options),
):
return cls.get(
browser,
domains,
console,
)
console.print(_("未选择浏览器!"))
return None
@classmethod
def get(
cls,
browser: str | int,
domains: list[str],
console: Console = None,
) -> str:
console = console or Console()
if not (browser := cls.__browser_object(browser)):
console.print(_("浏览器名称或序号输入错误!"))
return ""
try: try:
cookie = browser(domain_name=domain) cookies = browser(domains=domains)
cookie = [f"{i.name}={i.value}" for i in cookie] return "; ".join(f"{i['name']}={i['value']}" for i in cookies)
return "; ".join(cookie) except RuntimeError:
except PermissionError: console.print(_("获取 Cookie 失败,未找到 Cookie 数据!"))
print("读取 Cookie 失败,浏览器未关闭!")
except BrowserCookieError:
print("获取 Cookie 失败,未找到 Cookie 数据!")
return "" return ""
@classmethod @classmethod
def __browser_object(cls, browser: str | int): def __browser_object(cls, browser: str | int):
with suppress(ValueError):
browser = int(browser) - 1
if isinstance(browser, int):
try:
return list(cls.SUPPORT_BROWSER.values())[browser][0]
except IndexError:
return None
if isinstance(browser, str): if isinstance(browser, str):
return cls.SUPPORT_BROWSER[browser] try:
elif isinstance(browser, int): return cls.__match_browser(browser)
return list(cls.SUPPORT_BROWSER.values())[browser - 1] except KeyError:
return None
raise TypeError raise TypeError
@classmethod
def __match_browser(cls, browser: str):
for i, j in cls.SUPPORT_BROWSER.items():
if i.lower() == browser.lower():
return j[0]
match platform:
case "darwin":
from rookiepy import safari
BrowserCookie.SUPPORT_BROWSER |= {
"Safari": (safari, "macOS"),
}
case "linux":
BrowserCookie.SUPPORT_BROWSER.pop("OperaGX")
case "win32":
pass
case _:
print(_("从浏览器读取 Cookie 功能不支持当前平台!"))

116
source/expansion/cleaner.py Normal file
View File

@ -0,0 +1,116 @@
from platform import system
from re import compile
from string import whitespace
from warnings import warn
from emoji import replace_emoji
try:
from source.translation import _
except ImportError:
_ = lambda s: s
class Cleaner:
CONTROL_CHARACTERS = compile(r"[\x00-\x1F\x7F]")
def __init__(self):
"""
替换字符串中包含的非法字符默认根据系统类型生成对应的非法字符字典也可以自行设置非法字符字典
"""
self.rule = self.default_rule() # 默认非法字符字典
@staticmethod
def default_rule():
"""根据系统类型生成默认非法字符字典"""
if (s := system()) in ("Windows", "Darwin"):
rule = {
"/": "",
"\\": "",
"|": "",
"<": "",
">": "",
'"': "",
"?": "",
":": "",
"*": "",
"\x00": "",
} # Windows 系统和 Mac 系统
elif s == "Linux":
rule = {
"/": "",
"\x00": "",
} # Linux 系统
else:
warn(_("不受支持的操作系统类型,可能无法正常去除非法字符!"))
rule = {}
cache = {i: "" for i in whitespace[1:]} # 补充换行符等非法字符
return rule | cache
def set_rule(self, rule: dict[str, str], update=True):
"""
设置非法字符字典
:param rule: 替换规则字典格式键为非法字符值为替换后的内容
:param update: 如果是 True则与原有规则字典合并否则替换原有规则字典
"""
self.rule = {**self.rule, **rule} if update else rule
def filter(self, text: str) -> str:
"""
去除非法字符
:param text: 待处理的字符串
:return: 替换后的字符串如果替换后字符串为空则返回 None
"""
for i in self.rule:
text = text.replace(i, self.rule[i])
return text
def filter_name(
self,
text: str,
replace: str = "",
default: str = "",
) -> str:
"""过滤文件夹名称中的非法字符"""
text = text.replace(":", ".")
text = self.remove_control_characters(text)
text = self.filter(text)
text = replace_emoji(
text,
replace,
)
text = self.clear_spaces(text)
text = text.strip().strip(".").strip("_")
return text or default
@staticmethod
def clear_spaces(string: str):
"""将连续的空格转换为单个空格"""
return " ".join(string.split())
@classmethod
def remove_control_characters(
cls,
text,
replace="",
):
# 使用正则表达式匹配所有控制字符
return cls.CONTROL_CHARACTERS.sub(
replace,
text,
)
if __name__ == "__main__":
demo = Cleaner()
print(demo.rule)
print(demo.filter_name(""))
print(demo.remove_control_characters("hello \x08world"))

View File

@ -7,7 +7,7 @@ __all__ = ["Converter"]
class Converter: class Converter:
INITIAL_STATE = "(//script)[last()]/text()" INITIAL_STATE = "//script/text()"
KEYS_LINK = ( KEYS_LINK = (
"note", "note",
"noteDetailMap", "noteDetailMap",
@ -16,22 +16,21 @@ class Converter:
) )
def run(self, content: str) -> dict: def run(self, content: str) -> dict:
return self.__filter_object( return self._filter_object(self._convert_object(self._extract_object(content)))
self.__convert_object(
self.__extract_object(content)))
def __extract_object(self, html: str) -> str: def _extract_object(self, html: str) -> str:
if not html: if not html:
return "" return ""
html_tree = HTML(html) html_tree = HTML(html)
return d[0] if (d := html_tree.xpath(self.INITIAL_STATE)) else "" scripts = html_tree.xpath(self.INITIAL_STATE)
return self.get_script(scripts)
@staticmethod @staticmethod
def __convert_object(text: str) -> dict: def _convert_object(text: str) -> dict:
return safe_load(text.lstrip("window.__INITIAL_STATE__=")) return safe_load(text.lstrip("window.__INITIAL_STATE__="))
@classmethod @classmethod
def __filter_object(cls, data: dict) -> dict: def _filter_object(cls, data: dict) -> dict:
return cls.deep_get(data, cls.KEYS_LINK) or {} return cls.deep_get(data, cls.KEYS_LINK) or {}
@classmethod @classmethod
@ -55,3 +54,11 @@ class Converter:
elif isinstance(data, list | tuple | set): elif isinstance(data, list | tuple | set):
return data[index] return data[index]
raise TypeError raise TypeError
@staticmethod
def get_script(scripts: list) -> str:
scripts.reverse()
for script in scripts:
if script.startswith("window.__INITIAL_STATE__"):
return script
return ""

View File

@ -0,0 +1,7 @@
class CacheError(Exception):
def __init__(self, message: str):
super().__init__(message)
self.message = message
def __str__(self):
return self.message

View File

@ -0,0 +1,25 @@
from contextlib import suppress
from pathlib import Path
def file_switch(path: Path) -> None:
if path.exists():
path.unlink()
else:
path.touch()
def remove_empty_directories(path: Path) -> None:
exclude = {
"\\.",
"\\_",
"\\__",
}
for dir_path, dir_names, file_names in path.walk(
top_down=False,
):
if any(i in str(dir_path) for i in exclude):
continue
if not dir_names and not file_names:
with suppress(OSError):
dir_path.rmdir()

View File

@ -14,7 +14,8 @@ class Namespace:
def depth_conversion(element): def depth_conversion(element):
if isinstance(element, dict): if isinstance(element, dict):
return SimpleNamespace( return SimpleNamespace(
**{k: depth_conversion(v) for k, v in element.items()}) **{k: depth_conversion(v) for k, v in element.items()}
)
elif isinstance(element, list): elif isinstance(element, list):
return [depth_conversion(item) for item in element] return [depth_conversion(item) for item in element]
else: else:
@ -23,16 +24,18 @@ class Namespace:
return depth_conversion(data) return depth_conversion(data)
def safe_extract( def safe_extract(
self, self,
attribute_chain: str, attribute_chain: str,
default: Union[str, int, list, dict, SimpleNamespace] = ""): default: Union[str, int, list, dict, SimpleNamespace] = "",
):
return self.__safe_extract(self.data, attribute_chain, default) return self.__safe_extract(self.data, attribute_chain, default)
@staticmethod @staticmethod
def __safe_extract( def __safe_extract(
data_object: SimpleNamespace, data_object: SimpleNamespace,
attribute_chain: str, attribute_chain: str,
default: Union[str, int, list, dict, SimpleNamespace] = "", ): default: Union[str, int, list, dict, SimpleNamespace] = "",
):
data = deepcopy(data_object) data = deepcopy(data_object)
attributes = attribute_chain.split(".") attributes = attribute_chain.split(".")
for attribute in attributes: for attribute in attributes:
@ -53,15 +56,16 @@ class Namespace:
@classmethod @classmethod
def object_extract( def object_extract(
cls, cls,
data_object: SimpleNamespace, data_object: SimpleNamespace,
attribute_chain: str, attribute_chain: str,
default: Union[str, int, list, dict, SimpleNamespace] = "", default: Union[str, int, list, dict, SimpleNamespace] = "",
): ):
return cls.__safe_extract( return cls.__safe_extract(
data_object, data_object,
attribute_chain, attribute_chain,
default, ) default,
)
@property @property
def __dict__(self): def __dict__(self):
@ -70,10 +74,11 @@ class Namespace:
@classmethod @classmethod
def convert_to_dict(cls, data) -> dict: def convert_to_dict(cls, data) -> dict:
return { return {
key: cls.convert_to_dict(value) if isinstance( key: cls.convert_to_dict(value)
value, if isinstance(value, SimpleNamespace)
SimpleNamespace) else value for key, else value
value in vars(data).items()} for key, value in vars(data).items()
}
def __bool__(self): def __bool__(self):
return bool(vars(self.data)) return bool(vars(self.data))

View File

@ -0,0 +1,88 @@
"""
PyInstaller runtime hook for beartype compatibility.
This runtime hook runs BEFORE any user code and patches beartype's import hook
system to be compatible with PyInstaller's frozen import mechanism.
The Problem:
-----------
Beartype's `beartype.claw` module installs a custom path hook into
`sys.path_hooks` that uses `SourceFileLoader` to load and transform Python
source files. In PyInstaller's frozen environment:
1. There are no source .py files - only compiled bytecode in a PYZ archive
2. Beartype's hook is prepended to `sys.path_hooks`, taking precedence over
PyInstaller's `PyiFrozenFinder`
3. Beartype clears `sys.path_importer_cache`, invalidating PyInstaller's
cached finders
This causes `ModuleNotFoundError` for any module imported AFTER beartype's
hook is installed.
The Fix:
--------
This runtime hook monkey-patches beartype's `add_beartype_pathhook` function
to detect PyInstaller's frozen environment and skip installing the problematic
path hook.
See Also:
---------
- https://github.com/beartype/beartype/issues/599
- https://github.com/pyinstaller/pyinstaller/issues/9324
"""
import sys
def _is_pyinstaller_frozen():
"""Check if running in a PyInstaller frozen environment."""
return getattr(sys, "frozen", False) or hasattr(sys, "_MEIPASS")
def _patch_beartype_claw():
"""
Patch beartype's add_beartype_pathhook to skip in frozen environments.
This patches the function at import time before any user code can call it.
"""
# Only patch if we're actually frozen
if not _is_pyinstaller_frozen():
return
try:
# Import the module containing the function to patch
from beartype.claw._importlib import clawimpmain
# Store the original function
_original_add_beartype_pathhook = clawimpmain.add_beartype_pathhook
def _patched_add_beartype_pathhook():
"""
Patched version of add_beartype_pathhook that skips in frozen env.
"""
if _is_pyinstaller_frozen():
# In frozen environment, skip installing the path hook entirely
# This prevents breaking PyInstaller's frozen import system
return
# Otherwise, call the original
return _original_add_beartype_pathhook()
# Replace the function in clawimpmain module
clawimpmain.add_beartype_pathhook = _patched_add_beartype_pathhook
# CRITICAL: Also patch clawpkgmain which does `from ... import add_beartype_pathhook`
# and thus has its own local reference to the original function
from beartype.claw._package import clawpkgmain
clawpkgmain.add_beartype_pathhook = _patched_add_beartype_pathhook
except ImportError:
# beartype not installed or not using claw module
pass
except Exception:
# Don't crash on patch failure
pass
# Apply the patch when this runtime hook is loaded
_patch_beartype_claw()

View File

@ -0,0 +1,35 @@
from unicodedata import name
def is_chinese_char(char: str) -> bool:
return "CJK" in name(char, "")
def truncate_string(s: str, length: int = 64) -> str:
count = 0
result = ""
for char in s:
count += 2 if is_chinese_char(char) else 1
if count > length:
break
result += char
return result
def trim_string(s: str, length: int = 64) -> str:
length = length // 2 - 2
return f"{s[:length]}...{s[-length:]}" if len(s) > length else s
def beautify_string(s: str, length: int = 64) -> str:
count = 0
for char in s:
count += 2 if is_chinese_char(char) else 1
if count > length:
break
else:
return s
length //= 2
start = truncate_string(s, length)
end = truncate_string(s[::-1], length)[::-1]
return f"{start}...{end}"

View File

@ -1,7 +1,13 @@
from .extend import Account from .extend import Account
from .manager import Manager from .manager import Manager
from .model import (
ExtractData,
ExtractParams,
)
from .recorder import DataRecorder from .recorder import DataRecorder
from .recorder import IDRecorder from .recorder import IDRecorder
from .recorder import MapRecorder
from .mapping import Mapping
from .settings import Settings from .settings import Settings
from .static import ( from .static import (
VERSION_MAJOR, VERSION_MAJOR,
@ -19,41 +25,18 @@ from .static import (
WARNING, WARNING,
INFO, INFO,
USERSCRIPT, USERSCRIPT,
USERAGENT,
HEADERS, HEADERS,
PROJECT, PROJECT,
USERAGENT,
FILE_SIGNATURES,
FILE_SIGNATURES_LENGTH,
MAX_WORKERS,
__VERSION__,
) )
from .tools import ( from .tools import (
retry, retry,
logging, logging,
sleep_time,
retry_limited,
) )
from .translator import Translate from .script import ScriptServer
__all__ = [
"Account",
"Settings",
"IDRecorder",
"Manager",
"VERSION_MAJOR",
"VERSION_MINOR",
"VERSION_BETA",
"ROOT",
"REPOSITORY",
"LICENCE",
"RELEASES",
"MASTER",
"PROMPT",
"GENERAL",
"PROGRESS",
"ERROR",
"WARNING",
"INFO",
"USERSCRIPT",
"USERAGENT",
"HEADERS",
"retry",
"logging",
"PROJECT",
"Translate",
"DataRecorder",
]

View File

@ -1,60 +1,133 @@
from pathlib import Path from pathlib import Path
from re import compile from re import compile, sub
from re import sub from shutil import move, rmtree
from shutil import move from os import utime
from shutil import rmtree from httpx import (
from typing import Callable AsyncClient,
AsyncHTTPTransport,
HTTPStatusError,
RequestError,
TimeoutException,
get,
)
from aiohttp import ClientSession from source.expansion import remove_empty_directories
from aiohttp import ClientTimeout
from .static import HEADERS from ..translation import _
from .static import USERAGENT from .static import HEADERS, USERAGENT, WARNING
from .tools import logging
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from ..expansion import Cleaner
__all__ = ["Manager"] __all__ = ["Manager"]
class Manager: class Manager:
NAME = compile(r"[^\u4e00-\u9fffa-zA-Z0-9“”《》]") NAME = compile(r"[^\u4e00-\u9fffa-zA-Z0-9-_“”《》]")
NAME_KEYS = (
"收藏数量",
"评论数量",
"分享数量",
"点赞数量",
"作品标签",
"作品ID",
"作品标题",
"作品描述",
"作品类型",
"发布时间",
"最后更新时间",
"作者昵称",
"作者ID",
)
NO_PROXY = {
"http://": None,
"https://": None,
}
SEPARATE = "_"
WEB_ID = r"(?:^|; )webId=[^;]+"
WEB_SESSION = r"(?:^|; )web_session=[^;]+"
def __init__( def __init__(
self, self,
root: Path, root: Path,
path: str, path: str,
folder: str, folder: str,
user_agent: str, name_format: str,
chunk: int, chunk: int,
cookie: str, user_agent: str,
proxy: str, cookie: str,
timeout: int, proxy: str | dict,
retry: int, timeout: int,
record_data: bool, retry: int,
image_format: str, record_data: bool,
folder_mode: bool, image_format: str,
transition: Callable[[str], str], image_download: bool,
video_download: bool,
live_download: bool,
download_record: bool,
folder_mode: bool,
author_archive: bool,
write_mtime: bool,
script_server: bool,
cleaner: "Cleaner",
print_object,
): ):
self.print = print_object
self.root = root self.root = root
self.temp = root.joinpath("./temp") self.cleaner = cleaner
self.temp = root.joinpath("Temp")
self.path = self.__check_path(path) self.path = self.__check_path(path)
self.folder = self.__check_folder(folder) self.folder = self.__check_folder(folder)
self.compatible()
self.blank_headers = HEADERS | { self.blank_headers = HEADERS | {
"User-Agent": user_agent or USERAGENT, } "user-agent": user_agent or USERAGENT,
self.headers = self.blank_headers | {"Cookie": cookie} }
self.headers = self.blank_headers | {
"cookie": cookie,
}
self.retry = retry self.retry = retry
self.chunk = chunk self.chunk = chunk
self.record_data = record_data self.name_format = self.__check_name_format(name_format)
self.record_data = self.check_bool(record_data, False)
self.image_format = self.__check_image_format(image_format) self.image_format = self.__check_image_format(image_format)
self.folder_mode = folder_mode self.folder_mode = self.check_bool(folder_mode, False)
self.proxy = proxy self.download_record = self.check_bool(download_record, True)
self.request_session = ClientSession( self.proxy_tip = None
headers=self.headers | { self.proxy = self.__check_proxy(proxy)
"Referer": "https://www.xiaohongshu.com/explore", }, self.print_proxy_tip()
timeout=ClientTimeout(connect=timeout), self.timeout = timeout
self.request_client = AsyncClient(
headers=self.headers
| {
"referer": "https://www.xiaohongshu.com/",
},
timeout=timeout,
verify=False,
follow_redirects=True,
mounts={
"http://": AsyncHTTPTransport(proxy=self.proxy),
"https://": AsyncHTTPTransport(proxy=self.proxy),
},
) )
self.download_session = ClientSession( self.download_client = AsyncClient(
headers=self.blank_headers, headers=self.blank_headers,
timeout=ClientTimeout(connect=timeout)) timeout=timeout,
self.message = transition verify=False,
follow_redirects=True,
mounts={
"http://": AsyncHTTPTransport(proxy=self.proxy),
"https://": AsyncHTTPTransport(proxy=self.proxy),
},
)
self.image_download = self.check_bool(image_download, True)
self.video_download = self.check_bool(video_download, True)
self.live_download = self.check_bool(live_download, True)
self.author_archive = self.check_bool(author_archive, False)
self.write_mtime = self.check_bool(write_mtime, False)
self.script_server = self.check_bool(script_server, False)
self.create_folder()
def __check_path(self, path: str) -> Path: def __check_path(self, path: str) -> Path:
if not path: if not path:
@ -64,22 +137,27 @@ class Manager:
return r if (r := self.__check_root_again(r)) else self.root return r if (r := self.__check_root_again(r)) else self.root
def __check_folder(self, folder: str) -> Path: def __check_folder(self, folder: str) -> Path:
folder = self.path.joinpath(folder or "Download") folder = self.cleaner.filter_name(folder, default="Download")
folder.mkdir(exist_ok=True) return self.path.joinpath(folder)
self.temp.mkdir(exist_ok=True)
return folder
@staticmethod @staticmethod
def __check_root_again(root: Path) -> bool | Path: def __check_root_again(root: Path) -> bool | Path:
if root.resolve().parent.is_dir(): if root.parent.is_dir():
root.mkdir() root.mkdir(exist_ok=True)
return root return root
return False return False
@staticmethod @staticmethod
def __check_image_format(image_format) -> str: def __check_image_format(image_format) -> str:
if image_format in {"png", "PNG", "webp", "WEBP"}: if (i := image_format.lower()) in {
return image_format.lower() "auto",
"png",
"webp",
"jpeg",
"heic",
"avif",
}:
return i
return "png" return "png"
@staticmethod @staticmethod
@ -88,15 +166,28 @@ class Manager:
@staticmethod @staticmethod
def delete(path: Path): def delete(path: Path):
path.unlink() if path.exists():
path.unlink()
@staticmethod @staticmethod
def archive(root: Path, name: str, folder_mode: bool) -> Path: def archive(root: Path, name: str, folder_mode: bool) -> Path:
return root.joinpath(name) if folder_mode else root return root.joinpath(name) if folder_mode else root
@staticmethod @classmethod
def move(temp: Path, path: Path): def move(
cls,
temp: Path,
path: Path,
mtime: int = None,
rewrite: bool = False,
):
move(temp.resolve(), path.resolve()) move(temp.resolve(), path.resolve())
if rewrite and mtime:
cls.update_mtime(path.resolve(), mtime)
@staticmethod
def update_mtime(file: Path, mtime: int):
utime(file, (mtime, mtime))
def __clean(self): def __clean(self):
rmtree(self.temp.resolve()) rmtree(self.temp.resolve())
@ -105,7 +196,98 @@ class Manager:
name = self.NAME.sub("_", name) name = self.NAME.sub("_", name)
return sub(r"_+", "_", name).strip("_") return sub(r"_+", "_", name).strip("_")
@staticmethod
def check_bool(value: bool, default: bool) -> bool:
return value if isinstance(value, bool) else default
async def close(self): async def close(self):
await self.request_session.close() await self.request_client.aclose()
await self.download_session.close() await self.download_client.aclose()
self.__clean() # self.__clean()
remove_empty_directories(self.root)
remove_empty_directories(self.folder)
def __check_name_format(self, format_: str) -> str:
keys = format_.split()
return next(
("发布时间 作者昵称 作品标题" for key in keys if key not in self.NAME_KEYS),
format_,
)
def __check_proxy(
self,
proxy: str,
url="https://www.xiaohongshu.com/explore",
) -> str | None:
if proxy:
try:
response = get(
url,
proxy=proxy,
timeout=10,
headers={
"User-Agent": USERAGENT,
},
)
response.raise_for_status()
self.proxy_tip = (_("代理 {0} 测试成功").format(proxy),)
return proxy
except TimeoutException:
self.proxy_tip = (
_("代理 {0} 测试超时").format(proxy),
WARNING,
)
except (
RequestError,
HTTPStatusError,
) as e:
self.proxy_tip = (
_("代理 {0} 测试失败:{1}").format(
proxy,
e,
),
WARNING,
)
return None
def print_proxy_tip(
self,
) -> None:
if self.proxy_tip:
logging(self.print, *self.proxy_tip)
@classmethod
def clean_cookie(cls, cookie_string: str) -> str:
return cls.delete_cookie(
cookie_string,
(
cls.WEB_ID,
cls.WEB_SESSION,
),
)
@classmethod
def delete_cookie(cls, cookie_string: str, patterns: list | tuple) -> str:
for pattern in patterns:
# 使用空字符串替换匹配到的部分
cookie_string = sub(pattern, "", cookie_string)
# 去除多余的分号和空格
cookie_string = sub(r";\s*$", "", cookie_string) # 删除末尾的分号和空格
cookie_string = sub(r";\s*;", ";", cookie_string) # 删除中间多余分号后的空格
return cookie_string.strip("; ")
def create_folder(
self,
):
self.folder.mkdir(exist_ok=True)
self.temp.mkdir(exist_ok=True)
def compatible(
self,
):
if (
self.path == self.root
and (old := self.path.parent.joinpath(self.folder.name)).exists()
and not self.folder.exists()
):
move(old, self.folder)

216
source/module/mapping.py Normal file
View File

@ -0,0 +1,216 @@
from pathlib import Path
from typing import TYPE_CHECKING
from ..translation import _
from .static import ERROR
from .tools import logging
if TYPE_CHECKING:
from manager import Manager
from recorder import MapRecorder
__all__ = ["Mapping"]
class Mapping:
def __init__(
self,
manager: "Manager",
mapping: "MapRecorder",
):
self.root = manager.folder
self.folder_mode = manager.folder_mode
self.database = mapping
self.switch = manager.author_archive
self.print = manager.print
async def update_cache(
self,
id_: str,
alias: str,
):
if not self.switch:
return
if (a := await self.has_mapping(id_)) and a != alias:
self.__check_file(
id_,
alias,
a,
)
await self.database.add(id_, alias)
async def has_mapping(self, id_: str) -> str:
return d[0] if (d := await self.database.select(id_)) else ""
def __check_file(
self,
id_: str,
alias: str,
old_alias: str,
):
if not (old_folder := self.root.joinpath(f"{id_}_{old_alias}")).is_dir():
logging(
self.print,
_("{old_folder} 文件夹不存在,跳过处理").format(
old_folder=old_folder.name
),
)
return
self.__rename_folder(
old_folder,
id_,
alias,
)
self.__scan_file(
id_,
alias,
old_alias,
)
def __rename_folder(
self,
old_folder: Path,
id_: str,
alias: str,
):
new_folder = self.root.joinpath(f"{id_}_{alias}")
self.__rename(
old_folder,
new_folder,
_("文件夹"),
)
logging(
self.print,
_("文件夹 {old_folder} 已重命名为 {new_folder}").format(
old_folder=old_folder.name, new_folder=new_folder.name
),
)
def __rename_works_folder(
self,
old_: Path,
alias: str,
old_alias: str,
) -> Path:
if old_alias in old_.name:
new_ = old_.parent / old_.name.replace(old_alias, alias, 1)
self.__rename(
old_,
new_,
_("文件夹"),
)
logging(
self.print,
_("文件夹 {old_} 重命名为 {new_}").format(
old_=old_.name, new_=new_.name
),
)
return new_
return old_
def __scan_file(
self,
id_: str,
alias: str,
old_alias: str,
):
root = self.root.joinpath(f"{id_}_{alias}")
item_list = root.iterdir()
if self.folder_mode:
for f in item_list:
if f.is_dir():
f = self.__rename_works_folder(
f,
alias,
old_alias,
)
files = f.iterdir()
self.__batch_rename(
f,
files,
alias,
old_alias,
)
else:
self.__batch_rename(
root,
item_list,
alias,
old_alias,
)
def __batch_rename(
self,
root: Path,
files,
alias: str,
old_alias: str,
):
for old_file in files:
if old_alias not in old_file.name:
break
self.__rename_file(
root,
old_file,
alias,
old_alias,
)
def __rename_file(
self,
root: Path,
old_file: Path,
alias: str,
old_alias: str,
):
new_file = root.joinpath(old_file.name.replace(old_alias, alias, 1))
self.__rename(
old_file,
new_file,
_("文件"),
)
logging(
self.print,
_("文件 {old_file} 重命名为 {new_file}").format(
old_file=old_file.name, new_file=new_file.name
),
)
return True
def __rename(
self,
old_: Path,
new_: Path,
type_=_("文件"),
) -> bool:
try:
old_.rename(new_)
return True
except PermissionError as e:
logging(
self.print,
_("{type} {old}被占用,重命名失败: {error}").format(
type=type_, old=old_.name, error=e
),
ERROR,
)
return False
except FileExistsError as e:
logging(
self.print,
_("{type} {new}名称重复,重命名失败: {error}").format(
type=type_, new=new_.name, error=e
),
ERROR,
)
return False
except OSError as e:
logging(
self.print,
_("处理{type} {old}时发生预期之外的错误: {error}").format(
type=type_, old=old_.name, error=e
),
ERROR,
)
return True

16
source/module/model.py Normal file
View File

@ -0,0 +1,16 @@
from pydantic import BaseModel
class ExtractParams(BaseModel):
url: str
download: bool = False
index: list[str | int] | None = None
cookie: str = None
proxy: str = None
skip: bool = False
class ExtractData(BaseModel):
message: str
params: ExtractParams
data: dict | None

View File

@ -1,55 +1,82 @@
from re import compile from asyncio import CancelledError
from contextlib import suppress
from typing import TYPE_CHECKING
from shutil import move
from aiosqlite import connect from aiosqlite import connect
from source.module import Manager if TYPE_CHECKING:
from ..module import Manager
__all__ = ["IDRecorder", "DataRecorder", ] __all__ = ["IDRecorder", "DataRecorder", "MapRecorder"]
class IDRecorder: class IDRecorder:
URL = compile(r"\S*?https://www\.xiaohongshu\.com/explore/(\S+)") def __init__(self, manager: "Manager"):
self.name = "ExploreID.db"
def __init__(self, manager: Manager): self.file = manager.root.joinpath(self.name)
self.file = manager.root.joinpath("ExploreID.db") self.changed = False
self.switch = manager.download_record
self.database = None self.database = None
self.cursor = None self.cursor = None
async def _connect_database(self): async def _connect_database(self):
self.database = await connect(self.file) self.database = await connect(self.file)
self.cursor = await self.database.cursor() self.cursor = await self.database.cursor()
await self.database.execute("CREATE TABLE IF NOT EXISTS explore_id (ID TEXT PRIMARY KEY);") await self.database.execute(
"CREATE TABLE IF NOT EXISTS explore_id (ID TEXT PRIMARY KEY);"
)
await self.database.commit() await self.database.commit()
async def select(self, id_: str): async def select(self, id_: str):
await self.cursor.execute("SELECT ID FROM explore_id WHERE ID=?", (id_,)) if self.switch:
return await self.cursor.fetchone() await self.cursor.execute("SELECT ID FROM explore_id WHERE ID=?", (id_,))
return await self.cursor.fetchone()
async def add(self, id_: str) -> None: async def add(
await self.database.execute("REPLACE INTO explore_id VALUES (?);", (id_,)) self,
await self.database.commit() id_: str,
name: str = None,
*args,
**kwargs,
) -> None:
if self.switch:
await self.database.execute("REPLACE INTO explore_id VALUES (?);", (id_,))
await self.database.commit()
async def __delete(self, id_: str) -> None: async def __delete(self, id_: str) -> None:
if id_: if id_:
await self.database.execute("DELETE FROM explore_id WHERE ID=?", (id_,)) await self.database.execute("DELETE FROM explore_id WHERE ID=?", (id_,))
await self.database.commit() await self.database.commit()
async def delete(self, ids: str): async def delete(self, ids: list[str]):
ids = [i.group(1) for i in self.URL.finditer(ids)] if self.switch:
[await self.__delete(i) for i in ids] [await self.__delete(i) for i in ids]
async def all(self): async def all(self):
await self.cursor.execute("SELECT ID FROM explore_id") if self.switch:
return [i[0] for i in await self.cursor.fetchmany()] await self.cursor.execute("SELECT ID FROM explore_id")
return [i[0] for i in await self.cursor.fetchmany()]
async def __aenter__(self): async def __aenter__(self):
self.compatible()
await self._connect_database() await self._connect_database()
return self return self
async def __aexit__(self, exc_type, exc_value, traceback): async def __aexit__(self, exc_type, exc_value, traceback):
await self.cursor.close() with suppress(CancelledError):
await self.cursor.close()
await self.database.close() await self.database.close()
def compatible(
self,
):
if (
not self.changed
and (old := self.file.parent.parent.joinpath(self.name)).exists()
and not self.file.exists()
):
move(old, self.file)
class DataRecorder(IDRecorder): class DataRecorder(IDRecorder):
DATA_TABLE = ( DATA_TABLE = (
@ -67,15 +94,18 @@ class DataRecorder(IDRecorder):
("点赞数量", "TEXT"), ("点赞数量", "TEXT"),
("作者昵称", "TEXT"), ("作者昵称", "TEXT"),
("作者ID", "TEXT"), ("作者ID", "TEXT"),
("IP归属地", "TEXT"),
("作者链接", "TEXT"), ("作者链接", "TEXT"),
("作品链接", "TEXT"), ("作品链接", "TEXT"),
("下载地址", "TEXT"), ("下载地址", "TEXT"),
("动图地址", "TEXT"),
) )
def __init__(self, manager: Manager): def __init__(self, manager: "Manager"):
super().__init__(manager) super().__init__(manager)
self.file = manager.folder.joinpath("ExploreData.db") self.name = "ExploreData.db"
self.file = manager.folder.joinpath(self.name)
self.changed = True
self.switch = manager.record_data
async def _connect_database(self): async def _connect_database(self):
self.database = await connect(self.file) self.database = await connect(self.file)
@ -89,12 +119,16 @@ class DataRecorder(IDRecorder):
pass pass
async def add(self, **kwargs) -> None: async def add(self, **kwargs) -> None:
await self.database.execute(f"""REPLACE INTO explore_data ( if self.switch:
await self.database.execute(
f"""REPLACE INTO explore_data (
{", ".join(i[0] for i in self.DATA_TABLE)} {", ".join(i[0] for i in self.DATA_TABLE)}
) VALUES ( ) VALUES (
{", ".join("?" for _ in kwargs)} {", ".join("?" for _ in kwargs)}
);""", self.__generate_values(kwargs)) );""",
await self.database.commit() self.__generate_values(kwargs),
)
await self.database.commit()
async def __delete(self, id_: str) -> None: async def __delete(self, id_: str) -> None:
pass pass
@ -107,3 +141,51 @@ class DataRecorder(IDRecorder):
def __generate_values(self, data: dict) -> tuple: def __generate_values(self, data: dict) -> tuple:
return tuple(data[i] for i, _ in self.DATA_TABLE) return tuple(data[i] for i, _ in self.DATA_TABLE)
class MapRecorder(IDRecorder):
def __init__(self, manager: "Manager"):
super().__init__(manager)
self.name = "MappingData.db"
self.file = manager.root.joinpath(self.name)
self.switch = manager.author_archive
async def _connect_database(self):
self.database = await connect(self.file)
self.cursor = await self.database.cursor()
await self.database.execute(
"CREATE TABLE IF NOT EXISTS mapping_data ("
"ID TEXT PRIMARY KEY,"
"NAME TEXT NOT NULL"
");"
)
await self.database.commit()
async def select(self, id_: str):
if self.switch:
await self.cursor.execute(
"SELECT NAME FROM mapping_data WHERE ID=?", (id_,)
)
return await self.cursor.fetchone()
async def add(self, id_: str, name: str, *args, **kwargs) -> None:
if self.switch:
await self.database.execute(
"REPLACE INTO mapping_data VALUES (?, ?);",
(
id_,
name,
),
)
await self.database.commit()
async def __delete(self, id_: str) -> None:
pass
async def delete(self, ids: list[str]):
pass
async def all(self):
if self.switch:
await self.cursor.execute("SELECT ID, NAME FROM mapping_data")
return [i[0] for i in await self.cursor.fetchmany()]

47
source/module/script.py Normal file
View File

@ -0,0 +1,47 @@
from contextlib import suppress
from json import loads
from websockets import ConnectionClosed, serve
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from ..application import XHS
class ScriptServer:
def __init__(
self,
core: "XHS",
host="0.0.0.0",
port=5558,
):
self.core = core
self.host = host
self.port = port
self.server = None
async def handler(self, websocket):
with suppress(ConnectionClosed):
async for message in websocket:
data = loads(message)
await self.core.deal_script_tasks(**data)
async def start(self):
"""启动服务器"""
self.server = await serve(
self.handler,
self.host,
self.port,
)
async def stop(self):
"""停止服务器"""
if self.server:
self.server.close()
await self.server.wait_closed()
async def __aenter__(self):
await self.start()
return self
async def __aexit__(self, exc_type, exc_val, exc_tb):
await self.stop()

View File

@ -1,46 +1,120 @@
from json import dump from json import dump, load
from json import load
from pathlib import Path from pathlib import Path
from platform import system from platform import system
from shutil import move
from .static import ROOT, USERAGENT
__all__ = ['Settings'] __all__ = ["Settings"]
class Settings: class Settings:
# 默认配置参数
default = { default = {
"work_path": "", "mapping_data": {}, # 账号备注映射数据
"folder_name": "Download", "work_path": "", # 工作目录路径
"user_agent": "", "folder_name": "Download", # 下载文件夹名称
"cookie": "", "name_format": "发布时间 作者昵称 作品标题", # 文件命名格式
"proxy": None, "user_agent": USERAGENT, # 请求头
"timeout": 10, "cookie": "", # Cookie
"chunk": 1024 * 1024, "proxy": None, # 代理设置
"max_retry": 5, "timeout": 10, # 超时时间(秒)
"record_data": False, "chunk": 1024 * 1024 * 2, # 下载块大小(字节)
"image_format": "PNG", "max_retry": 5, # 最大重试次数
"image_download": True, "record_data": False, # 是否记录作品数据
"video_download": True, "image_format": "PNG", # 图文作品格式
"folder_mode": False, "image_download": True, # 是否下载图文
"language": "zh_CN", "video_download": True, # 是否下载视频
"server": False, "live_download": False, # 是否下载动图
"folder_mode": False, # 文件夹归档模式
"download_record": True, # 是否记录下载历史
"author_archive": False, # 是否按作者归档
"write_mtime": False, # 是否写入修改时间
"language": "zh_CN", # 语言设置
"script_server": False, # 是否启用脚本服务器
} }
# 根据操作系统设置编码格式
encode = "UTF-8-SIG" if system() == "Windows" else "UTF-8" encode = "UTF-8-SIG" if system() == "Windows" else "UTF-8"
def __init__(self, root: Path): def __init__(self, root: Path = ROOT):
self.file = root.joinpath("./settings.json") """初始化Settings类
Args:
root: 设置文件的根目录路径,默认为ROOT
"""
# 设置文件路径
self.name = "settings.json"
self.root = root
self.path = root.joinpath(self.name)
def run(self): def run(self):
return self.read() if self.file.is_file() else self.create() """运行设置管理
Returns:
dict: 设置参数字典
"""
self.migration_file()
# 如果文件存在则读取,否则创建新文件
return self.read() if self.path.is_file() else self.create()
def read(self) -> dict: def read(self) -> dict:
with self.file.open("r", encoding=self.encode) as f: """读取设置文件
return load(f)
Returns:
dict: 读取的设置参数字典
"""
# 读取设置文件
with self.path.open("r", encoding=self.encode) as f:
return self.compatible(load(f))
def create(self) -> dict: def create(self) -> dict:
with self.file.open("w", encoding=self.encode) as f: """创建新的设置文件
dump(self.default, f, indent=4)
Returns:
dict: 默认设置参数字典
"""
# 创建新的设置文件
with self.path.open("w", encoding=self.encode) as f:
dump(self.default, f, indent=4, ensure_ascii=False)
return self.default return self.default
def update(self, data: dict): def update(self, data: dict):
with self.file.open("w", encoding=self.encode) as f: """更新设置文件内容
Args:
data: 要更新的设置参数字典
"""
# 更新设置文件
with self.path.open("w", encoding=self.encode) as f:
dump(data, f, indent=4, ensure_ascii=False) dump(data, f, indent=4, ensure_ascii=False)
def compatible(
self,
data: dict,
) -> dict:
"""兼容性检查,确保所有默认配置都存在
Args:
data: 要检查的设置参数字典
Returns:
dict: 经过兼容性检查后的设置参数字典
"""
# 兼容性检查: 确保所有默认配置都存在
update = False
for i, j in self.default.items():
if i not in data:
data[i] = j
update = True
if update:
self.update(data)
return data
def migration_file(self):
"""迁移设置文件
如果旧的设置文件存在且新路径下不存在,则移动旧文件到新路径
"""
if (
old := self.root.parent.joinpath(self.name)
).exists() and not self.path.exists():
move(old, self.path)

View File

@ -1,32 +1,14 @@
from pathlib import Path from pathlib import Path
__all__ = [ VERSION_MAJOR = 2
"VERSION_MAJOR", VERSION_MINOR = 7
"VERSION_MINOR", VERSION_BETA = True
"VERSION_BETA", __VERSION__ = f"{VERSION_MAJOR}.{VERSION_MINOR}.{'beta' if VERSION_BETA else 'stable'}"
"ROOT", ROOT = Path(__file__).resolve().parent.parent.parent.joinpath("Volume")
"REPOSITORY", ROOT.mkdir(exist_ok=True)
"LICENCE", PROJECT = f"XHS-Downloader V{VERSION_MAJOR}.{VERSION_MINOR} {
"RELEASES", 'Beta' if VERSION_BETA else 'Stable'
"MASTER", }"
"PROMPT",
"GENERAL",
"PROGRESS",
"ERROR",
"WARNING",
"INFO",
"USERSCRIPT",
"USERAGENT",
"HEADERS",
"PROJECT",
]
VERSION_MAJOR = 1
VERSION_MINOR = 9
VERSION_BETA = False
ROOT = Path(__file__).resolve().parent.parent.parent
PROJECT = f"XHS-Downloader V{VERSION_MAJOR}.{
VERSION_MINOR}{" Beta" if VERSION_BETA else ""}"
REPOSITORY = "https://github.com/JoeanAmier/XHS-Downloader" REPOSITORY = "https://github.com/JoeanAmier/XHS-Downloader"
LICENCE = "GNU General Public License v3.0" LICENCE = "GNU General Public License v3.0"
@ -34,30 +16,54 @@ RELEASES = "https://github.com/JoeanAmier/XHS-Downloader/releases/latest"
USERSCRIPT = "https://raw.githubusercontent.com/JoeanAmier/XHS-Downloader/master/static/XHS-Downloader.js" USERSCRIPT = "https://raw.githubusercontent.com/JoeanAmier/XHS-Downloader/master/static/XHS-Downloader.js"
HEADERS = { USERAGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36"
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,"
"application/signed-exchange;v=b3;q=0.7",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9",
"Cache-Control": "max-age=0",
"Dnt": "1",
"Sec-Ch-Ua": "\"Not_A Brand\";v=\"8\", \"Chromium\";v=\"120\", \"Microsoft Edge\";v=\"120\"",
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua-Platform": "\"Windows\"",
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "none",
"Sec-Fetch-User": "?1",
"Upgrade-Insecure-Requests": "1",
}
USERAGENT = (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 "
"Safari/537.36 Edg/121.0.0.0")
MASTER = "b #fff200" HEADERS = {
PROMPT = "b turquoise2" "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,"
GENERAL = "b bright_white" "application/signed-exchange;v=b3;q=0.7",
PROGRESS = "b bright_magenta" "referer": "https://www.xiaohongshu.com/explore",
ERROR = "b bright_red" "user-agent": USERAGENT,
WARNING = "b bright_yellow" }
INFO = "b bright_green"
MASTER = "#fff200"
PROMPT = "turquoise2"
GENERAL = "bright_white"
PROGRESS = "bright_magenta"
ERROR = "bright_red"
WARNING = "bright_yellow"
INFO = "bright_green"
FILE_SIGNATURES: tuple[
tuple[
int,
bytes,
str,
],
...,
] = (
# 分别为偏移量(字节)、十六进制签名、后缀
# 参考https://en.wikipedia.org/wiki/List_of_file_signatures
# 参考https://www.garykessler.net/library/file_sigs.html
(0, b"\xff\xd8\xff", "jpeg"),
(0, b"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a", "png"),
(4, b"\x66\x74\x79\x70\x61\x76\x69\x66", "avif"),
(4, b"\x66\x74\x79\x70\x68\x65\x69\x63", "heic"),
(8, b"\x57\x45\x42\x50", "webp"),
(4, b"\x66\x74\x79\x70\x4d\x53\x4e\x56", "mp4"),
(4, b"\x66\x74\x79\x70\x69\x73\x6f\x6d", "mp4"),
(4, b"\x66\x74\x79\x70\x6d\x70\x34\x32", "m4v"),
(4, b"\x66\x74\x79\x70\x71\x74\x20\x20", "mov"),
(0, b"\x1a\x45\xdf\xa3", "mkv"),
(0, b"\x00\x00\x01\xb3", "mpg"),
(0, b"\x00\x00\x01\xba", "mpg"),
(0, b"\x46\x4c\x56\x01", "flv"),
(8, b"\x41\x56\x49\x20", "avi"),
)
FILE_SIGNATURES_LENGTH = max(
offset + len(signature) for offset, signature, _ in FILE_SIGNATURES
)
MAX_WORKERS: int = 4
if __name__ == "__main__":
print(__VERSION__)

View File

@ -1,16 +1,19 @@
from asyncio import sleep
from random import uniform
from typing import Callable
from rich import print from rich import print
from rich.text import Text from rich.text import Text
from ..translation import _
from .static import INFO from .static import INFO
__all__ = ["retry", "logging", ]
def retry(function): def retry(function):
async def inner(self, *args, **kwargs): async def inner(self, *args, **kwargs):
if result := await function(self, *args, **kwargs): if result := await function(self, *args, **kwargs):
return result return result
for _ in range(self.retry): for __ in range(self.retry):
if result := await function(self, *args, **kwargs): if result := await function(self, *args, **kwargs):
return result return result
return result return result
@ -18,9 +21,37 @@ def retry(function):
return inner return inner
def logging(log, text, style=INFO): def retry_limited(function):
# TODO: 不支持 TUI
def inner(self, *args, **kwargs):
while True:
if function(self, *args, **kwargs):
return
if self.console.input(
_(
"如需重新尝试处理该对象,请关闭所有正在访问该对象的窗口或程序,然后直接按下回车键!\n"
"如需跳过处理该对象,请输入任意字符后按下回车键!"
),
):
return
return inner
def logging(log: Callable, text, style=INFO):
string = Text(text, style=style) string = Text(text, style=style)
if log: func = log()
log.write(string) if func is print:
func(string)
else: else:
print(string) func.write(
string,
scroll_end=True,
)
async def sleep_time(
min_time: int | float = 2.0,
max_time: int | float = 4.0,
):
await sleep(uniform(min_time, max_time))

View File

@ -1,27 +0,0 @@
from gettext import translation
from source.module import ROOT
__all__ = ["Translate"]
class Translate:
SUPPORT = {
"zh_CN",
"en_GB",
}
def __init__(self, language: str):
self.language = self.__check_language(language)
self.translate = translation(
"xhs",
localedir=ROOT.joinpath("locale"),
languages=[self.language],
fallback=True,
)
def __check_language(self, language: str) -> str:
return language if language in self.SUPPORT else "zh_CN"
def message(self):
return self.translate.gettext

View File

@ -0,0 +1 @@
from .translate import switch_language, _

View File

@ -0,0 +1,87 @@
from gettext import translation
from locale import getlocale
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent.parent
class TranslationManager:
"""管理gettext翻译的类"""
_instance = None # 单例实例
def __new__(cls, *args, **kwargs):
if not cls._instance:
cls._instance = super(TranslationManager, cls).__new__(cls)
return cls._instance
def __init__(self, domain="xhs", localedir=None):
self.domain = domain
if not localedir:
localedir = ROOT.joinpath("locale")
self.localedir = Path(localedir)
self.current_translator = self.setup_translation(
self.get_language_code(),
)
@staticmethod
def get_language_code() -> str:
# 获取当前系统的语言和区域设置
language_code, __ = getlocale()
if not language_code:
return "en_US"
return (
"zh_CN"
if any(
s in language_code.upper()
for s in (
"CHINESE",
"ZH",
"CHINA",
)
)
else "en_US"
)
def setup_translation(self, language: str = "zh_CN"):
"""设置gettext翻译环境"""
try:
return translation(
self.domain,
localedir=self.localedir,
languages=[language],
fallback=True,
)
except FileNotFoundError as e:
print(
f"Warning: Translation files for '{self.domain}' not found. Error: {e}"
)
return translation(self.domain, fallback=True)
def switch_language(self, language: str = "en_US"):
"""切换当前使用的语言"""
self.current_translator = self.setup_translation(language)
def gettext(self, message):
"""提供gettext方法"""
return self.current_translator.gettext(message)
# 初始化TranslationManager单例实例
translation_manager = TranslationManager()
def _translate(message):
"""辅助函数来简化翻译调用"""
return translation_manager.gettext(message)
def switch_language(language: str = "en_US"):
"""切换语言并刷新翻译函数"""
global _
translation_manager.switch_language(language)
_ = translation_manager.gettext
# 设置默认翻译函数
_ = _translate

2429
static/20250619.js Normal file

File diff suppressed because one or more lines are too long

BIN
static/DartNode_AD.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

18
static/Release_Notes.md Normal file
View File

@ -0,0 +1,18 @@
**项目更新内容:**
1. 修复 MCP 模式无法下载文件的问题
2. 新增 `script_server` 配置参数
3. 新增连接用户脚本下载作品功能
4. 新增作品处理统计功能
5. 调整内置延时机制
*****
**用户脚本更新内容:**
**版本号2.2.3**
1. 新增链接提取/图片下载选择模式开关
2. 修复合辑作品链接提取失败的问题
3. 链接提取选择界面添加序号显示
4. 新增推送下载任务至服务器功能

BIN
static/XHS-Downloader.icns Normal file

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -1,10 +1,6 @@
ScrollableContainer, RichLog, Monitor, About {
background: #2f3542;
}
Button { Button {
width: 1fr; width: 1fr;
margin: 1 1; margin: 1 1;
text-style: bold;
} }
.vertical-layout { .vertical-layout {
layout: vertical; layout: vertical;
@ -18,46 +14,38 @@ Button {
width: 25vw; width: 25vw;
} }
Button#deal, Button#paste, Button#save, Button#enter { Button#deal, Button#paste, Button#save, Button#enter {
tint: #27ae60 60%; color: $success;
} }
Button#reset, Button#abandon, Button#close { Button#reset, Button#abandon, Button#close {
tint: #c0392b 60%; color: $error;
} }
Label { Label, Link {
width: 100%; width: 100%;
content-align-horizontal: center; content-align-horizontal: center;
content-align-vertical: middle; content-align-vertical: middle;
text-style: bold; }
Link {
color: $accent;
} }
Label.params { Label.params {
margin: 1 0 0 0; margin: 1 0 0 0;
color: $primary;
} }
Label.prompt { Label.prompt {
padding: 1; padding: 1;
} }
Bar {
width: 33vw;
}
Bar > .bar--indeterminate {
color: #7bed9f;
}
Bar > .bar--complete {
color: #ff7f50;
}
.loading { .loading {
grid-size: 1 2; grid-size: 1 2;
grid-gutter: 1; grid-gutter: 1;
width: 40vw; width: 40vw;
height: 5; height: 5;
background: #353b48; border: double $primary;
border: double #747d8c;
} }
#record { #record {
grid-size: 1 3; grid-size: 1 3;
width: 80vw; width: 80vw;
height: 12; height: 12;
background: #353b48; border: double $primary;
border: double #747d8c;
} }
ModalScreen { ModalScreen {
align: center middle; align: center middle;

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 385 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 646 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 293 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 207 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

After

Width:  |  Height:  |  Size: 350 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

After

Width:  |  Height:  |  Size: 236 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -0,0 +1,101 @@
// ==UserScript==
// @name 自动滚动页面
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 模拟自然滚动,测试页面滚动效果
// @author ChatGPT, JoeanAmier
// @match *://*/* // 匹配所有页面,也可以指定具体网站
// @grant none
// @run-at document-end // 在页面加载完毕后运行脚本
// ==/UserScript==
(function () {
'use strict';
// 配置滚动模式
const scrollMode = 'limited'; // 'none'、'endless' 或 'limited'
const maxScrollCount = 10; // 最大滚动次数(如果模式是 'limited'
// 随机整数生成函数
const getRandomInt = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
// 判断是否需要暂停,模拟用户的停顿行为
const shouldPause = () => Math.random() < 0.2; // 20%几率停顿
// 执行一次增量滚动
const scrollOnce = () => {
const scrollDistanceMin = 50; // 最小滚动距离
const scrollDistanceMax = 200; // 最大滚动距离
const scrollDistance = getRandomInt(scrollDistanceMin, scrollDistanceMax);
console.log(`滚动距离: ${scrollDistance}px`); // 日志输出滚动距离
window.scrollBy(0, scrollDistance); // 增量滚动
};
// 检查是否已经滚动到底部
const isAtBottom = () => {
const docHeight = document.documentElement.scrollHeight;
const winHeight = window.innerHeight;
const scrollPos = window.scrollY;
return (docHeight - winHeight - scrollPos <= 10); // 如果距离底部小于10px认为滚动到底部
};
// 自动滚动主函数
const scrollScreen = (callback, scrollCount = 0,) => {
const timeoutMin = 100; // 最小滚动间隔
const timeoutMax = 300; // 最大滚动间隔
console.log('开始滚动...');
const scrollInterval = setInterval(() => {
if (shouldPause()) {
// 停顿,模拟用户的休息
clearInterval(scrollInterval);
setTimeout(() => {
scrollScreen(callback, scrollCount,); // 重新启动滚动
}, getRandomInt(500, 1500)); // 随机停顿时间
} else if (scrollMode === 'endless') {
// 无限滚动至底部模式
if (!isAtBottom()) {
scrollOnce(); // 执行一次滚动
} else {
// 到达底部,停止滚动
clearInterval(scrollInterval);
callback(); // 调用回调函数
console.log('已经到达页面底部,停止滚动');
}
} else if (scrollMode === 'limited') {
// 滚动指定次数模式
if (scrollCount < maxScrollCount && !isAtBottom()) {
scrollOnce(); // 执行一次滚动
scrollCount++;
} else {
// 如果到达底部或滚动次数已满,停止滚动
clearInterval(scrollInterval);
callback(); // 调用回调函数
console.log(`已经滚动${scrollCount}次,停止滚动`);
}
} else if (scrollMode === 'none') {
// 关闭滚动功能
clearInterval(scrollInterval);
console.log('自动滚动已关闭');
}
}, getRandomInt(timeoutMin, timeoutMax)); // 随机滚动间隔
};
// 等待页面完全加载后执行滚动
window.addEventListener('load', () => {
console.log('页面加载完成');
// 检查页面是否足够长,以便滚动
if (document.body.scrollHeight > window.innerHeight && scrollMode !== 'none') {
// 执行自动滚动
scrollScreen(() => {
console.log('滚动完成');
});
} else {
console.log('页面没有足够的内容进行滚动,或者自动滚动已关闭');
}
});
})();

1680
uv.lock generated Normal file

File diff suppressed because it is too large Load Diff