Should be using the full-sized profile images, not the 'normal' ones
This commit is contained in:
parent
294917124a
commit
932b42eafc
@ -97,6 +97,11 @@ func ParseSingleUser(apiUser APIUser) (ret User, err error) {
|
|||||||
ret.IsPrivate = apiUser.Protected
|
ret.IsPrivate = apiUser.Protected
|
||||||
ret.IsVerified = apiUser.Verified
|
ret.IsVerified = apiUser.Verified
|
||||||
ret.ProfileImageUrl = apiUser.ProfileImageURLHTTPS
|
ret.ProfileImageUrl = apiUser.ProfileImageURLHTTPS
|
||||||
|
|
||||||
|
|
||||||
|
if regexp.MustCompile("_normal\\.\\w{2,4}").MatchString(ret.ProfileImageUrl) {
|
||||||
|
ret.ProfileImageUrl = strings.ReplaceAll(ret.ProfileImageUrl, "_normal.", ".")
|
||||||
|
}
|
||||||
ret.BannerImageUrl = apiUser.ProfileBannerURL
|
ret.BannerImageUrl = apiUser.ProfileBannerURL
|
||||||
|
|
||||||
ret.ProfileImageLocalPath = ret.compute_profile_image_local_path()
|
ret.ProfileImageLocalPath = ret.compute_profile_image_local_path()
|
||||||
@ -137,12 +142,8 @@ func (u User) compute_banner_image_local_path() string {
|
|||||||
base_name := path.Base(u.BannerImageUrl)
|
base_name := path.Base(u.BannerImageUrl)
|
||||||
|
|
||||||
// Check if it has an extension (e.g., ".png" or ".jpeg")
|
// Check if it has an extension (e.g., ".png" or ".jpeg")
|
||||||
match, err := regexp.MatchString("\\.\\w{2,4}$", base_name)
|
if !regexp.MustCompile("\\.\\w{2,4}$").MatchString(base_name) {
|
||||||
if err != nil {
|
// If it doesn't have an extension, add one
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
// If it doesn't have an extension, add one
|
|
||||||
if !match {
|
|
||||||
base_name += ".jpg"
|
base_name += ".jpg"
|
||||||
}
|
}
|
||||||
return string(u.Handle) + "_banner_" + base_name
|
return string(u.Handle) + "_banner_" + base_name
|
||||||
|
@ -60,7 +60,7 @@ func TestParseSingleUser(t *testing.T) {
|
|||||||
if user.IsVerified != true {
|
if user.IsVerified != true {
|
||||||
t.Errorf("Expected %v, got %v", true, user.IsPrivate)
|
t.Errorf("Expected %v, got %v", true, user.IsPrivate)
|
||||||
}
|
}
|
||||||
expectedProfileImage := "https://pbs.twimg.com/profile_images/1064051934812913664/Lbwdb_C9_normal.jpg"
|
expectedProfileImage := "https://pbs.twimg.com/profile_images/1064051934812913664/Lbwdb_C9.jpg"
|
||||||
if user.ProfileImageUrl != expectedProfileImage {
|
if user.ProfileImageUrl != expectedProfileImage {
|
||||||
t.Errorf("Expected %q, got %q", expectedProfileImage, user.ProfileImageUrl)
|
t.Errorf("Expected %q, got %q", expectedProfileImage, user.ProfileImageUrl)
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ func TestParseSingleUser(t *testing.T) {
|
|||||||
if user.BannerImageUrl != expectedBannerImage {
|
if user.BannerImageUrl != expectedBannerImage {
|
||||||
t.Errorf("Expected %q, got %q", expectedBannerImage, user.BannerImageUrl)
|
t.Errorf("Expected %q, got %q", expectedBannerImage, user.BannerImageUrl)
|
||||||
}
|
}
|
||||||
expected_profile_image_local := "michaelmalice_profile_Lbwdb_C9_normal.jpg"
|
expected_profile_image_local := "michaelmalice_profile_Lbwdb_C9.jpg"
|
||||||
if user.ProfileImageLocalPath != expected_profile_image_local {
|
if user.ProfileImageLocalPath != expected_profile_image_local {
|
||||||
t.Errorf("Expected %q, got %q", expected_profile_image_local, user.ProfileImageLocalPath)
|
t.Errorf("Expected %q, got %q", expected_profile_image_local, user.ProfileImageLocalPath)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user