diff --git a/cmd/twitter/main.go b/cmd/twitter/main.go index fc8094a..9ae38c7 100644 --- a/cmd/twitter/main.go +++ b/cmd/twitter/main.go @@ -174,7 +174,7 @@ func fetch_tweet_conversation(tweet_identifier string) { if err != nil { die(fmt.Sprintf("Error saving tweet (id %d): %s", t.ID, err.Error()), false, 4) } - err = profile.DownloadTweetContentFor(&t) + _, err = profile.DownloadTweetContentIfNeeded(&t) if err != nil { die("Error getting tweet content: " + err.Error(), false, 11) } @@ -217,7 +217,7 @@ func fetch_user_feed(handle string, how_many int) { if err != nil { die("Error saving tweet: " + err.Error(), false, 4) } - err = profile.DownloadTweetContentFor(&t) + _, err = profile.DownloadTweetContentIfNeeded(&t) if err != nil { die("Error getting tweet content: " + err.Error(), false, 11) } @@ -286,7 +286,7 @@ func search(query string) { if err != nil { die("Error saving tweet: " + err.Error(), false, 4) } - err = profile.DownloadTweetContentFor(&t) + _, err = profile.DownloadTweetContentIfNeeded(&t) if err != nil { die("Error getting tweet content: " + err.Error(), false, 11) } diff --git a/persistence/media_download.go b/persistence/media_download.go index e31f8d2..88284a8 100644 --- a/persistence/media_download.go +++ b/persistence/media_download.go @@ -174,5 +174,17 @@ func (p Profile) DownloadUserContentIfNeeded(u *scraper.User) (bool, error) { return false, nil } return true, p.DownloadUserContentFor(u) - +} + + +/** + * Download a Tweet's content, if needed. + * + * Returns whether anything was downloaded or not. + */ +func (p Profile) DownloadTweetContentIfNeeded(t *scraper.Tweet) (bool, error) { + if !p.CheckTweetContentDownloadNeeded(*t) { + return false, nil + } + return true, p.DownloadTweetContentFor(t) }