From cef5429cdc8e4501aa745b104daac86631df37d1 Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Sat, 7 Jun 2025 17:16:18 -0600 Subject: [PATCH] fix tweet cursor --- src/parser.nim | 2 +- src/parserutils.nim | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/parser.nim b/src/parser.nim index 2843236..2f4236e 100644 --- a/src/parser.nim +++ b/src/parser.nim @@ -588,7 +588,7 @@ proc parseGraphConversation*(js: JsonNode; tweetId: string): Conversation = else: result.replies.content.add thread elif entryId.startsWith("cursor-bottom"): - result.replies.bottom = e{"content", "value"}.getStr + result.replies.bottom = e.getCursor proc parseGraphTimeline*(js: JsonNode; root: string; after=""): Profile = result = Profile(tweets: Timeline(beginning: after.len == 0)) diff --git a/src/parserutils.nim b/src/parserutils.nim index 1d1fa15..786b326 100644 --- a/src/parserutils.nim +++ b/src/parserutils.nim @@ -48,7 +48,13 @@ template with*(ident; value: JsonNode; body): untyped = if notNull(value): body template getCursor*(js: JsonNode): string = - js{"content", "operation", "cursor", "value"}.getStr + var cursor = js{"content", "operation", "cursor", "value"} + if cursor.isNull: + cursor = js{"content", "value"} + if cursor.isNull: + cursor = js{"content", "itemContent", "value"} + + cursor.getStr template getError*(js: JsonNode): Error = if js.kind != JArray or js.len == 0: null