Skip to content

Commit

Permalink
[twitter] strip useless t.co links (#1532)
Browse files Browse the repository at this point in the history
The 'full_text' of Tweets with media content usually ends with a t.co
link to itself. This commit removes those.
  • Loading branch information
mikf committed May 16, 2021
1 parent 3a7c3ff commit 394fbb5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gallery_dl/extractor/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ def _transform_tweet(self, tweet):
if urls:
for url in urls:
content = content.replace(url["url"], url["expanded_url"])
tdata["content"] = content
txt, _, tco = content.rpartition(" ")
tdata["content"] = txt if tco.startswith("https://t.co/") else content

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

0 comments on commit 394fbb5

Please sign in to comment.