Added kahoot-import

This commit is contained in:
Mawoka
2022-03-08 21:42:44 +01:00
parent 5c5386fdf8
commit 4f4b38d8b0
5 changed files with 47 additions and 9 deletions
+7 -2
View File
@@ -9,7 +9,12 @@ class _Response(BaseModel):
kahoot: _Kahoot
async def get(game_id: str) -> _Response:
async def get(game_id: str) -> _Response | None:
async with ClientSession() as session:
async with session.get(f"https://create.kahoot.it/rest/kahoots/{game_id}/card/?includeKahoot=true") as response:
return _Response(**await response.json())
if response.status == 200:
return _Response(**await response.json())
elif response.status == 404:
return None
else:
raise Exception(f"Unexpected response status: {response.status}")