mirror of
https://github.com/JoeanAmier/XHS-Downloader.git
synced 2026-03-22 06:57:16 +08:00
refactor(app): 重构数据处理逻辑
This commit is contained in:
@@ -199,7 +199,7 @@ class XHS:
|
||||
container: dict,
|
||||
data: Namespace,
|
||||
):
|
||||
container["下载地址"] = self.video.get_video_link(
|
||||
container["下载地址"] = self.video.deal_video_link(
|
||||
data,
|
||||
)
|
||||
container["动图地址"] = [
|
||||
|
||||
@@ -10,10 +10,16 @@ class Image:
|
||||
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 = [
|
||||
cls.__extract_image_token(Namespace.object_extract(i, "urlDefault"))
|
||||
for i in images
|
||||
]
|
||||
if not any(
|
||||
token_list := [
|
||||
cls.__extract_image_token(Namespace.object_extract(i, "urlDefault"))
|
||||
for i in images
|
||||
]
|
||||
):
|
||||
token_list = [
|
||||
cls.__extract_image_token(Namespace.object_extract(i, "url"))
|
||||
for i in images
|
||||
]
|
||||
match format_:
|
||||
case "png" | "webp" | "jpeg" | "heic" | "avif":
|
||||
return [
|
||||
|
||||
@@ -11,6 +11,14 @@ class Video:
|
||||
"originVideoKey",
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def deal_video_link(
|
||||
cls,
|
||||
data: Namespace,
|
||||
preference="resolution",
|
||||
):
|
||||
return cls.generate_video_link(data) or cls.get_video_link(data, preference)
|
||||
|
||||
@classmethod
|
||||
def generate_video_link(cls, data: Namespace) -> list:
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user