29 lines
674 B
Python
29 lines
674 B
Python
import requests as python_requests
|
|
|
|
discussionPrefix = "https://talk.zhdo.space/topic/"
|
|
|
|
|
|
def getRecentArticle():
|
|
# TODO fetch latest article
|
|
recent = {"title": "N/A", "link": "#"}
|
|
return recent
|
|
|
|
|
|
def getRecentDiscussion():
|
|
recent = {"title": "N/A", "link": "#"}
|
|
obj = python_requests.get("https://talk.zhdo.space/api/recent/posts/week")
|
|
if obj.status_code == 200:
|
|
recent["title"] = str(obj.json()[0]["topic"]["title"])
|
|
recent["link"] = discussionPrefix + str(obj.json()[0]["topic"]["slug"])
|
|
return recent
|
|
else:
|
|
return "error"
|
|
|
|
|
|
def main():
|
|
print(getRecentDiscussion())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|