perf: 更新项目默认配置参数

1. 更新项目 README
2. 更新默认 UserAgent
3. 默认图片格式修改为 JPEG
4. 修正项目描述错误
This commit is contained in:
Quan
2026-01-07 20:15:38 +08:00
parent 086ff930e1
commit f68ac8477e
9 changed files with 40 additions and 31 deletions

View File

@@ -268,12 +268,12 @@ async def example_api():
<h2>📜 脚本说明</h2>
<ul>
<li>下载小红书无水印作品文件时,脚本需要花费时间处理文件,请等待片刻,请勿多次点击下载按钮</li>
<li>无水印图片文件为 PNG 格式;无水印视频文件较大,可能需要较长的时间处理,页面跳转可能会导致下载失败</li>
<li>提取账号发布、收藏、点赞、专辑作品链接时,脚本可以自动滚动页面直至加载全部作品</li>
<li>提取推荐作品链接、搜索作品、用户链接时脚本可以自动滚动指定次数加载更多内容默认滚动次数50 次</li>
<li>自动滚动页面功能默认关闭;用户可以自由开启,并修改滚动页面次数,修改后立即生效</li>
<li>如果未开启自动滚动页面功能,用户需要手动滚动页面以便加载更多内容后再进行其他操作</li>
<li>支持作品文件打包下载;该功能默认开启,多个文件的作品将会以压缩包格式下载</li>
<li>向服务器推送下载任务时,文件格式、名称规则等设置以服务器配置文件中的设置为准</li>
<li>使用全局代理工具可能会导致脚本下载文件失败,如有异常,请尝试关闭代理工具,必要时向作者反馈</li>
<li>XHS-Downloader 用户脚本仅实现可见即可得的数据采集功能,无任何收费功能和破解功能</li>
</ul>
@@ -434,7 +434,7 @@ async def example():
<td align="center">image_format</td>
<td align="center">str</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">JPEG</td>
</tr>
<tr>
<td align="center">image_download</td>

View File

@@ -272,12 +272,12 @@ async def example_api():
<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>When pushing download tasks to the server, the file format, name rules, etc. settings will be based on the server configuration file settings</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>
@@ -438,7 +438,7 @@ async def example():
<td align="center">image_format</td>
<td align="center">str</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">JPEG</td>
</tr>
<tr>
<td align="center">image_download</td>

View File

@@ -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(

View File

@@ -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",

View File

@@ -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,

View File

@@ -158,7 +158,7 @@ class Manager:
"avif",
}:
return i
return "png"
return "jpeg"
@staticmethod
def is_exists(path: Path) -> bool:

View File

@@ -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, # 是否下载动图

View File

@@ -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,"

View File

@@ -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快手、KuaiShouhttps://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快手、KuaiShouhttps://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快手、KuaiShouhttps://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快手、KuaiShouhttps://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({