mirror of
https://github.com/zedeus/nitter.git
synced 2024-12-12 02:56:29 +00:00
Fix parsing censored tweets
This commit is contained in:
parent
509e1dc5e8
commit
2d7e12fcb8
2 changed files with 17 additions and 5 deletions
|
@ -328,7 +328,7 @@ proc parseThread(js: JsonNode; global: GlobalObjects): tuple[thread: Chain, self
|
|||
else:
|
||||
result.thread.more = -1
|
||||
else:
|
||||
var tweet = finalizeTweet(global, entry.getId)
|
||||
var tweet = finalizeTweet(global, t.getEntryId)
|
||||
if not tweet.available:
|
||||
tweet.tombstone = getTombstone(content{"tombstone"})
|
||||
result.thread.content.add tweet
|
||||
|
@ -343,8 +343,8 @@ proc parseConversation*(js: JsonNode; tweetId: string): Conversation =
|
|||
|
||||
for e in instructions[0]{"addEntries", "entries"}:
|
||||
let entry = e{"entryId"}.getStr
|
||||
if "tweet" in entry:
|
||||
let tweet = finalizeTweet(global, entry.getId)
|
||||
if "tweet" in entry or "tombstone" in entry:
|
||||
let tweet = finalizeTweet(global, e.getEntryId)
|
||||
if $tweet.id != tweetId:
|
||||
result.before.content.add tweet
|
||||
else:
|
||||
|
@ -408,8 +408,8 @@ proc parseTimeline*(js: JsonNode; after=""): Timeline =
|
|||
|
||||
for e in instructions[0]{"addEntries", "entries"}:
|
||||
let entry = e{"entryId"}.getStr
|
||||
if "tweet" in entry or "sq-I-t" in entry:
|
||||
let tweet = finalizeTweet(global, entry.getId)
|
||||
if "tweet" in entry or "sq-I-t" in entry or "tombstone" in entry:
|
||||
let tweet = finalizeTweet(global, e.getEntryId)
|
||||
if not tweet.available: continue
|
||||
result.content.add tweet
|
||||
elif "cursor-top" in entry:
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue