Commit 14afb322 authored by Cody Zacharias's avatar Cody Zacharias Committed by GitHub

Fix date check

parent 0c379c62
...@@ -46,12 +46,8 @@ def writeJSON(Tweet, file): ...@@ -46,12 +46,8 @@ def writeJSON(Tweet, file):
json.dump(data, json_file) json.dump(data, json_file)
json_file.write("\n") json_file.write("\n")
def getDate(tweet, config): def getDate(tweet):
datestamp = tweet.find("a", "tweet-timestamp")["title"] datestamp = tweet.find("a", "tweet-timestamp")["title"]
if config.Since and config.Until:
if (datestamp.date() - datetime.datetime.strptime(date.Since, "%Y-%m-%d").date()).days == -1:
# mitigation here, maybe find something better
sys.exit(0)
datestamp = datestamp.rpartition(" - ")[-1] datestamp = datestamp.rpartition(" - ")[-1]
return datetime.datetime.strptime(datestamp, "%d %b %Y") return datetime.datetime.strptime(datestamp, "%d %b %Y")
...@@ -92,7 +88,11 @@ def getMentions(tweet, text): ...@@ -92,7 +88,11 @@ def getMentions(tweet, text):
def getTweet(tw, config): def getTweet(tw, config):
t = Tweet() t = Tweet()
t.id = tw.find("div")["data-item-id"] t.id = tw.find("div")["data-item-id"]
t.date = getDate(tw, config) t.date = getDate(tw)
if config.Since and config.Until:
if (t.date.date() - datetime.datetime.strptime(config.Since, "%Y-%m-%d").date()).days == -1:
# mitigation here, maybe find something better
sys.exit(0)
t.datestamp = t.date.strftime("%Y-%m-%d") t.datestamp = t.date.strftime("%Y-%m-%d")
t.time = getTime(tw) t.time = getTime(tw)
t.timestamp = t.time.strftime("%H:%M:%S") t.timestamp = t.time.strftime("%H:%M:%S")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment