Fix tweet tags being shown as unavailable tweets

This commit is contained in:
Zed 2019-06-27 21:48:59 +02:00
parent e2039ec81c
commit 9dc4b240e7
3 changed files with 8 additions and 7 deletions

View file

@ -188,10 +188,11 @@ proc getTimeline*(username: string; after=""): Future[Timeline] {.async.} =
minId: json.getOrDefault("min_position").getStr(""),
)
if json["new_latent_count"].to(int) == 0:
return
if json["new_latent_count"].to(int) == 0: return
if not json.hasKey("items_html"): return
let html = parseHtml(json["items_html"].to(string))
result.tweets = parseTweets(html)
await getVideos(result.tweets)

View file

@ -83,7 +83,9 @@ proc parseTweet*(node: XmlNode): Tweet =
proc parseTweets*(node: XmlNode): Tweets =
if node == nil or node.kind == xnText: return
node.selectAll(".stream-item").map(parseTweet)
for n in node.selectAll(".stream-item"):
if "account" notin n.child("div").attr("class"):
result.add parseTweet(n)
proc parseConversation*(node: XmlNode): Conversation =
result = Conversation(

View file

@ -140,8 +140,7 @@ proc getTweetMedia*(tweet: Tweet; node: XmlNode) =
tweet.photos.add photo.attrs["data-image-url"]
let player = node.select(".PlayableMedia")
if player == nil:
return
if player == nil: return
if "gif" in player.attr("class"):
tweet.gif = some(getGif(player.select(".PlayableMedia-player")))
@ -149,8 +148,7 @@ proc getTweetMedia*(tweet: Tweet; node: XmlNode) =
tweet.video = some(Video())
proc getQuoteMedia*(quote: var Quote; node: XmlNode) =
let sensitive = node.select(".QuoteTweet--sensitive")
if sensitive != nil:
if node.select(".QuoteTweet--sensitive") != nil:
quote.sensitive = true
return