diff --git a/src/parser.nim b/src/parser.nim index a6d030e..da10d85 100644 --- a/src/parser.nim +++ b/src/parser.nim @@ -63,11 +63,11 @@ proc parseTweet*(node: XmlNode): Tweet = time: getTimestamp(tweet), shortTime: getShortTime(tweet), profile: parseTweetProfile(tweet), + stats: parseTweetStats(tweet), pinned: "pinned" in tweet.attr("class"), available: true ) - result.getTweetStats(tweet) result.getTweetMedia(tweet) result.getTweetCards(tweet) diff --git a/src/parserutils.nim b/src/parserutils.nim index f9fa80a..f7ba651 100644 --- a/src/parserutils.nim +++ b/src/parserutils.nim @@ -111,16 +111,14 @@ proc getIntentStats*(profile: var Profile; node: XmlNode) = of "followers": profile.followers = text of "following": profile.following = text -proc getTweetStats*(tweet: Tweet; node: XmlNode) = - tweet.replies = "0" - tweet.retweets = "0" - tweet.likes = "0" +proc parseTweetStats*(node: XmlNode): TweetStats = + result = TweetStats(replies: "0", retweets: "0", likes: "0") for action in node.selectAll(".ProfileTweet-actionCountForAria"): let text = action.innerText.split() case text[1][0 .. 2] - of "ret": tweet.retweets = text[0] - of "rep": tweet.replies = text[0] - of "lik": tweet.likes = text[0] + of "ret": result.retweets = text[0] + of "rep": result.replies = text[0] + of "lik": result.likes = text[0] proc getGif(player: XmlNode): Gif = let diff --git a/src/types.nim b/src/types.nim index de15075..4758f80 100644 --- a/src/types.nim +++ b/src/types.nim @@ -66,23 +66,26 @@ type by*: string id*: string + TweetStats* = object + replies*: string + retweets*: string + likes*: string + Tweet* = ref object id*: string profile*: Profile text*: string time*: Time shortTime*: string - replies*: string - retweets*: string - likes*: string + available*: bool pinned*: bool + stats*: TweetStats retweet*: Option[Retweet] quote*: Option[Quote] gif*: Option[Gif] video*: Option[Video] photos*: seq[string] poll*: Option[Poll] - available*: bool Thread* = object tweets*: seq[Tweet] diff --git a/src/views/tweet.nimf b/src/views/tweet.nimf index 7ff9603..9f9e7a7 100644 --- a/src/views/tweet.nimf +++ b/src/views/tweet.nimf @@ -132,11 +132,11 @@ #end proc # -#proc renderStats(tweet: Tweet): string = +#proc renderStats(stats: TweetStats): string =