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

fix: Original quality Twitter profile pictures. #131

Merged
merged 5 commits into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Twitter profile pictures are now returned in their original quality. (#131)
- Youtube thumbnails are now in medium quality instead of standard definition to get a rectangular shaped image. (#127)

## 1.0.1
Expand Down
7 changes: 7 additions & 0 deletions internal/resolvers/twitter/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"net/http"
"net/url"
"strings"
"time"

"github.com/Chatterino/api/pkg/humanize"
Expand Down Expand Up @@ -111,5 +112,11 @@ func getUserByName(userName, bearer string) (*TwitterUserApiResponse, error) {
return nil, errors.New("unable to process response")
}

/* By default, Twitter returns a low resolution image.
* This modification removes "_normal" to get the original sized image, based on Twitter's API documentation:
* https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/user-profile-images-and-banners
*/
user.ProfileImageUrl = strings.Replace(user.ProfileImageUrl, "_normal", "", 1)

return user, nil
}