diff options
-rwxr-xr-x | twitter.py | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -103,22 +103,25 @@ def twitter(user): logging.error('Request to twitter failed.', exc_info=exc) return None + feed = { + 'title': 'Twitter: ' + user, + 'url': 'https://twitter.com/' + user, + 'description': 'The latest entries of the twitter account of ' + user, + 'content': [] + } + if not response["meta"]["result_count"]: - return [] + return feed - tweets = [parse_tweet( + feed['content'] = [parse_tweet( user, tweet, response.get("includes", {}).get("tweets", []), response.get("includes", {}).get("media", []), ) for tweet in response["data"]] - return { - 'title': 'Twitter: ' + user, - 'url': 'https://twitter.com/' + user, - 'description': 'The latest entries of the twitter account of ' + user, - 'content': tweets - } + return feed + def parse_tweet(user, tweet, included_tweets, included_media): title = description = tweet["text"] |