summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Glüpker <git@wgmd.de>2021-07-29 10:44:00 +0200
committerAndré Glüpker <git@wgmd.de>2021-07-29 10:44:00 +0200
commit4b0a75b85d1892e04230de828fe09b90d4f73f09 (patch)
treefe18bd687c1966d47412269dde06b4efe738d972
parent1d8f04124d1eab31b104731a6e672a014b818859 (diff)
downloadrss-feeds-4b0a75b85d1892e04230de828fe09b90d4f73f09.tar.gz
rss-feeds-4b0a75b85d1892e04230de828fe09b90d4f73f09.tar.bz2
rss-feeds-4b0a75b85d1892e04230de828fe09b90d4f73f09.zip
Handle empty twitter feeds
-rwxr-xr-xtwitter.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/twitter.py b/twitter.py
index 7f2dfae..87dfc68 100755
--- a/twitter.py
+++ b/twitter.py
@@ -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"]