diff --git a/linktree.py b/linktree.py index 8f1b887..62443da 100644 --- a/linktree.py +++ b/linktree.py @@ -70,7 +70,13 @@ async def uncensorLinks(self, account_id : int, link_ids : Union[List[int], int] json_resp = await resp.json() await session.close() - _links = json_resp["links"] + json_resp = await resp.json() + if not json_resp or "links" not in json_resp: + await session.close() + return [] + + links = json_resp["links"] + links = [] for _link in _links: @@ -120,8 +126,7 @@ async def getLinktreeUserInfo(self, url : Optional[str] = None, username : Optio avatar_image = account["profilePictureUrl"] url = f"https://linktr.ee/{username}" if url is None else url id = account["id"] - tier = account["tier"] - isActive = account["isActive"] + tier = account.get("tier", "Unknown") createdAt = account["createdAt"] updatedAt = account["updatedAt"] description = account["description"] @@ -170,6 +175,5 @@ async def main(): if __name__ == "__main__": - loop = asyncio.get_event_loop() - loop.run_until_complete(main()) + asyncio.run(main())