Skip to content

Commit

Permalink
[twitter] resolve t.co URLs in 'content' (#1532)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed May 15, 2021
1 parent 2b5d808 commit 41457db
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion gallery_dl/extractor/twitter.py
Expand Up @@ -168,7 +168,6 @@ def _transform_tweet(self, tweet):
tweet["created_at"], "%a %b %d %H:%M:%S %z %Y"),
"user" : self._transform_user(tweet["user"]),
"lang" : tweet["lang"],
"content" : tweet["full_text"],
"favorite_count": tweet["favorite_count"],
"quote_count" : tweet["quote_count"],
"reply_count" : tweet["reply_count"],
Expand All @@ -187,6 +186,13 @@ def _transform_tweet(self, tweet):
"nick": u["name"],
} for u in mentions]

content = tweet["full_text"]
urls = entities.get("urls")
if urls:
for url in urls:
content = content.replace(url["url"], url["expanded_url"])
tdata["content"] = content

if "in_reply_to_screen_name" in tweet:
tdata["reply_to"] = tweet["in_reply_to_screen_name"]

Expand Down

0 comments on commit 41457db

Please sign in to comment.