♻️ Add custom http functions so that User-Agent is always sent
This commit is contained in:
parent
cfef5a6c7a
commit
2208b1de55
3 changed files with 62 additions and 15 deletions
|
|
@ -4,9 +4,9 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
u "net/url"
|
||||
|
||||
"codeberg.org/danjones000/strip-beats/config"
|
||||
h "codeberg.org/danjones000/strip-beats/utils/http"
|
||||
)
|
||||
|
||||
type MbRecording struct {
|
||||
|
|
@ -77,17 +77,9 @@ func GetMbRecording(id string) (MbRecording, error) {
|
|||
|
||||
func FillMbRecording(rec *MbRecording) error {
|
||||
url := fmt.Sprintf("https://musicbrainz.org/ws/2/recording/%s", rec.Id)
|
||||
req, err := http.NewRequest(http.MethodGet, url, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
q := req.URL.Query()
|
||||
q.Add("fmt", "json")
|
||||
q.Add("inc", "releases+media+artist-credits+isrcs+genres")
|
||||
req.URL.RawQuery = q.Encode()
|
||||
req.Header.Set("User-Agent", config.UserAgent)
|
||||
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
resp, err := h.GetWithQuery(url, u.Values{
|
||||
"fmt": []string{"json"},
|
||||
"inc": []string{"releases+media+artist-credits+isrcs+genres"}})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue