hydrate updates
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
@@ -737,12 +737,15 @@ class Twarc(object):
# 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):
+ try:
return next(self.hydrate([tweet_id]))
+ except StopIteration:
+ return []
def retweets(self, tweet_id):
"""
@@ -905,6 +908,9 @@ class Twarc(object):
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)
