List posts by branch
This commit is contained in:
parent
8e8de42d15
commit
6c69c6d6c8
3 changed files with 24 additions and 9 deletions
|
|
@ -1,2 +1,2 @@
|
|||
from .get import get
|
||||
from .get import get
|
||||
from .listbybranch import listbybranch
|
||||
12
jobs/post/listbybranch.py
Normal file
12
jobs/post/listbybranch.py
Normal 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
|
||||
19
testing.py
19
testing.py
|
|
@ -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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue