feat: 发布 2.4 版本

This commit is contained in:
JoeanAmier
2025-01-05 11:45:15 +08:00
parent b3974fe8f3
commit bd7af3d0d1
19 changed files with 25 additions and 29 deletions

View File

@@ -39,15 +39,13 @@ def check_value(function):
class CLI:
def __init__(self, ctx: Context, **kwargs):
# print(kwargs)
self.ctx = ctx
self.url = kwargs.pop("url")
self.index = self.__format_index(kwargs.pop("index"))
self.path = kwargs.pop("settings")
self.update = kwargs.pop("update_settings")
# print(kwargs)
self.url = ctx.params.pop("url")
self.index = self.__format_index(ctx.params.pop("index"))
self.path = ctx.params.pop("settings")
self.update = ctx.params.pop("update_settings")
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)
self.APP = XHS(**self.parameter)
async def __aenter__(self):
@@ -116,7 +114,8 @@ class CLI:
options = (
("--url", "-u", "str", _("小红书作品链接")),
("--index", "-i", "str", _("下载指定序号的图片文件,仅对图文作品生效;多个序号输入示例:\"1 3 5 7\"")),
("--index", "-i", "str",
fill(_("下载指定序号的图片文件,仅对图文作品生效;多个序号输入示例:\"1 3 5 7\""), width=55),),
("--work_path", "-wp", "str", _("作品数据 / 文件保存根路径")),
("--folder_name", "-fn", "str", _("作品文件储存文件夹名称")),
("--name_format", "-nf", "str", _("作品文件名称格式")),
@@ -126,7 +125,7 @@ class CLI:
("--cookie", "-ck", "str", _("小红书网页版 Cookie无需登录")),
("--proxy", "-p", "str", _("网络代理")),
("--timeout", "-t", "int", _("请求数据超时限制,单位:秒")),
("--chunk", "-c", "int", _("下载文件时,每次从服务器获取的数据块大小,单位:字节")),
("--chunk", "-c", "int", fill(_("下载文件时,每次从服务器获取的数据块大小,单位:字节"), width=55),),
("--max_retry", "-mr", "int", _("请求数据失败时,重试的最大次数")),
("--record_data", "-rd", "bool", _("是否记录作品数据至文件")),
("--image_format", "-if", "choice", _("图文作品文件下载格式支持PNG、WEBP")),
@@ -141,7 +140,7 @@ class CLI:
BrowserCookie.SUPPORT_BROWSER.keys(),
start=1,
))
), width=40)),
), width=55)),
("--update_settings", "-us", "flag", _("是否更新配置文件")),
("--help", "-h", "flag", _("查看详细参数说明")),
("--version", "-v", "flag", _("查看 XHS-Downloader 版本")),
@@ -218,4 +217,4 @@ if __name__ == "__main__":
from click.testing import CliRunner
runner = CliRunner()
result = runner.invoke(cli, ['-l', 'en_US', '-h'])
result = runner.invoke(cli, ['-l', 'en_US', '-u', ''])

View File

@@ -90,7 +90,6 @@ class Index(Screen):
">" *
50}",
style=MASTER),
animate=True,
scroll_end=True,
)
self.xhs.manager.print_proxy_tip(log=self.tip, )
@@ -102,12 +101,10 @@ class Index(Screen):
else:
self.tip.write(
Text(_("未输入任何小红书作品链接"), style=WARNING),
animate=True,
scroll_end=True,
)
self.tip.write(
Text(">" * 50, style=GENERAL),
animate=True,
scroll_end=True,
)
@@ -132,7 +129,6 @@ class Index(Screen):
)
self.tip.write(
Text(">" * 50, style=GENERAL),
animate=True,
scroll_end=True,
)
await self.app.action_back()

View File

@@ -53,7 +53,6 @@ class Monitor(Screen):
Text(_(
"程序会自动读取并提取剪贴板中的小红书作品链接,并自动下载链接对应的作品文件,如需关闭,请点击关闭按钮,或者向剪贴板写入 “close” 文本!"),
style=MASTER),
animate=True,
scroll_end=True,
)
self.run_monitor()

View File

@@ -2,7 +2,7 @@ from pathlib import Path
VERSION_MAJOR = 2
VERSION_MINOR = 4
VERSION_BETA = True
VERSION_BETA = False
ROOT = Path(__file__).resolve().parent.parent.parent
PROJECT = f"XHS-Downloader V{VERSION_MAJOR}.{
VERSION_MINOR}{" Beta" if VERSION_BETA else ""}"

View File

@@ -22,7 +22,7 @@ def retry(function):
def logging(log, text, style=INFO):
string = Text(text, style=style)
if log:
log.write(string, animate=True, scroll_end=True, )
log.write(string, scroll_end=True, )
else:
print(string)