Commit 93a13cbf authored by Francesco Poldi's avatar Francesco Poldi

Fix #283

parent 3879726a
......@@ -60,7 +60,7 @@ def _output(obj, output, config, **extra):
else:
write.Text(output, config.Output)
if config.Pandas and config.User_full:
if config.Pandas and obj.type == "user":
panda.update(obj, config)
if extra.get("follow_list"):
follow_object.username = config.Username
......
from time import strftime, localtime
import pandas as pd
import warnings
from .elasticsearch import *
from .elasticsearch import hour
Tweets_df = None
Follow_df = None
......@@ -13,6 +13,17 @@ _object_blocks = {
"following": [],
"followers": []
}
weekdays = {
"Monday": 1,
"Tuesday": 2,
"Wednesday": 3,
"Thursday": 4,
"Friday": 5,
"Saturday": 6,
"Sunday": 7,
}
_type = ""
def _concat(df, type):
......@@ -46,43 +57,66 @@ def update(object, config):
_type = config.Following*"following" + config.Followers*"followers"
if _type == "tweet":
Tweet = object
day = weekdays[strftime("%A", localtime(Tweet.datetime))]
dt = f"{object.datestamp} {object.timestamp}"
_data = {
"id": object.id,
"id": str(Tweet.id),
"conversation_id": Tweet.conversation_id,
"created_at": Tweet.datetime,
"date": dt,
"timezone": object.timezone,
"location": object.location,
"tweet": object.tweet,
"hashtags": object.hashtags,
"user_id": object.user_id,
"username": object.username,
"link": object.link,
"retweet": object.retweet,
"user_rt": object.user_rt,
"essid": config.Essid,
'mentions': object.mentions
"timezone": Tweet.timezone,
"place": Tweet.place,
"location": Tweet.location,
"tweet": Tweet.tweet,
"hashtags": Tweet.hashtags,
"user_id": Tweet.user_id,
"user_id_str": Tweet.user_id_str,
"username": Tweet.username,
"name": Tweet.name,
"profile_image_url": Tweet.profile_image_url,
"day": day,
"hour": hour(Tweet.datetime),
"link": Tweet.link,
"gif_url": Tweet.gif_url,
"gif_thumb": Tweet.gif_thumb,
"video_url": Tweet.video_url,
"video_thumb": Tweet.video_thumb,
"is_reply_to": Tweet.is_reply_to,
"has_parent_tweet": Tweet.has_parent_tweet,
"retweet": Tweet.retweet,
"nlikes": int(Tweet.likes_count),
"nreplies": int(Tweet.replies_count),
"nretweets": int(Tweet.retweets_count),
"is_quote_status": Tweet.is_quote_status,
"quote_id": Tweet.quote_id,
"quote_id_str": Tweet.quote_id_str,
"quote_url": Tweet.quote_url,
"search": str(config.Search),
"near": config.Near
}
_object_blocks[_type].append(_data)
elif _type == "user":
user = object
_data = {
"id": object.id,
"name": object.name,
"username": object.username,
"bio": object.bio,
"location": object.location,
"url": object.url,
"join_datetime": object.join_date + " " + object.join_time,
"join_date": object.join_date,
"join_time": object.join_time,
"tweets": object.tweets,
"following": object.following,
"followers": object.followers,
"likes": object.likes,
"media": object.media_count,
"private": object.is_private,
"verified": object.is_verified,
"avatar": object.avatar,
"session": str(config.Essid)
"id": user.id,
"name": user.name,
"username": user.username,
"bio": user.bio,
"location": user.location,
"url": user.url,
"join_datetime": user.join_date + " " + user.join_time,
"join_date": user.join_date,
"join_time": user.join_time,
"tweets": user.tweets,
"following": user.following,
"followers": user.followers,
"likes": user.likes,
"media": user.media_count,
"private": user.is_private,
"verified": user.is_verified,
"avatar": user.avatar,
"background_image": user.background_image,
}
_object_blocks[_type].append(_data)
elif _type == "followers" or _type == "following":
......
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