Commit 53f4d009 authored by Francesco Poldi's avatar Francesco Poldi Committed by GitHub

Merge branch 'dev' into master

parents 1e51ef60 8f8731de
......@@ -195,6 +195,9 @@ def main():
if not args.index_users:
args.index_users = "twintUser"
if not args.essid:
args.essid = ""
c = initialize(args)
if args.favorites:
......
VERSION = (1, 1, 3, 4) #mysql support
VERSION = (1, 1, 3, 5) #mysql support
__version__ = '.'.join(map(str, VERSION))
......@@ -29,7 +29,7 @@ class Config:
All = None
Debug = False
Format = None
Essid = None
Essid = ""
Profile = False
Followers = False
Following = False
......@@ -42,6 +42,6 @@ class Config:
Pandas_type = None
Pandas = False
Search_name = "-" #for identify a records in mysql with the search it provides from. it cannot be null for DB requirements. a tweet must be in several search so the PK are tweet ID and search_name
Index_tweets = None
Index_follow = None
Index_users = None
Index_tweets = "twint"
Index_follow = "twintGraph"
Index_users = "twintUser"
\ No newline at end of file
......@@ -91,7 +91,7 @@ def init(db):
);
"""
cursor.execute(table_followers)
table_following = """
CREATE TABLE IF NOT EXISTS
following (
......@@ -127,7 +127,7 @@ def fTable(Followers):
table = "followers_names"
else:
table = "following_names"
return table
def uTable(Followers):
......@@ -135,7 +135,7 @@ def uTable(Followers):
table = "followers"
else:
table = "following"
return table
def follow(conn, Username, Followers, User):
......@@ -168,7 +168,7 @@ def user(conn, Username, Followers, User):
User.media_count,
User.is_private,
User.is_verified,
User.avatar,
User.avatar,
date_time,
Username,)
query = 'INSERT INTO {} VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'.format(uTable(Followers))
......
......@@ -33,7 +33,6 @@ def fTable(Followers):
table = "followers_names"
else:
table = "following_names"
return table
def uTable(Followers):
......@@ -41,7 +40,6 @@ def uTable(Followers):
table = "followers"
else:
table = "following"
return table
def follow(conn, Username, Followers, User):
......@@ -80,10 +78,9 @@ def user(conn, Username, Followers, User):
query = 'INSERT INTO {} VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'.format(uTable(Followers))
cursor.execute(query, entry)
conn.commit()
except MySQLdb.IntegrityError:
pass
def tweets(conn, Tweet, config):
try:
......
......@@ -31,7 +31,16 @@ def hour(datetime):
return strftime("%H", localtime(datetime))
def Tweet(Tweet, config):
day = weekday(strftime("%A", localtime(Tweet.datetime)))
weekdays = {
"Monday": 1,
"Tuesday": 2,
"Wednesday": 3,
"Thursday": 4,
"Friday": 5,
"Saturday": 6,
"Sunday": 7,
}
day = weekdays[strftime("%A", localtime(Tweet.datetime))]
actions = []
nLikes = 0
......@@ -43,7 +52,7 @@ def Tweet(Tweet, config):
j_data = {
"_index": config.Index_tweets,
"_type": "items",
"_id": Tweet.id + "_raw_" + str(config.Essid),
"_id": Tweet.id + "_raw_" + config.Essid,
"_source": {
"id": Tweet.id,
"date": dt,
......@@ -58,7 +67,7 @@ def Tweet(Tweet, config):
"link": Tweet.link,
"retweet": Tweet.retweet,
"user_rt": Tweet.user_rt,
"essid": str(config.Essid)
"essid": config.Essid
}
}
actions.append(j_data)
......@@ -67,7 +76,7 @@ def Tweet(Tweet, config):
j_data = {
"_index": config.Index_tweets,
"_type": "items",
"_id": Tweet.id + "_likes_" + str(nLikes) + "_" + str(config.Essid),
"_id": Tweet.id + "_likes_" + str(nLikes) + "_" + config.Essid,
"_source": {
"id": Tweet.id,
"date": dt,
......@@ -83,7 +92,7 @@ def Tweet(Tweet, config):
"link": Tweet.link,
"retweet": Tweet.retweet,
"user_rt": Tweet.user_rt,
"essid": str(config.Essid)
"essid": config.Essid
}
}
actions.append(j_data)
......@@ -93,7 +102,7 @@ def Tweet(Tweet, config):
j_data = {
"_index": config.Index_tweets,
"_type": "items",
"_id": Tweet.id + "_replies_" + str(nReplies) + "_" + str(config.Essid),
"_id": Tweet.id + "_replies_" + str(nReplies) + "_" + config.Essid,
"_source": {
"id": Tweet.id,
"date": dt,
......@@ -109,7 +118,7 @@ def Tweet(Tweet, config):
"link": Tweet.link,
"retweet": Tweet.retweet,
"user_rt": Tweet.user_rt,
"essid": str(config.Essid)
"essid": config.Essid
}
}
actions.append(j_data)
......@@ -119,7 +128,7 @@ def Tweet(Tweet, config):
j_data = {
"_index": config.Index_tweets,
"_type": "items",
"_id": Tweet.id + "_retweets_" + str(nRetweets) + "_" + str(config.Essid),
"_id": Tweet.id + "_retweets_" + str(nRetweets) + "_" + config.Essid,
"_source": {
"id": Tweet.id,
"date": dt,
......@@ -135,7 +144,7 @@ def Tweet(Tweet, config):
"link": Tweet.link,
"retweet": Tweet.retweet,
"user_rt": Tweet.user_rt,
"essid": str(config.Essid)
"essid": config.Essid
}
}
actions.append(j_data)
......@@ -152,11 +161,11 @@ def Follow(user, config):
j_data = {
"_index": config.Index_follow,
"_type": "items",
"_id": user + "_" + config.Username + "_" + str(config.Essid),
"_id": user + "_" + config.Username + "_" + config.Essid,
"_source": {
"user": user,
"follow": config.Username,
"essid": str(config.Essid)
"essid": config.Essid
}
}
actions.append(j_data)
......@@ -172,7 +181,7 @@ def UserProfile(user, config):
j_data = {
"_index": config.Index_users,
"_type": "items",
"_id": user.id + "_" + user.join_date + "_" + user.join_time + "_" + str(config.Essid),
"_id": user.id + "_" + user.join_date + "_" + user.join_time + "_" + config.Essid,
"_source": {
"id": user.id,
"name": user.name,
......@@ -191,7 +200,7 @@ def UserProfile(user, config):
"private": user.is_private,
"verified": user.is_verified,
"avatar": user.avatar,
"session": str(config.Essid)
"session": config.Essid
}
}
actions.append(j_data)
......
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