feat: 支持以发布时间作为文件修改时间

1. 新增 write_mtime 配置参数
2. 更新项目英语翻译
This commit is contained in:
2025-04-20 18:15:22 +08:00
parent d972420ab3
commit 936b4f9075
20 changed files with 882 additions and 586 deletions

View File

@@ -103,6 +103,7 @@ class XHS:
folder_mode=False,
download_record=True,
author_archive=False,
write_mtime=False,
language="zh_CN",
read_cookie: int | str = None,
_print: bool = True,
@@ -129,6 +130,7 @@ class XHS:
download_record,
folder_mode,
author_archive,
write_mtime,
_print,
)
self.mapping_data = mapping_data or {}
@@ -184,6 +186,7 @@ class XHS:
+ self.CLEANER.filter_name(container["作者昵称"]),
name,
container["作品类型"],
container["时间戳"],
log,
bar,
)

View File

@@ -65,6 +65,7 @@ class Download:
self.video_download = manager.video_download
self.live_download = manager.live_download
self.author_archive = manager.author_archive
self.write_mtime = manager.write_mtime
async def run(
self,
@@ -74,6 +75,7 @@ class Download:
nickname: str,
filename: str,
type_: str,
mtime: int,
log,
bar,
) -> tuple[Path, list[Any]]:
@@ -102,6 +104,7 @@ class Download:
path,
name,
format_,
mtime,
log,
bar,
)
@@ -198,6 +201,7 @@ class Download:
path: Path,
name: str,
format_: str,
mtime: int,
log,
bar,
):
@@ -253,7 +257,12 @@ class Download:
format_,
log,
)
self.manager.move(temp, real)
self.manager.move(
temp,
real,
mtime,
self.write_mtime,
)
# self.__create_progress(bar, None)
logging(log, _("文件 {0} 下载成功").format(real.name))
return True
@@ -321,8 +330,8 @@ class Download:
headers["Range"] = f"bytes={(p := self.__get_resume_byte_position(file))}-"
return p
@staticmethod
async def __suffix_with_file(
self,
temp: Path,
path: Path,
name: str,

View File

@@ -62,6 +62,9 @@ class Explore:
if (last := data.safe_extract("lastUpdateTime"))
else _("未知")
)
container["时间戳"] = (
(time / 1000) if (time := data.safe_extract("time")) else None
)
@staticmethod
def __extract_user(container: dict, data: Namespace):