log listenbrainz scrobble response
This commit is contained in:
@@ -5,7 +5,9 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/httputil"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.senan.xyz/gonic/server/db"
|
"go.senan.xyz/gonic/server/db"
|
||||||
@@ -86,11 +88,14 @@ func (s *Scrobbler) Scrobble(user *db.User, track *db.Track, stamp time.Time, su
|
|||||||
return fmt.Errorf("http post: %w", err)
|
return fmt.Errorf("http post: %w", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
respBytes, _ := httputil.DumpResponse(resp, true)
|
||||||
switch {
|
switch {
|
||||||
case resp.StatusCode == http.StatusUnauthorized:
|
case resp.StatusCode == http.StatusUnauthorized:
|
||||||
return fmt.Errorf("unathorized: %w", ErrListenBrainz)
|
return fmt.Errorf("unathorized: %w", ErrListenBrainz)
|
||||||
case resp.StatusCode >= 200:
|
case resp.StatusCode >= 400:
|
||||||
return fmt.Errorf("non >= 400: %d: %w", resp.StatusCode, ErrListenBrainz)
|
log.Println("received listenbrainz response")
|
||||||
|
log.Println(string(respBytes))
|
||||||
|
return fmt.Errorf(">= 400: %d: %w", resp.StatusCode, ErrListenBrainz)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user