Skip to content
Permalink
Browse files

Added retweet_date

  • Loading branch information...
pielco11 committed Aug 14, 2019
1 parent 8d995df commit a70910724fd08ed47cd0226d0a148c4b26ddbe54
Showing with 15 additions and 6 deletions.
  1. +1 −1 twint/__version__.py
  2. +6 −2 twint/storage/db.py
  3. +2 −1 twint/storage/panda.py
  4. +4 −2 twint/storage/write_meta.py
  5. +2 −0 twint/tweet.py
@@ -1,3 +1,3 @@
VERSION = (2, 1, 0)
VERSION = (2, 1, 1)

__version__ = '.'.join(map(str, VERSION))
@@ -3,6 +3,8 @@
import time
import hashlib

from datetime import datetime

def Conn(database):
if database:
print("[+] Inserting into Database: " + str(database))
@@ -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)
@@ -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:
@@ -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":
@@ -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

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

@@ -1,4 +1,5 @@
from time import strftime, localtime
from datetime import datetime
import json

import logging as logme
@@ -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 ""

0 comments on commit a709107

Please sign in to comment.
You can’t perform that action at this time.