Skip to content

Commit

Permalink
fix: update GetPost API, fixed get-post, download-post commands
Browse files Browse the repository at this point in the history
Closes #198, #180
  • Loading branch information
Ljzd-PRO committed Dec 3, 2024
1 parent a360b4c commit 6998437
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions ktoolbox/api/posts/get_post.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from pydantic import BaseModel

from ktoolbox.api import BaseAPI, APIRet
from ktoolbox.api.model import Post

Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions ktoolbox/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
)
Expand Down

0 comments on commit 6998437

Please sign in to comment.