From d889fdff208f5c1bc9031b2e20028bd05fbc5b6f Mon Sep 17 00:00:00 2001 From: simonwt Date: Tue, 31 Mar 2026 12:10:15 +0100 Subject: [PATCH] List comments by post --- jobs/comment/__init__.py | 3 ++- jobs/comment/listtbypostid.py | 12 ++++++++++++ testing.py | 35 +++++++++++++++++++---------------- 3 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 jobs/comment/listtbypostid.py diff --git a/jobs/comment/__init__.py b/jobs/comment/__init__.py index fd01b16..4f81e8a 100644 --- a/jobs/comment/__init__.py +++ b/jobs/comment/__init__.py @@ -1 +1,2 @@ -from .create import create \ No newline at end of file +from .create import create +from .listtbypostid import listtbypostid \ No newline at end of file diff --git a/jobs/comment/listtbypostid.py b/jobs/comment/listtbypostid.py new file mode 100644 index 0000000..bef5ba5 --- /dev/null +++ b/jobs/comment/listtbypostid.py @@ -0,0 +1,12 @@ +def listtbypostid(API, post_id: str,) -> dict: + """ + Fetches the list of comments for a given post ID from the API. + + Args: + post_id (str): ID of the post to fetch comments for. + Returns: + dict: The list of comments for the post. + """ + print(f"Fetching comments for post ID: {post_id}") + comment_list = API.make_request("GET", "content", f"comment/bypostid/{post_id}", authenticate=True) + return comment_list \ No newline at end of file diff --git a/testing.py b/testing.py index 387cfae..fa3776b 100644 --- a/testing.py +++ b/testing.py @@ -38,7 +38,7 @@ if not API.is_token_valid(): # branch = API.run_job('branch.get', "music") # print(branch) # print("-------------- Get a post -------------------") -# post = API.run_job('post.get', "1774875037-170a46a9") +# post = API.run_job('post.get', "1774951384-98fe38df") # print(post) # print("-----------------------------") # feed = API.run_job('post.listbybranch', "music") @@ -59,18 +59,21 @@ if not API.is_token_valid(): # }) # print(post) # print("-----------------------------") -post = API.run_job('comment.create', { - "blurLabel": None, - "commentText": "This is a test comment created via the API wrapper.", - "parent": { - "pk": "maintrunk#maintrunk", - "sk": "post#1774951384-98fe38df", - "slug": "1774951384-98fe38df" - }, - "topLevel": { - "pk": "maintrunk#maintrunk", - "sk": "post#1774951384-98fe38df" - }, - "version": 3 -}) -print(post) \ No newline at end of file +# post = API.run_job('comment.create', { +# "blurLabel": None, +# "commentText": "This is a test comment created via the API wrapper.", +# "parent": { +# "pk": "maintrunk#maintrunk", +# "sk": "post#1774951384-98fe38df", +# "slug": "1774951384-98fe38df" +# }, +# "topLevel": { +# "pk": "maintrunk#maintrunk", +# "sk": "post#1774951384-98fe38df" +# }, +# "version": 3 +# }) +# print(post) +# print("-----------------------------") +feed = API.run_job('comment.listtbypostid', "1774951384-98fe38df") +print(feed) \ No newline at end of file