From f2c52cbe8939acd1756bdfe6df8da52027c466f1 Mon Sep 17 00:00:00 2001 From: Quan Date: Tue, 16 Sep 2025 13:00:08 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E8=B0=83=E6=95=B4=E5=86=85=E7=BD=AE?= =?UTF-8?q?=E5=BB=B6=E6=97=B6=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locale/en_US/LC_MESSAGES/xhs.po | 2 +- locale/xhs.pot | 2 +- locale/zh_CN/LC_MESSAGES/xhs.po | 2 +- pyproject.toml | 2 +- source/application/app.py | 4 ++-- source/application/download.py | 11 ++++++----- source/module/static.py | 4 ++-- source/module/tools.py | 4 ++-- static/Release_Notes.md | 2 ++ uv.lock | 2 +- 10 files changed, 19 insertions(+), 16 deletions(-) diff --git a/locale/en_US/LC_MESSAGES/xhs.po b/locale/en_US/LC_MESSAGES/xhs.po index 91a9603..3320683 100644 --- a/locale/en_US/LC_MESSAGES/xhs.po +++ b/locale/en_US/LC_MESSAGES/xhs.po @@ -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: \n" "POT-Creation-Date: 2025-08-10 23:34+0800\n" "PO-Revision-Date: 2024-12-22 14:14+0800\n" diff --git a/locale/xhs.pot b/locale/xhs.pot index 605915a..19c0b12 100644 --- a/locale/xhs.pot +++ b/locale/xhs.pot @@ -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" diff --git a/locale/zh_CN/LC_MESSAGES/xhs.po b/locale/zh_CN/LC_MESSAGES/xhs.po index 9345d4b..01835b3 100644 --- a/locale/zh_CN/LC_MESSAGES/xhs.po +++ b/locale/zh_CN/LC_MESSAGES/xhs.po @@ -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: \n" "POT-Creation-Date: 2025-08-10 23:34+0800\n" "PO-Revision-Date: 2024-12-22 14:14+0800\n" diff --git a/pyproject.toml b/pyproject.toml index c3b1722..8fa181c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "XHS-Downloader" -version = "2.6" +version = "2.7" description = "小红书(XiaoHongShu、RedNote)链接提取/作品采集工具:提取账号发布、收藏、点赞、专辑作品链接;提取搜索结果作品、用户链接;采集小红书作品信息;提取小红书作品下载地址;下载小红书无水印作品文件" authors = [ { name = "JoeanAmier", email = "yonglelolu@foxmail.com" }, diff --git a/source/application/app.py b/source/application/app.py index c6ce60d..a0eb9b0 100644 --- a/source/application/app.py +++ b/source/application/app.py @@ -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( diff --git a/source/application/download.py b/source/application/download.py index b7c9f77..c3d06d1 100644 --- a/source/application/download.py +++ b/source/application/download.py @@ -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) diff --git a/source/module/static.py b/source/module/static.py index 05e5b8e..a3753cd 100644 --- a/source/module/static.py +++ b/source/module/static.py @@ -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) diff --git a/source/module/tools.py b/source/module/tools.py index c2a25d0..8da6faf 100644 --- a/source/module/tools.py +++ b/source/module/tools.py @@ -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)) diff --git a/static/Release_Notes.md b/static/Release_Notes.md index 721b089..2dc0e71 100644 --- a/static/Release_Notes.md +++ b/static/Release_Notes.md @@ -1,5 +1,7 @@ **项目更新内容:** +1. 调整内置延时机制 + ***** **用户脚本更新内容:** diff --git a/uv.lock b/uv.lock index 87e75a2..5d48bab 100644 --- a/uv.lock +++ b/uv.lock @@ -1011,7 +1011,7 @@ wheels = [ [[package]] name = "xhs-downloader" -version = "2.6" +version = "2.7" source = { virtual = "." } dependencies = [ { name = "aiofiles" },