it simply is not going to work. No matter how much I want it to.

This commit is contained in:
Greg Gauthier 2025-04-13 12:43:20 +01:00
parent 96a8838d1d
commit 64ac85026f
2 changed files with 34 additions and 1 deletions

22
examples/show_category.py Normal file
View 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()

View File

@ -7,3 +7,14 @@ class Categories:
16: "No Politics",
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