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

Fix #283

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