Commit 52fcf7c2 authored by Filipp Fediakov's avatar Filipp Fediakov Committed by andytnt

Parse information of existence of video in tweet

parent 12448cd1
...@@ -26,6 +26,7 @@ PUT twinttweets ...@@ -26,6 +26,7 @@ PUT twinttweets
"nreplies": {"type": "integer"}, "nreplies": {"type": "integer"},
"nretweets": {"type": "integer"}, "nretweets": {"type": "integer"},
"quote_url": {"type": "text"}, "quote_url": {"type": "text"},
"video": {"type": "integer"},
"search": {"type": "text"}, "search": {"type": "text"},
"near": {"type": "text"}, "near": {"type": "text"},
"geo_near": {"type": "geo_point"}, "geo_near": {"type": "geo_point"},
......
...@@ -75,6 +75,7 @@ def init(db): ...@@ -75,6 +75,7 @@ def init(db):
urls text, urls text,
photos text, photos text,
quote_url text, quote_url text,
video integer,
time_update integer not null, time_update integer not null,
PRIMARY KEY (id) PRIMARY KEY (id)
); );
...@@ -242,8 +243,9 @@ def tweets(conn, Tweet, config): ...@@ -242,8 +243,9 @@ def tweets(conn, Tweet, config):
",".join(Tweet.urls), ",".join(Tweet.urls),
",".join(Tweet.photos), ",".join(Tweet.photos),
Tweet.quote_url, Tweet.quote_url,
Tweet.video,
time_ms) time_ms)
cursor.execute('INSERT INTO tweets VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', entry) cursor.execute('INSERT INTO tweets VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', entry)
if config.Favorites: if config.Favorites:
query = 'INSERT INTO favorites VALUES(?,?)' query = 'INSERT INTO favorites VALUES(?,?)'
......
...@@ -80,6 +80,7 @@ def createIndex(config, instance, **scope): ...@@ -80,6 +80,7 @@ def createIndex(config, instance, **scope):
"nreplies": {"type": "integer"}, "nreplies": {"type": "integer"},
"nretweets": {"type": "integer"}, "nretweets": {"type": "integer"},
"quote_url": {"type": "text"}, "quote_url": {"type": "text"},
"video": {"type":"integer"},
"search": {"type": "text"}, "search": {"type": "text"},
"near": {"type": "text"}, "near": {"type": "text"},
"geo_near": {"type": "geo_point"}, "geo_near": {"type": "geo_point"},
...@@ -220,6 +221,7 @@ def Tweet(Tweet, config): ...@@ -220,6 +221,7 @@ def Tweet(Tweet, config):
"nreplies": int(Tweet.replies_count), "nreplies": int(Tweet.replies_count),
"nretweets": int(Tweet.retweets_count), "nretweets": int(Tweet.retweets_count),
"quote_url": Tweet.quote_url, "quote_url": Tweet.quote_url,
"video": Tweet.video,
"search": str(config.Search), "search": str(config.Search),
"near": config.Near "near": config.Near
} }
......
...@@ -21,7 +21,8 @@ def tweetData(t): ...@@ -21,7 +21,8 @@ def tweetData(t):
"hashtags": t.hashtags, "hashtags": t.hashtags,
"link": t.link, "link": t.link,
"retweet": t.retweet, "retweet": t.retweet,
"quote_url": t.quote_url "quote_url": t.quote_url,
"video": t.video
} }
return data return data
...@@ -48,7 +49,8 @@ def tweetFieldnames(): ...@@ -48,7 +49,8 @@ def tweetFieldnames():
"hashtags", "hashtags",
"link", "link",
"retweet", "retweet",
"quote_url" "quote_url",
"video"
] ]
return fieldnames return fieldnames
......
...@@ -82,6 +82,7 @@ def Tweet(tw, location, config): ...@@ -82,6 +82,7 @@ def Tweet(tw, location, config):
t.mentions = getMentions(tw) t.mentions = getMentions(tw)
t.urls = [link.attrs["data-expanded-url"] for link in tw.find_all('a',{'class':'twitter-timeline-link'}) if link.has_attr("data-expanded-url")] t.urls = [link.attrs["data-expanded-url"] for link in tw.find_all('a',{'class':'twitter-timeline-link'}) if link.has_attr("data-expanded-url")]
t.photos = [photo_node.attrs['data-image-url'] for photo_node in tw.find_all("div", "AdaptiveMedia-photoContainer")] t.photos = [photo_node.attrs['data-image-url'] for photo_node in tw.find_all("div", "AdaptiveMedia-photoContainer")]
t.video = 1 if tw.find_all("div", "AdaptiveMedia-video") != [] else 0
t.tweet = getText(tw) t.tweet = getText(tw)
t.location = location t.location = location
t.hashtags = [hashtag.text for hashtag in tw.find_all("a","twitter-hashtag")] t.hashtags = [hashtag.text for hashtag in tw.find_all("a","twitter-hashtag")]
......
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