From d5061bde059824dc9b8717b5a1e5e22f8921531c Mon Sep 17 00:00:00 2001 From: Zed Date: Sat, 19 Oct 2019 07:14:29 +0200 Subject: [PATCH] Fix nil tweet time crash --- src/parserutils.nim | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/parserutils.nim b/src/parserutils.nim index d8a3efd..f82e4f6 100644 --- a/src/parserutils.nim +++ b/src/parserutils.nim @@ -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)