From 6998437e3d496e979ab18f475c21da52b8d646d7 Mon Sep 17 00:00:00 2001 From: Ljzd-PRO <63289359+Ljzd-PRO@users.noreply.github.com> Date: Tue, 3 Dec 2024 23:41:29 +0800 Subject: [PATCH] fix: update `GetPost` API, fixed `get-post`, `download-post` commands Closes #198, #180 --- ktoolbox/api/posts/get_post.py | 8 +++++--- ktoolbox/cli.py | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ktoolbox/api/posts/get_post.py b/ktoolbox/api/posts/get_post.py index 51adddf..67b41d4 100644 --- a/ktoolbox/api/posts/get_post.py +++ b/ktoolbox/api/posts/get_post.py @@ -1,3 +1,5 @@ +from pydantic import BaseModel + from ktoolbox.api import BaseAPI, APIRet from ktoolbox.api.model import Post @@ -8,11 +10,11 @@ class GetPost(BaseAPI): path = "/{service}/user/{creator_id}/post/{post_id}" method = "get" - class Response(Post): - ... + class Response(BaseModel): + post: Post @classmethod - async def __call__(cls, service: str, creator_id: str, post_id: str) -> APIRet[Post]: + async def __call__(cls, service: str, creator_id: str, post_id: str) -> APIRet[Response]: """ Get a specific post diff --git a/ktoolbox/cli.py b/ktoolbox/cli.py index 855e7b3..97271d9 100644 --- a/ktoolbox/cli.py +++ b/ktoolbox/cli.py @@ -122,7 +122,7 @@ async def get_post(service: str, creator_id: str, post_id: str, *, dump: Path = await f.write( ret.data.json(indent=config.json_dump_indent) ) - return ret.data + return ret.data.post else: return ret.message @@ -187,9 +187,9 @@ async def download_post( post_id=post_id ) if ret: - post_path = path / generate_post_path_name(ret.data) + post_path = path / generate_post_path_name(ret.data.post) job_list = await create_job_from_post( - post=ret.data, + post=ret.data.post, post_path=post_path, dump_post_data=dump_post_data )