From f24c892471549289663e6354df0ad13b016a6681 Mon Sep 17 00:00:00 2001 From: Relakkes Date: Sat, 18 Nov 2023 11:18:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E5=AF=BC=E8=87=B4=E7=A8=8B=E5=BA=8F=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E9=80=80=E5=87=BA=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- media_platform/xhs/client.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/media_platform/xhs/client.py b/media_platform/xhs/client.py index 0064359..575c555 100644 --- a/media_platform/xhs/client.py +++ b/media_platform/xhs/client.py @@ -186,6 +186,14 @@ class XHSClient: comments_res = await self.get_note_comments(note_id, comments_cursor) comments_has_more = comments_res.get("has_more", False) comments_cursor = comments_res.get("cursor", "") + # thanks, @Akiqqqqqqq fix it issue + # Check if 'comments' key exists in the response + if "comments" not in comments_res: + # Handle the absence of 'comments' key appropriately + # For example, log an error message, break from the loop, etc. + # This is just an example: + print(f"No 'comments' key found in response: {comments_res}") + break comments = comments_res["comments"] if not is_fetch_sub_comments: result.extend(comments)