diff --git a/README.md b/README.md
index 7461ea7..43f6715 100644
--- a/README.md
+++ b/README.md
@@ -268,12 +268,12 @@ async def example_api():
📜 脚本说明
- 下载小红书无水印作品文件时,脚本需要花费时间处理文件,请等待片刻,请勿多次点击下载按钮
-- 无水印图片文件为 PNG 格式;无水印视频文件较大,可能需要较长的时间处理,页面跳转可能会导致下载失败
- 提取账号发布、收藏、点赞、专辑作品链接时,脚本可以自动滚动页面直至加载全部作品
- 提取推荐作品链接、搜索作品、用户链接时,脚本可以自动滚动指定次数加载更多内容,默认滚动次数:50 次
- 自动滚动页面功能默认关闭;用户可以自由开启,并修改滚动页面次数,修改后立即生效
- 如果未开启自动滚动页面功能,用户需要手动滚动页面以便加载更多内容后再进行其他操作
- 支持作品文件打包下载;该功能默认开启,多个文件的作品将会以压缩包格式下载
+- 向服务器推送下载任务时,文件格式、名称规则等设置以服务器配置文件中的设置为准
- 使用全局代理工具可能会导致脚本下载文件失败,如有异常,请尝试关闭代理工具,必要时向作者反馈
- XHS-Downloader 用户脚本仅实现可见即可得的数据采集功能,无任何收费功能和破解功能
@@ -434,7 +434,7 @@ async def example():
image_format |
str |
图文作品文件下载格式,支持:AUTO、PNG、WEBP、JPEG、HEIC 部分作品没有 HEIC 格式的文件,此时下载的文件可能为 WEBP 格式! 设置为 AUTO 时表示动态格式,实际格式取决于服务器响应数据! |
-PNG |
+JPEG |
| image_download |
diff --git a/README_EN.md b/README_EN.md
index 3758e23..72469c5 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -272,12 +272,12 @@ async def example_api():
📜 Script Instructions
- 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.
-- 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.
- When extracting links for posts, collects, likes, and board from an account, the script can automatically scroll the page until all works are loaded.
- 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.
- 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.
- If the automatic page scroll feature is not enabled, users need to manually scroll the page to load more content before performing other actions.
- 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
+- When pushing download tasks to the server, the file format, name rules, etc. settings will be based on the server configuration file settings
- 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.
- XHS-Downloader userscript only implements the data collection functionality for visible content and does not include any paid or cracked features.
@@ -438,7 +438,7 @@ async def example():
image_format |
str |
Download format for image works files, supported: AUTO、PNG、WEBP、JPEG、HEIC Some works do not have files in HEIC format, and the downloaded files may be in WEBP format When set toAUTO, it represents dynamic format, and the actual format depends on the server's response data |
-PNG |
+JPEG |
| image_download |
diff --git a/example.py b/example.py
index d0e7dc8..d47f11d 100644
--- a/example.py
+++ b/example.py
@@ -97,12 +97,6 @@ async def test():
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(
diff --git a/source/CLI/main.py b/source/CLI/main.py
index 8ad53d5..6e6fd51 100644
--- a/source/CLI/main.py
+++ b/source/CLI/main.py
@@ -158,7 +158,7 @@ class CLI:
"--image_format",
"-if",
"choice",
- _("图文作品文件下载格式,支持:PNG、WEBP"),
+ _("图文作品文件下载格式,支持:PNG、WEBP、JPEG、HEIC、AUTO"),
),
("--live_download", "-ld", "bool", _("动态图片下载开关")),
("--download_record", "-dr", "bool", _("作品下载记录开关")),
@@ -279,7 +279,9 @@ class CLI:
@option(
"--image_format",
"-if",
- type=Choice(["png", "PNG", "webp", "WEBP"]),
+ type=Choice(
+ ["png", "PNG", "webp", "WEBP", "jpeg", "JPEG", "heic", "HEIC", "auto", "AUTO"]
+ ),
)
@option(
"--live_download",
diff --git a/source/application/app.py b/source/application/app.py
index ab89e38..5414abb 100644
--- a/source/application/app.py
+++ b/source/application/app.py
@@ -126,7 +126,7 @@ class XHS:
chunk=1024 * 1024,
max_retry=5,
record_data=False,
- image_format="PNG",
+ image_format="JPEG",
image_download=True,
video_download=True,
live_download=False,
diff --git a/source/module/manager.py b/source/module/manager.py
index 34989c7..b1c5917 100644
--- a/source/module/manager.py
+++ b/source/module/manager.py
@@ -158,7 +158,7 @@ class Manager:
"avif",
}:
return i
- return "png"
+ return "jpeg"
@staticmethod
def is_exists(path: Path) -> bool:
diff --git a/source/module/settings.py b/source/module/settings.py
index f3885b9..59cacfd 100644
--- a/source/module/settings.py
+++ b/source/module/settings.py
@@ -21,7 +21,7 @@ class Settings:
"chunk": 1024 * 1024 * 2, # 下载块大小(字节)
"max_retry": 5, # 最大重试次数
"record_data": False, # 是否记录作品数据
- "image_format": "PNG", # 图文作品格式
+ "image_format": "JPEG", # 图文作品格式
"image_download": True, # 是否下载图文
"video_download": True, # 是否下载视频
"live_download": False, # 是否下载动图
diff --git a/source/module/static.py b/source/module/static.py
index c33b19e..4a83566 100644
--- a/source/module/static.py
+++ b/source/module/static.py
@@ -16,7 +16,10 @@ RELEASES = "https://github.com/JoeanAmier/XHS-Downloader/releases/latest"
USERSCRIPT = "https://raw.githubusercontent.com/JoeanAmier/XHS-Downloader/master/static/XHS-Downloader.js"
-USERAGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36"
+USERAGENT = (
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 "
+ "Safari/537.36 Edg/143.0.0.0"
+)
HEADERS = {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,"
diff --git a/static/XHS-Downloader.js b/static/XHS-Downloader.js
index dd838ac..2e1fed2 100644
--- a/static/XHS-Downloader.js
+++ b/static/XHS-Downloader.js
@@ -2,7 +2,7 @@
// @name XHS-Downloader
// @namespace xhs_downloader
// @homepage https://github.com/JoeanAmier/XHS-Downloader
-// @version 2.2.4
+// @version 2.2.5
// @tag 小红书
// @tag RedNote
// @description 提取小红书作品/用户链接,下载小红书无水印图文/视频作品文件
@@ -41,7 +41,8 @@
maxScrollCount: GM_getValue("maxScrollCount", 50),
keepMenuVisible: GM_getValue("keepMenuVisible", false),
linkCheckboxSwitch: GM_getValue("linkCheckboxSwitch", true),
- imageCheckboxSwitch: GM_getValue("imageCheckboxSwitch", true), // imageDownloadFormat: GM_getValue("imageDownloadFormat", "JPG"),
+ imageCheckboxSwitch: GM_getValue("imageCheckboxSwitch", true),
+ imageDownloadFormat: GM_getValue("imageDownloadFormat", "JPEG"),
scriptServerURL: GM_getValue("scriptServerURL", defaultsWebSocketURL),
scriptServerSwitch: GM_getValue("scriptServerSwitch", false),
fileNameFormat: undefined,
@@ -75,12 +76,14 @@
注意事项:
1. 下载小红书无水印作品文件时,脚本需要花费时间处理文件,请等待片刻,请勿多次点击下载按钮
-2. 无水印作品文件较大,可能需要较长的时间处理,页面跳转可能会导致下载失败
-3. 提取账号发布、收藏、点赞、专辑作品链接时,脚本可以自动滚动页面直至加载全部作品
-4. 提取推荐作品链接、搜索作品、用户链接时,脚本可以自动滚动指定次数加载更多内容,默认滚动次数:50 次
-5. 自动滚动页面功能默认关闭;用户可以自由开启,并修改滚动页面次数,修改后立即生效
-6. 如果未开启自动滚动页面功能,用户需要手动滚动页面以便加载更多内容后再进行其他操作
-7. 支持作品文件打包下载;该功能默认开启,多个文件的作品将会以压缩包格式下载
+2. 提取账号发布、收藏、点赞、专辑作品链接时,脚本可以自动滚动页面直至加载全部作品
+3. 提取推荐作品链接、搜索作品、用户链接时,脚本可以自动滚动指定次数加载更多内容,默认滚动次数:50 次
+4. 自动滚动页面功能默认关闭;用户可以自由开启,并修改滚动页面次数,修改后立即生效
+5. 如果未开启自动滚动页面功能,用户需要手动滚动页面以便加载更多内容后再进行其他操作
+6. 支持作品文件打包下载;该功能默认开启,多个文件的作品将会以压缩包格式下载
+7. 向服务器推送下载任务时,文件格式、名称规则等设置以服务器配置文件中的设置为准
+8. 使用全局代理工具可能会导致脚本下载文件失败,如有异常,请尝试关闭代理工具,必要时向作者反馈
+9. XHS-Downloader 用户脚本仅实现可见即可得的数据采集功能,无任何收费功能和破解功能
项目开源地址:https://github.com/JoeanAmier/XHS-Downloader
`
@@ -242,7 +245,11 @@ KS-Downloader(快手、KuaiShou):https://github.com/JoeanAmier/KS-Download
images.forEach((item) => {
let match = item.urlDefault.match(regex);
if (match && match[1]) {
- urls.push(`https://ci.xiaohongshu.com/${match[1]}?imageView2/format/png`);
+ urls.push(
+ `https://ci.xiaohongshu.com/${match[1]}?imageView2/format/${GM_getValue(
+ "imageDownloadFormat",
+ "JPEG"
+ ).toLowerCase()}`);
}
})
return urls
@@ -413,9 +420,9 @@ KS-Downloader(快手、KuaiShou):https://github.com/JoeanAmier/KS-Download
const downloadPromises = items.map(async (item) => {
let fileName;
if (item.index) {
- fileName = `${name}_${item.index}.png`; // 根据索引生成文件名
+ fileName = `${name}_${item.index}.${GM_getValue("imageDownloadFormat", "JPEG").toLowerCase()}`; // 根据索引生成文件名
} else {
- fileName = `${name}.png`;
+ fileName = `${name}.${GM_getValue("imageDownloadFormat", "JPEG").toLowerCase()}`;
}
const result = await downloadFile(item.url, fileName, false); // 调用单个文件下载方法
if (result) {
@@ -476,11 +483,14 @@ KS-Downloader(快手、KuaiShou):https://github.com/JoeanAmier/KS-Download
if (!config.packageDownloadFiles && items.length > 1) {
let result = [];
for (let item of items) {
- result.push(await downloadFile(item.url, `${name}_${item.index}.png`));
+ result.push(
+ await downloadFile(item.url, `${name}_${item.index}.${GM_getValue("imageDownloadFormat", "JPEG")
+ .toLowerCase()}`));
}
success = result.every(item => item === true);
} else if (items.length === 1) {
- success = await downloadFile(items[0].url, `${name}.png`);
+ success = await downloadFile(
+ items[0].url, `${name}.${GM_getValue("imageDownloadFormat", "JPEG").toLowerCase()}`);
} else {
success = await downloadFiles(items, name,);
}
@@ -1171,8 +1181,8 @@ KS-Downloader(快手、KuaiShou):https://github.com/JoeanAmier/KS-Download
// const imageDownloadFormat = createSelectItem({
// label: '图片下载格式',
// description: '选择图片格式',
- // options: ["AUTO", "PNG", "JPG",],
- // value: GM_getValue("imageDownloadFormat", "JPG"),
+ // options: ["AUTO", "PNG", "WEBP", "JPEG", "HEIC"],
+ // value: GM_getValue("imageDownloadFormat", "JPEG"),
// });
//
// const nameFormat = createTextInput({