fix __twarc metadata writing for flattened tweets
@@ -199,8 +199,8 @@ def flatten(response):
if "data" in response:
response["data"] = expand_payload(response["data"])
- # Add the __twarc metadata from the response to each tweet
- if "__twarc" in response:
+ # Add the __twarc metadata from the response to each tweet if it's a result set
+ if "__twarc" in response and isinstance(response["data"], list):
for tweet in response["data"]:
tweet["__twarc"] = response["__twarc"]
