it simply is not going to work. No matter how much I want it to.
This commit is contained in:
parent
96a8838d1d
commit
64ac85026f
22
examples/show_category.py
Normal file
22
examples/show_category.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
from lunduke.client import DiscourseClient
|
||||||
|
from lunduke.forum.mappings import Categories
|
||||||
|
|
||||||
|
def main():
|
||||||
|
client = DiscourseClient()
|
||||||
|
category_ids = Categories().get_all().keys()
|
||||||
|
# https://{defaultHost}/c/{id}/show.json
|
||||||
|
# TODO: FAILS: 403 - The API KEY DOES NOT ACKNOWLEDGE THAT I AM LOGGED IN
|
||||||
|
for cat_id in category_ids:
|
||||||
|
try:
|
||||||
|
response = client.get(f"/c/{cat_id}/show.json")
|
||||||
|
print(response.request.url)
|
||||||
|
print(response.request.headers)
|
||||||
|
print(response.status_code)
|
||||||
|
print(response.json())
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error: {e}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
@ -6,4 +6,15 @@ class Categories:
|
|||||||
15: "Politics OK",
|
15: "Politics OK",
|
||||||
16: "No Politics",
|
16: "No Politics",
|
||||||
23: "Forum Stuff"
|
23: "Forum Stuff"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def get_category_name(self, category_id):
|
||||||
|
return self.categories.get(category_id, "Unknown")
|
||||||
|
|
||||||
|
def get_category_id(self, category_name):
|
||||||
|
for category_id, category_name in self.categories.items():
|
||||||
|
if category_name == category_name:
|
||||||
|
return category_id
|
||||||
|
|
||||||
|
def get_all(self):
|
||||||
|
return self.categories
|
||||||
|
Loading…
Reference in New Issue
Block a user