Fix parsing censored tweets

This commit is contained in:
Zed
2020-11-07 22:48:49 +01:00
parent 509e1dc5e8
commit 2d7e12fcb8
2 changed files with 17 additions and 5 deletions

View File

@@ -55,6 +55,18 @@ proc getId*(js: JsonNode): int64 {.inline.} =
of JInt: return js.getBiggestInt()
else: return 0
proc getEntryId*(js: JsonNode): string {.inline.} =
let entry = js{"entryId"}.getStr
if entry.len == 0: return
if "tweet" in entry:
return entry.getId
elif "tombstone" in entry:
return js{"content", "item", "content", "tombstone", "tweet", "id"}.getStr
else:
echo "unknown entry: ", entry
return
template getStrVal*(js: JsonNode; default=""): string =
js{"string_value"}.getStr(default)