Fix tweet tags being shown as unavailable tweets
This commit is contained in:
parent
e2039ec81c
commit
9dc4b240e7
3 changed files with 8 additions and 7 deletions
|
@ -188,10 +188,11 @@ proc getTimeline*(username: string; after=""): Future[Timeline] {.async.} =
|
||||||
minId: json.getOrDefault("min_position").getStr(""),
|
minId: json.getOrDefault("min_position").getStr(""),
|
||||||
)
|
)
|
||||||
|
|
||||||
if json["new_latent_count"].to(int) == 0:
|
if json["new_latent_count"].to(int) == 0: return
|
||||||
return
|
if not json.hasKey("items_html"): return
|
||||||
|
|
||||||
let html = parseHtml(json["items_html"].to(string))
|
let html = parseHtml(json["items_html"].to(string))
|
||||||
|
|
||||||
result.tweets = parseTweets(html)
|
result.tweets = parseTweets(html)
|
||||||
await getVideos(result.tweets)
|
await getVideos(result.tweets)
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,9 @@ proc parseTweet*(node: XmlNode): Tweet =
|
||||||
|
|
||||||
proc parseTweets*(node: XmlNode): Tweets =
|
proc parseTweets*(node: XmlNode): Tweets =
|
||||||
if node == nil or node.kind == xnText: return
|
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 =
|
proc parseConversation*(node: XmlNode): Conversation =
|
||||||
result = Conversation(
|
result = Conversation(
|
||||||
|
|
|
@ -140,8 +140,7 @@ proc getTweetMedia*(tweet: Tweet; node: XmlNode) =
|
||||||
tweet.photos.add photo.attrs["data-image-url"]
|
tweet.photos.add photo.attrs["data-image-url"]
|
||||||
|
|
||||||
let player = node.select(".PlayableMedia")
|
let player = node.select(".PlayableMedia")
|
||||||
if player == nil:
|
if player == nil: return
|
||||||
return
|
|
||||||
|
|
||||||
if "gif" in player.attr("class"):
|
if "gif" in player.attr("class"):
|
||||||
tweet.gif = some(getGif(player.select(".PlayableMedia-player")))
|
tweet.gif = some(getGif(player.select(".PlayableMedia-player")))
|
||||||
|
@ -149,8 +148,7 @@ proc getTweetMedia*(tweet: Tweet; node: XmlNode) =
|
||||||
tweet.video = some(Video())
|
tweet.video = some(Video())
|
||||||
|
|
||||||
proc getQuoteMedia*(quote: var Quote; node: XmlNode) =
|
proc getQuoteMedia*(quote: var Quote; node: XmlNode) =
|
||||||
let sensitive = node.select(".QuoteTweet--sensitive")
|
if node.select(".QuoteTweet--sensitive") != nil:
|
||||||
if sensitive != nil:
|
|
||||||
quote.sensitive = true
|
quote.sensitive = true
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue