Commit eb38424d authored by Francesco Poldi's avatar Francesco Poldi

Added retweet_date

parent fcddc135
VERSION = (2, 1, 0) VERSION = (2, 1, 1)
__version__ = '.'.join(map(str, VERSION)) __version__ = '.'.join(map(str, VERSION))
...@@ -3,6 +3,8 @@ import sys ...@@ -3,6 +3,8 @@ import sys
import time import time
import hashlib import hashlib
from datetime import datetime
def Conn(database): def Conn(database):
if database: if database:
print("[+] Inserting into Database: " + str(database)) print("[+] Inserting into Database: " + str(database))
...@@ -91,6 +93,7 @@ def init(db): ...@@ -91,6 +93,7 @@ def init(db):
username text not null, username text not null,
tweet_id integer not null, tweet_id integer not null,
retweet_id integer not null, retweet_id integer not null,
retweet_date integer not null,
CONSTRAINT retweets_pk PRIMARY KEY(user_id, tweet_id), CONSTRAINT retweets_pk PRIMARY KEY(user_id, tweet_id),
CONSTRAINT user_id_fk FOREIGN KEY(user_id) REFERENCES users(id), CONSTRAINT user_id_fk FOREIGN KEY(user_id) REFERENCES users(id),
CONSTRAINT tweet_id_fk FOREIGN KEY(tweet_id) REFERENCES tweets(id) CONSTRAINT tweet_id_fk FOREIGN KEY(tweet_id) REFERENCES tweets(id)
...@@ -270,8 +273,9 @@ def tweets(conn, Tweet, config): ...@@ -270,8 +273,9 @@ def tweets(conn, Tweet, config):
cursor.execute(query, (config.User_id, Tweet.id)) cursor.execute(query, (config.User_id, Tweet.id))
if Tweet.retweet: if Tweet.retweet:
query = 'INSERT INTO retweets VALUES(?,?,?,?)' query = 'INSERT INTO retweets VALUES(?,?,?,?,?)'
cursor.execute(query, (int(Tweet.user_rt_id), Tweet.user_rt, Tweet.id, int(Tweet.retweet_id))) _d = datetime.timestamp(datetime.strptime(Tweet.retweet_date, "%Y-%m-%d %H:%M:%S"))
cursor.execute(query, (int(Tweet.user_rt_id), Tweet.user_rt, Tweet.id, int(Tweet.retweet_id), _d))
if Tweet.reply_to: if Tweet.reply_to:
for reply in Tweet.reply_to: for reply in Tweet.reply_to:
......
...@@ -95,7 +95,8 @@ def update(object, config): ...@@ -95,7 +95,8 @@ def update(object, config):
"user_rt_id": Tweet.user_rt_id, "user_rt_id": Tweet.user_rt_id,
"user_rt": Tweet.user_rt, "user_rt": Tweet.user_rt,
"retweet_id": Tweet.retweet_id, "retweet_id": Tweet.retweet_id,
"reply_to": Tweet.reply_to "reply_to": Tweet.reply_to,
"retweet_date": Tweet.retweet_date
} }
_object_blocks[_type].append(_data) _object_blocks[_type].append(_data)
elif _type == "user": elif _type == "user":
......
...@@ -29,7 +29,8 @@ def tweetData(t): ...@@ -29,7 +29,8 @@ def tweetData(t):
"user_rt_id": t.user_rt_id, "user_rt_id": t.user_rt_id,
"user_rt": t.user_rt, "user_rt": t.user_rt,
"retweet_id": t.retweet_id, "retweet_id": t.retweet_id,
"reply_to": t.reply_to "reply_to": t.reply_to,
"retweet_date": t.retweet_date
} }
return data return data
...@@ -64,7 +65,8 @@ def tweetFieldnames(): ...@@ -64,7 +65,8 @@ def tweetFieldnames():
"user_rt_id", "user_rt_id",
"user_rt", "user_rt",
"retweet_id", "retweet_id",
"reply_to" "reply_to",
"retweet_date"
] ]
return fieldnames return fieldnames
......
from time import strftime, localtime from time import strftime, localtime
from datetime import datetime
import json import json
import logging as logme import logging as logme
...@@ -98,6 +99,7 @@ def Tweet(tw, config): ...@@ -98,6 +99,7 @@ def Tweet(tw, config):
t.user_rt_id, t.user_rt = getRetweet(tw) t.user_rt_id, t.user_rt = getRetweet(tw)
t.retweet = True if t.user_rt else False t.retweet = True if t.user_rt else False
t.retweet_id = tw['data-retweet-id'] if t.user_rt else '' t.retweet_id = tw['data-retweet-id'] if t.user_rt else ''
t.retweet_date = datetime.fromtimestamp(((t.id >> 22) + 1288834974657)/1000.0).strftime("%Y-%m-%d %H:%M:%S") if t.user_rt else ''
t.quote_url = getQuoteURL(tw) t.quote_url = getQuoteURL(tw)
t.near = config.Near if config.Near else "" t.near = config.Near if config.Near else ""
t.geo = config.Geo if config.Geo else "" t.geo = config.Geo if config.Geo else ""
......
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