Fix bug with users with 600x200 banner images

When downloading these users' content, they weren't getting saved afterward (to update 'is_content_downloaded').
This commit is contained in:
Alessio 2022-01-18 17:48:08 -08:00
parent dc24ce5ad4
commit 56870173e9
3 changed files with 14 additions and 9 deletions

View File

@ -194,10 +194,10 @@ test $(find link_preview_images | wc -l) = $initial_link_preview_images_count #
# Test a tweet thread with tombstones
# tw fetch_tweet https://twitter.com/CovfefeAnon/status/1454526270809726977 # TODO: This guy un-privated for some reason
# test $(sqlite3 twitter.db "select is_stub from tweets where id = 1454515503242829830") = 1
# test $(sqlite3 twitter.db "select is_stub from tweets where id = 1454521424144654344") = 0
# test $(sqlite3 twitter.db "select is_stub from tweets where id = 1454522147750260742") = 1
tw fetch_tweet https://twitter.com/CovfefeAnon/status/1454526270809726977
test $(sqlite3 twitter.db "select is_stub from tweets where id = 1454515503242829830") = 1
test $(sqlite3 twitter.db "select is_stub from tweets where id = 1454521424144654344") = 0
test $(sqlite3 twitter.db "select is_stub from tweets where id = 1454522147750260742") = 1
# Test search
tw search "from:michaelmalice constitution"
@ -215,6 +215,11 @@ tw fetch_user nancytracker
test "$(sqlite3 twitter.db "select is_content_downloaded, is_banned from users where handle='nancytracker'")" = "1|1"
test -e profile_images/default_profile.png
# Fetch a user with "600x200" banner image
tw fetch_user AlexKoppelman # This is probably kind of a flimsy test
test $(sqlite3 twitter.db "select is_content_downloaded from users where handle='AlexKoppelman'") = "1"
# TODO: Maybe this file should be broken up into multiple test scripts
echo -e "\033[32mAll tests passed. Finished successfully.\033[0m"

View File

@ -167,11 +167,11 @@ func (p Profile) DownloadUserContentWithInjector(u *scraper.User, downloader Med
if u.BannerImageLocalPath != "" {
outfile = path.Join(p.ProfileDir, "profile_images", u.BannerImageLocalPath)
err = downloader.Curl(u.BannerImageUrl, outfile)
if err != nil && strings.Contains(err.Error(), "404 Not Found") {
// Try adding "600x200". Not sure why this does this but sometimes it does.
err = downloader.Curl(u.BannerImageUrl + "/600x200", outfile)
}
if err != nil {
if strings.Contains(err.Error(), "404 Not Found") {
// Try adding "600x200". Not sure why this does this but sometimes it does.
err = downloader.Curl(u.BannerImageUrl + "/600x200", outfile)
}
return err
}
}

View File

@ -161,7 +161,7 @@ func TestModifyTweet(t *testing.T) {
t.Errorf("Expected %d retweets, got %d", 2500, new_tweet.NumRetweets)
}
if new_tweet.NumReplies != 3500 {
t.Errorf("Expected %d replies, got %d", 1500, new_tweet.NumReplies)
t.Errorf("Expected %d replies, got %d", 3500, new_tweet.NumReplies)
}
if new_tweet.NumQuoteTweets != 4500 {
t.Errorf("Expected %d quote tweets, got %d", 4500, new_tweet.NumQuoteTweets)