diff options
| author | André Glüpker <git@wgmd.de> | 2021-05-16 23:20:13 +0200 | 
|---|---|---|
| committer | André Glüpker <git@wgmd.de> | 2021-05-16 23:20:13 +0200 | 
| commit | 1d8f04124d1eab31b104731a6e672a014b818859 (patch) | |
| tree | 3da1f5ec21989be7832a7dc2b7a442b0843c4a87 /twitter.py | |
| parent | 9fff75d7016b29715c2413febf6f86d7f444f52c (diff) | |
| download | rss-feeds-1d8f04124d1eab31b104731a6e672a014b818859.tar.gz rss-feeds-1d8f04124d1eab31b104731a6e672a014b818859.tar.bz2 rss-feeds-1d8f04124d1eab31b104731a6e672a014b818859.zip | |
Fix twitter references
Diffstat (limited to 'twitter.py')
| -rwxr-xr-x | twitter.py | 9 | 
1 files changed, 5 insertions, 4 deletions
| @@ -109,7 +109,8 @@ def twitter(user):      tweets = [parse_tweet(              user,              tweet, -            response["includes"]["media"], +            response.get("includes", {}).get("tweets", []), +            response.get("includes", {}).get("media", []),          ) for tweet in response["data"]]      return { @@ -119,7 +120,7 @@ def twitter(user):          'content': tweets      } -def parse_tweet(user, tweet, media): +def parse_tweet(user, tweet, included_tweets, included_media):      title = description = tweet["text"]      link = "https://twitter.com/" + user + "/status/" + str(tweet["id"]) @@ -129,7 +130,7 @@ def parse_tweet(user, tweet, media):          if rt["type"] == "retweeted":              rt_info = title[: title.index(":") + 2]              ref_tweet = next( -                t for t in response["includes"]["tweets"] if t["id"] == rt["id"] +                t for t in included_tweets if t["id"] == rt["id"]              )              title = rt_info + ref_tweet["text"]              description = rt_info + ref_tweet["text"] @@ -150,7 +151,7 @@ def parse_tweet(user, tweet, media):      included_media_keys = tweet.get('attachments', {}).get('media_keys', [])      for included_media_key in included_media_keys:          ref_media = next( -            t for t in media if t["media_key"] == included_media_key +            t for t in included_media if t["media_key"] == included_media_key          )          if 'url' not in ref_media: continue          if ref_media.get('type', '') == 'photo': | 
