List posts by branch

This commit is contained in:
simonwt 2026-03-31 10:25:52 +01:00
parent 8e8de42d15
commit 6c69c6d6c8
3 changed files with 24 additions and 9 deletions

View file

@ -1,2 +1,2 @@
from .get import get
from .get import get
from .listbybranch import listbybranch

12
jobs/post/listbybranch.py Normal file
View file

@ -0,0 +1,12 @@
def listbybranch(API, branch_slug: str,) -> dict:
"""
Fetches the list of posts for a given branch from the API.
Args:
branch_slug (str): Slug of the branch to fetch posts for.
Returns:
dict: The list of posts for the branch.
"""
print(f"Fetching posts for branch: {branch_slug}")
post_list = API.make_request("GET", "content", f"post/ref-subwiki/{branch_slug}", authenticate=True)
return post_list

View file

@ -31,11 +31,14 @@ if not API.is_token_valid():
with open("token_data.json", "w") as f:
json.dump(tokendata, f, indent=4)
profile = API.run_job('userprofile.get', "simon-little")
print(profile)
print("-----------------------------")
branch = API.run_job('branch.get', "music")
print(branch)
print("-----------------------------")
post = API.run_job('post.get', "1774875037-170a46a9")
print(post)
# profile = API.run_job('userprofile.get', "simon-little")
# print(profile)
# print("-----------------------------")
# branch = API.run_job('branch.get', "music")
# print(branch)
# print("-----------------------------")
# post = API.run_job('post.get', "1774875037-170a46a9")
# print(post)
# print("-----------------------------")
feed = API.run_job('post.listbybranch', "music")
print(feed)