Skip to content

Commit

Permalink
Fix nil tweet time crash
Browse files Browse the repository at this point in the history
  • Loading branch information
zedeus committed Oct 19, 2019
1 parent e73963f commit d5061bd
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/parserutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,12 @@ proc getTweetText*(tweet: XmlNode): string =
link = text.selectAttr("a.twitter-timeline-link.u-hidden", "data-expanded-url")
parseText(text, if quote != nil: link else: "")

proc getTime(tweet: XmlNode): XmlNode =
tweet.select(".js-short-timestamp")

proc getTimestamp*(tweet: XmlNode): Time =
let time = getTime(tweet).attr("data-time")
let time = tweet.selectAttr(".js-short-timestamp", "data-time")
fromUnix(if time.len > 0: parseInt(time) else: 0)

proc getShortTime*(tweet: XmlNode): string =
getTime(tweet).innerText()
tweet.selectText(".js-short-timestamp")

proc getDate*(node: XmlNode; selector: string): Time =
let date = node.select(selector)
Expand Down

0 comments on commit d5061bd

Please sign in to comment.