Commit 5f4afa27 authored by Francesco Poldi's avatar Francesco Poldi

Adding Store_object to store tweets (in ram)

parent 846babf6
...@@ -34,3 +34,4 @@ class Config: ...@@ -34,3 +34,4 @@ class Config:
TwitterSearch = False TwitterSearch = False
User_full = False User_full = False
Profile_full = False Profile_full = False
Store_object = False
...@@ -4,6 +4,8 @@ from . import db, elasticsearch, format, write ...@@ -4,6 +4,8 @@ from . import db, elasticsearch, format, write
from .tweet import Tweet from .tweet import Tweet
from .user import User from .user import User
tweets_object = []
def datecheck(datestamp, config): def datecheck(datestamp, config):
if config.Since and config.Until: if config.Since and config.Until:
d = int(datestamp.replace("-", "")) d = int(datestamp.replace("-", ""))
...@@ -29,9 +31,15 @@ def _output(obj, output, config): ...@@ -29,9 +31,15 @@ def _output(obj, output, config):
write.Text(output, config.Output) write.Text(output, config.Output)
if config.Elasticsearch: if config.Elasticsearch:
print(output, end=".", flush=True) if config.Store_object:
tweets_object.append(tweet)
else:
print(output, end=".", flush=True)
else: else:
print(output) if config.Store_object:
tweets_object.append(tweet)
else:
print(output)
async def Tweets(tw, location, config, conn): async def Tweets(tw, location, config, conn):
copyright = tw.find("div", "StreamItemContent--withheld") copyright = tw.find("div", "StreamItemContent--withheld")
...@@ -39,12 +47,12 @@ async def Tweets(tw, location, config, conn): ...@@ -39,12 +47,12 @@ async def Tweets(tw, location, config, conn):
tweet = Tweet(tw, location, config) tweet = Tweet(tw, location, config)
if datecheck(tweet.datestamp, config): if datecheck(tweet.datestamp, config):
output = format.Tweet(config, tweet) output = format.Tweet(config, tweet)
if config.Database: if config.Database:
db.tweets(conn, tweet) db.tweets(conn, tweet)
if config.Elasticsearch: if config.Elasticsearch:
elasticsearch.Tweet(tweet, config.Elasticsearch, config.Essid) elasticsearch.Tweet(tweet, config.Elasticsearch, config.Essid)
_output(tweet, output, config) _output(tweet, output, config)
async def Users(u, config, conn): async def Users(u, config, conn):
......
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