From 41457dbb1b693664d52145e047953a3fa0c9dee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 15 May 2021 02:46:46 +0200 Subject: [PATCH] [twitter] resolve t.co URLs in 'content' (#1532) --- gallery_dl/extractor/twitter.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gallery_dl/extractor/twitter.py b/gallery_dl/extractor/twitter.py index acfbd54dd4..10f3b394b1 100644 --- a/gallery_dl/extractor/twitter.py +++ b/gallery_dl/extractor/twitter.py @@ -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"], @@ -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"]