perf: 调整内置延时机制

This commit is contained in:
Quan 2025-09-16 13:00:08 +08:00
parent af63050292
commit f2c52cbe89
10 changed files with 19 additions and 16 deletions

View File

@ -5,7 +5,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: XHS-Downloader 2.6\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"

View File

@ -6,7 +6,7 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: XHS-Downloader 2.6\n"
"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"

View File

@ -5,7 +5,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: XHS-Downloader 2.6\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"

View File

@ -1,6 +1,6 @@
[project]
name = "XHS-Downloader"
version = "2.6"
version = "2.7"
description = "小红书XiaoHongShu、RedNote链接提取/作品采集工具:提取账号发布、收藏、点赞、专辑作品链接;提取搜索结果作品、用户链接;采集小红书作品信息;提取小红书作品下载地址;下载小红书无水印作品文件"
authors = [
{ name = "JoeanAmier", email = "yonglelolu@foxmail.com" },

View File

@ -38,7 +38,7 @@ from source.module import (
Manager,
MapRecorder,
logging,
sleep_time,
# sleep_time,
)
from source.translation import _, switch_language
@ -347,7 +347,7 @@ class XHS:
await self.update_author_nickname(data, log)
await self.__download_files(data, download, index, log, bar)
logging(log, _("作品处理完成:{0}").format(i))
await sleep_time()
# await sleep_time()
return data
async def update_author_nickname(

View File

@ -14,7 +14,7 @@ from ..module import (
FILE_SIGNATURES_LENGTH,
MAX_WORKERS,
logging,
sleep_time,
# sleep_time,
)
from ..module import retry as re_download
from ..translation import _
@ -175,8 +175,8 @@ class Download:
tasks.append([j[1], file, self.live_format])
return tasks
@staticmethod
def __check_exists_glob(
self,
path: Path,
name: str,
log,
@ -186,8 +186,8 @@ class Download:
return True
return False
@staticmethod
def __check_exists_path(
self,
path: Path,
name: str,
log,
@ -236,7 +236,7 @@ class Download:
url,
headers=headers,
) as response:
await sleep_time()
# await sleep_time()
if response.status_code == 416:
raise CacheError(
_("文件 {0} 缓存异常,重新下载").format(temp.name),
@ -311,11 +311,12 @@ class Download:
headers: dict[str, str],
suffix: str,
) -> tuple[int, str]:
"""未使用"""
response = await self.client.head(
url,
headers=headers,
)
await sleep_time()
# 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)

View File

@ -1,8 +1,8 @@
from pathlib import Path
VERSION_MAJOR = 2
VERSION_MINOR = 6
VERSION_BETA = False
VERSION_MINOR = 7
VERSION_BETA = True
__VERSION__ = f"{VERSION_MAJOR}.{VERSION_MINOR}.{'beta' if VERSION_BETA else 'stable'}"
ROOT = Path(__file__).resolve().parent.parent.parent.joinpath("Volume")
ROOT.mkdir(exist_ok=True)

View File

@ -49,7 +49,7 @@ def logging(log, text, style=INFO):
async def sleep_time(
min_time: int | float = 1.0,
max_time: int | float = 2.5,
min_time: int | float = 2.0,
max_time: int | float = 4.0,
):
await sleep(uniform(min_time, max_time))

View File

@ -1,5 +1,7 @@
**项目更新内容:**
1. 调整内置延时机制
*****
**用户脚本更新内容:**

2
uv.lock generated
View File

@ -1011,7 +1011,7 @@ wheels = [
[[package]]
name = "xhs-downloader"
version = "2.6"
version = "2.7"
source = { virtual = "." }
dependencies = [
{ name = "aiofiles" },