From f332b3fb2d160da3368fd932ec9cb6f993235c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=A8?= Date: Fri, 21 Mar 2025 20:54:57 +0800 Subject: [PATCH] =?UTF-8?q?refactor(app):=20=E5=B0=86=20account=5Farchive?= =?UTF-8?q?=20=E6=9B=B4=E6=96=B0=E4=B8=BA=20author=5Farchive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++--- README_EN.md | 6 +++--- example.py | 4 ++-- source/CLI/main.py | 11 +++++++++++ source/TUI/setting.py | 6 +++--- source/application/app.py | 4 ++-- source/application/download.py | 4 ++-- source/module/manager.py | 4 ++-- source/module/settings.py | 2 +- static/Release_Notes.md | 2 +- 10 files changed, 30 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index fb44e23..0d980a8 100644 --- a/README.md +++ b/README.md @@ -233,7 +233,7 @@ async def example(): live_download = False # 图文动图文件下载开关 download_record = True # 是否记录下载成功的作品 ID language = "zh_CN" # 设置程序提示语言 - account_archive = True # 是否将每个作者的作品存至单独的文件夹 + author_archive = True # 是否将每个作者的作品存至单独的文件夹 read_cookie = None # 读取浏览器 Cookie,支持设置浏览器名称(字符串)或者浏览器序号(整数),设置为 None 代表不读取 # async with XHS() as xhs: @@ -258,7 +258,7 @@ async def example(): download_record=download_record, language=language, read_cookie=read_cookie, - account_archive=account_archive, + author_archive=author_archive, ) as xhs: # 使用自定义参数 download = True # 是否下载作品文件,默认值:False # 返回作品详细信息,包括下载地址 @@ -382,7 +382,7 @@ async def example(): true -account_archive +author_archive bool 是否将每个作者的作品储存至单独的文件夹;文件夹名称为 作者ID_作者昵称 false diff --git a/README_EN.md b/README_EN.md index 26c195f..1d5db72 100644 --- a/README_EN.md +++ b/README_EN.md @@ -237,7 +237,7 @@ async def example(): live_download = False # 图文动图文件下载开关 download_record = True # 是否记录下载成功的作品 ID language = "zh_CN" # 设置程序提示语言 - account_archive = True # 是否将每个作者的作品存至单独的文件夹 + author_archive = True # 是否将每个作者的作品存至单独的文件夹 read_cookie = None # 读取浏览器 Cookie,支持设置浏览器名称(字符串)或者浏览器序号(整数),设置为 None 代表不读取 # async with XHS() as xhs: @@ -262,7 +262,7 @@ async def example(): download_record=download_record, language=language, read_cookie=read_cookie, - account_archive=account_archive, + author_archive=author_archive, ) as xhs: # 使用自定义参数 download = True # 是否下载作品文件,默认值:False # 返回作品详细信息,包括下载地址 @@ -386,7 +386,7 @@ async def example(): true -account_archive +author_archive bool Whether to save each author's works into a separate folder; The folder name is authorID_nickname false diff --git a/example.py b/example.py index 247318f..694cb68 100644 --- a/example.py +++ b/example.py @@ -28,7 +28,7 @@ async def example(): live_download = False # 图文动图文件下载开关 download_record = True # 是否记录下载成功的作品 ID language = "zh_CN" # 设置程序提示语言 - account_archive = True # 是否将每个作者的作品存至单独的文件夹 + author_archive = True # 是否将每个作者的作品存至单独的文件夹 read_cookie = None # 读取浏览器 Cookie,支持设置浏览器名称(字符串)或者浏览器序号(整数),设置为 None 代表不读取 # async with XHS() as xhs: @@ -53,7 +53,7 @@ async def example(): download_record=download_record, language=language, read_cookie=read_cookie, - account_archive=account_archive, + author_archive=author_archive, ) as xhs: # 使用自定义参数 download = True # 是否下载作品文件,默认值:False # 返回作品详细信息,包括下载地址 diff --git a/source/CLI/main.py b/source/CLI/main.py index 15cfe0d..9667d20 100644 --- a/source/CLI/main.py +++ b/source/CLI/main.py @@ -166,6 +166,12 @@ class CLI: "bool", _("是否将每个作品的文件储存至单独的文件夹"), ), + ( + "--author_archive", + "-aa", + "bool", + _("是否将每个作者的作品储存至单独的文件夹"), + ), ("--language", "-l", "choice", _("设置程序语言,目前支持:zh_CN、en_US")), ("--settings", "-s", "str", _("读取指定配置文件")), ( @@ -279,6 +285,11 @@ class CLI: "-fm", type=bool, ) +@option( + "--author_archive", + "-aa", + type=bool, +) @option( "--language", "-l", diff --git a/source/TUI/setting.py b/source/TUI/setting.py index 976b344..8bdad3b 100644 --- a/source/TUI/setting.py +++ b/source/TUI/setting.py @@ -159,8 +159,8 @@ class Setting(Screen): ), Checkbox( _("作者归档保存模式"), - id="account_archive", - value=self.data["account_archive"], + id="author_archive", + value=self.data["author_archive"], ), classes="horizontal-layout", ), @@ -234,7 +234,7 @@ class Setting(Screen): "video_download": self.query_one("#video_download").value, "live_download": self.query_one("#live_download").value, "download_record": self.query_one("#download_record").value, - "account_archive": self.query_one("#account_archive").value, + "author_archive": self.query_one("#author_archive").value, } ) diff --git a/source/application/app.py b/source/application/app.py index cc6c64e..0e91615 100644 --- a/source/application/app.py +++ b/source/application/app.py @@ -103,7 +103,7 @@ class XHS: live_download=False, folder_mode=False, download_record=True, - account_archive=False, + author_archive=False, language="zh_CN", read_cookie: int | str = None, _print: bool = True, @@ -129,7 +129,7 @@ class XHS: live_download, download_record, folder_mode, - account_archive, + author_archive, _print, ) self.html = Html(self.manager) diff --git a/source/application/download.py b/source/application/download.py index 40a2365..8a59124 100644 --- a/source/application/download.py +++ b/source/application/download.py @@ -63,7 +63,7 @@ class Download: self.image_download = manager.image_download self.video_download = manager.video_download self.live_download = manager.live_download - self.account_archive = manager.account_archive + self.author_archive = manager.author_archive async def run( self, @@ -110,7 +110,7 @@ class Download: return path, tasks def __generate_path(self, nickname:str, filename: str): - if self.account_archive: + if self.author_archive: folder = self.folder.joinpath(nickname) folder.mkdir(exist_ok=True) else: diff --git a/source/module/manager.py b/source/module/manager.py index a9ffa32..c25b43e 100644 --- a/source/module/manager.py +++ b/source/module/manager.py @@ -65,7 +65,7 @@ class Manager: live_download: bool, download_record: bool, folder_mode: bool, - account_archive:bool, + author_archive:bool, _print: bool, ): self.root = root @@ -116,7 +116,7 @@ class Manager: self.image_download = self.check_bool(image_download, True) self.video_download = self.check_bool(video_download, True) self.live_download = self.check_bool(live_download, True) - self.account_archive = self.check_bool(account_archive, False) + self.author_archive = self.check_bool(author_archive, False) def __check_path(self, path: str) -> Path: if not path: diff --git a/source/module/settings.py b/source/module/settings.py index b4a9704..6aef1e2 100644 --- a/source/module/settings.py +++ b/source/module/settings.py @@ -27,7 +27,7 @@ class Settings: "live_download": False, "folder_mode": False, "download_record": True, - "account_archive": False, + "author_archive": False, "language": "zh_CN", } encode = "UTF-8-SIG" if system() == "Windows" else "UTF-8" diff --git a/static/Release_Notes.md b/static/Release_Notes.md index 2d2c7c4..c71efd4 100644 --- a/static/Release_Notes.md +++ b/static/Release_Notes.md @@ -9,7 +9,7 @@ **注意:** -

配置文件新增参数 account_archive,旧版本更新需要手动添加配置内容:"account_archive": false;或者直接删除旧版配置文件后再运行程序!

+

配置文件新增参数 author_archive,旧版本更新需要手动添加配置内容:"author_archive": false;或者直接删除旧版配置文件后再运行程序!

*****