diff --git a/scrobble/lastfm/lastfm.go b/scrobble/lastfm/lastfm.go index 61adbf66..905e8d11 100644 --- a/scrobble/lastfm/lastfm.go +++ b/scrobble/lastfm/lastfm.go @@ -6,7 +6,9 @@ import ( "encoding/xml" "errors" "fmt" + "log" "net/http" + "net/http/httputil" "net/url" "sort" "strconv" @@ -153,9 +155,13 @@ func makeRequest(method string, params url.Values) (LastFM, error) { decoder := xml.NewDecoder(resp.Body) lastfm := LastFM{} if err = decoder.Decode(&lastfm); err != nil { + respBytes, _ := httputil.DumpResponse(resp, true) + log.Printf("received bad lastfm response:\n%s", string(respBytes)) return LastFM{}, fmt.Errorf("decoding: %w", err) } if lastfm.Error.Code != 0 { + respBytes, _ := httputil.DumpResponse(resp, true) + log.Printf("received bad lastfm response:\n%s", string(respBytes)) return LastFM{}, fmt.Errorf("%v: %w", lastfm.Error.Value, ErrLastFM) } return lastfm, nil diff --git a/scrobble/listenbrainz/listenbrainz.go b/scrobble/listenbrainz/listenbrainz.go index dd1b0cdf..6f171674 100644 --- a/scrobble/listenbrainz/listenbrainz.go +++ b/scrobble/listenbrainz/listenbrainz.go @@ -92,13 +92,12 @@ func (s *Scrobbler) Scrobble(user *db.User, track *db.Track, stamp time.Time, su } defer resp.Body.Close() - respBytes, _ := httputil.DumpResponse(resp, true) switch { case resp.StatusCode == http.StatusUnauthorized: return fmt.Errorf("unathorized: %w", ErrListenBrainz) case resp.StatusCode >= 400: - log.Println("received listenbrainz response") - log.Println(string(respBytes)) + respBytes, _ := httputil.DumpResponse(resp, true) + log.Printf("received bad listenbrainz response:\n%s", string(respBytes)) return fmt.Errorf(">= 400: %d: %w", resp.StatusCode, ErrListenBrainz) } return nil