Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Commit

Permalink
Added retweet_date
Browse files Browse the repository at this point in the history
  • Loading branch information
pielco11 committed Aug 14, 2019
1 parent 8d995df commit a709107
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion twint/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION = (2, 1, 0)
VERSION = (2, 1, 1)

__version__ = '.'.join(map(str, VERSION))
8 changes: 6 additions & 2 deletions twint/storage/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import time
import hashlib

from datetime import datetime

def Conn(database):
if database:
print("[+] Inserting into Database: " + str(database))
Expand Down Expand Up @@ -91,6 +93,7 @@ def init(db):
username text not null,
tweet_id integer not null,
retweet_id integer not null,
retweet_date integer not null,
CONSTRAINT retweets_pk PRIMARY KEY(user_id, tweet_id),
CONSTRAINT user_id_fk FOREIGN KEY(user_id) REFERENCES users(id),
CONSTRAINT tweet_id_fk FOREIGN KEY(tweet_id) REFERENCES tweets(id)
Expand Down Expand Up @@ -270,8 +273,9 @@ def tweets(conn, Tweet, config):
cursor.execute(query, (config.User_id, Tweet.id))

if Tweet.retweet:
query = 'INSERT INTO retweets VALUES(?,?,?,?)'
cursor.execute(query, (int(Tweet.user_rt_id), Tweet.user_rt, Tweet.id, int(Tweet.retweet_id)))
query = 'INSERT INTO retweets VALUES(?,?,?,?,?)'
_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:
for reply in Tweet.reply_to:
Expand Down
3 changes: 2 additions & 1 deletion twint/storage/panda.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def update(object, config):
"user_rt_id": Tweet.user_rt_id,
"user_rt": Tweet.user_rt,
"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)
elif _type == "user":
Expand Down
6 changes: 4 additions & 2 deletions twint/storage/write_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def tweetData(t):
"user_rt_id": t.user_rt_id,
"user_rt": t.user_rt,
"retweet_id": t.retweet_id,
"reply_to": t.reply_to
"reply_to": t.reply_to,
"retweet_date": t.retweet_date
}
return data

Expand Down Expand Up @@ -64,7 +65,8 @@ def tweetFieldnames():
"user_rt_id",
"user_rt",
"retweet_id",
"reply_to"
"reply_to",
"retweet_date"
]
return fieldnames

Expand Down
2 changes: 2 additions & 0 deletions twint/tweet.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from time import strftime, localtime
from datetime import datetime
import json

import logging as logme
Expand Down Expand Up @@ -98,6 +99,7 @@ def Tweet(tw, config):
t.user_rt_id, t.user_rt = getRetweet(tw)
t.retweet = True if t.user_rt else False
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.near = config.Near if config.Near else ""
t.geo = config.Geo if config.Geo else ""
Expand Down

0 comments on commit a709107

Please sign in to comment.