From 92dd28c815599269eea8eac94897e00552f30f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=A8?= Date: Mon, 12 May 2025 19:15:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E9=9F=B3=E4=B9=90?= =?UTF-8?q?=E5=9B=BE=E9=9B=86=E4=BD=9C=E5=93=81=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/application/app.py | 6 +++++- source/application/explore.py | 17 +++++++++++------ source/application/image.py | 2 +- source/module/static.py | 4 ++-- static/Release_Notes.md | 2 ++ 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/source/application/app.py b/source/application/app.py index f914cc9..1a6c69f 100644 --- a/source/application/app.py +++ b/source/application/app.py @@ -315,9 +315,13 @@ class XHS: return {} if data["作品类型"] == _("视频"): self.__extract_video(data, namespace) - elif data["作品类型"] == _("图文"): + elif data["作品类型"] in { + _("图文"), + _("图集"), + }: self.__extract_image(data, namespace) else: + logging(log, _("未知的作品类型:{0}").format(i), WARNING) data["下载地址"] = [] await self.update_author_nickname(data, log) await self.__download_files(data, download, index, log, bar) diff --git a/source/application/explore.py b/source/application/explore.py index 6902b12..5afe43d 100644 --- a/source/application/explore.py +++ b/source/application/explore.py @@ -9,9 +9,6 @@ __all__ = ["Explore"] class Explore: time_format = "%Y-%m-%d_%H:%M:%S" - def __init__(self): - self.explore_type = {"video": _("视频"), "normal": _("图文")} - def run(self, data: Namespace) -> dict: return self.__extract_data(data) @@ -46,9 +43,7 @@ class Explore: ) container["作品标题"] = data.safe_extract("title") container["作品描述"] = data.safe_extract("desc") - container["作品类型"] = self.explore_type.get( - data.safe_extract("type"), _("未知") - ) + container["作品类型"] = self.__classify_works(data) # container["IP归属地"] = data.safe_extract("ipLocation") def __extract_time(self, container: dict, data: Namespace): @@ -73,3 +68,13 @@ class Explore: container["作者链接"] = ( f"https://www.xiaohongshu.com/user/profile/{container['作者ID']}" ) + + @staticmethod + def __classify_works(data: Namespace) -> str: + type_ = data.safe_extract("type") + list_ = data.safe_extract("imageList", []) + if type_ not in {"video", "normal"} or len(list_) == 0: + return _("未知") + if type_ == "video": + return _("视频") if len(list_) == 1 else _("图集") + return _("图文") diff --git a/source/application/image.py b/source/application/image.py index 2e2b0a3..30ac4b9 100644 --- a/source/application/image.py +++ b/source/application/image.py @@ -7,7 +7,7 @@ __all__ = ["Image"] class Image: @classmethod - def get_image_link(cls, data: Namespace, format_: str) -> [list, list]: + def get_image_link(cls, data: Namespace, format_: str) -> tuple[list, list]: images = data.safe_extract("imageList", []) live_link = cls.__get_live_link(images) token_list = [ diff --git a/source/module/static.py b/source/module/static.py index 09c9ab3..079abe9 100644 --- a/source/module/static.py +++ b/source/module/static.py @@ -1,8 +1,8 @@ from pathlib import Path VERSION_MAJOR = 2 -VERSION_MINOR = 5 -VERSION_BETA = False +VERSION_MINOR = 6 +VERSION_BETA = True __VERSION__ = f"{VERSION_MAJOR}.{VERSION_MINOR}.{'beta' if VERSION_BETA else 'stable'}" ROOT = Path(__file__).resolve().parent.parent.parent PROJECT = f"XHS-Downloader V{VERSION_MAJOR}.{VERSION_MINOR} { diff --git a/static/Release_Notes.md b/static/Release_Notes.md index 6165140..133a733 100644 --- a/static/Release_Notes.md +++ b/static/Release_Notes.md @@ -1,5 +1,7 @@ **项目更新内容:** +1. 支持音乐图集作品下载 + ***** **用户脚本更新内容:**