Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Twitter] [#1532] Add account URL to --write-metadata and expand t.co links in user descriptions #1787

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions gallery_dl/extractor/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def _transform_user(self, user):
"name" : user["screen_name"],
"nick" : user["name"],
"description" : user["description"],
"url" : "",
"location" : user["location"],
"date" : text.parse_datetime(
user["created_at"], "%a %b %d %H:%M:%S %z %Y"),
Expand All @@ -231,6 +232,13 @@ def _transform_user(self, user):
"media_count" : user["media_count"],
"statuses_count" : user["statuses_count"],
}
if "urls" in user["entities"]["description"]:
for tco in user["entities"]["description"]["urls"]:
cache[uid]["description"] = cache[uid]["description"]\
.replace(tco["url"], tco["expanded_url"])
if "url" in user["entities"]:
cache[uid]["url"] = \
user["entities"]["url"]["urls"][0]["expanded_url"]
return cache[uid]

def _users_result(self, users):
Expand Down