Skip to content

Commit

Permalink
[twitter] expand t.co links in user descriptions (#1532, #1787)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Aug 23, 2021
1 parent 7c0ae88 commit 0817f46
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion gallery_dl/extractor/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ def _transform_user(self, user):
"id" : text.parse_int(uid),
"name" : user["screen_name"],
"nick" : user["name"],
"description" : user["description"],
"location" : user["location"],
"date" : text.parse_datetime(
user["created_at"], "%a %b %d %H:%M:%S %z %Y"),
Expand All @@ -236,6 +235,13 @@ def _transform_user(self, user):
"statuses_count" : user["statuses_count"],
}

descr = user["description"]
urls = entities["description"].get("urls")
if urls:
for url in urls:
descr = descr.replace(url["url"], url["expanded_url"])
udata["description"] = descr

if "url" in entities:
udata["url"] = entities["url"]["urls"][0]["expanded_url"]

Expand Down Expand Up @@ -469,6 +475,11 @@ class TwitterTweetExtractor(TwitterExtractor):
("https://twitter.com/i/web/status/1424882930803908612", {
"options": (("replies", "self"),),
"count": 4,
"keyword": {"user": {
"description": "re:business email-- [email protected] "
"patreon- http://patreon.com/Princecanary",
"url": "http://princecanary.tumblr.com",
}},
}),
("https://twitter.com/i/web/status/1424898916156284928", {
"options": (("replies", "self"),),
Expand Down

0 comments on commit 0817f46

Please sign in to comment.