Skip to content

Commit

Permalink
hydrate updates
Browse files Browse the repository at this point in the history
There was a small bug in Twarc.hydrate that was bypassing Twarc.post and using
Twarc.client.post directly before Twarc.client was initialized.

This commit also makes sure that hydrate passes along tweet_mode as appropriate
if the user wants to hdyrate tweets in extended mode (tweets > 140 chars).

Fixes #155
  • Loading branch information
edsu committed Mar 21, 2017
1 parent 0b7e654 commit 6ed8c5c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions twarc.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,12 +737,15 @@ def hydrate(self, iterator):
# hydrate any remaining ones
if len(ids) > 0:
logging.info("hydrating %s", ids)
resp = self.client.post(url, data={"id": ','.join(ids)})
resp = self.post(url, data={"id": ','.join(ids)})
for tweet in resp.json():
yield tweet

def tweet(self, tweet_id):
return next(self.hydrate([tweet_id]))
try:
return next(self.hydrate([tweet_id]))
except StopIteration:
return []

def retweets(self, tweet_id):
"""
Expand Down Expand Up @@ -905,6 +908,9 @@ def post(self, *args, **kwargs):
if not self.client:
self.connect()

if "data" in kwargs:
kwargs["data"]["tweet_mode"] = self.tweet_mode

connection_error_count = kwargs.pop('connection_error_count', 0)
try:
logging.info("posting %s %s", args, kwargs)
Expand Down

0 comments on commit 6ed8c5c

Please sign in to comment.