partial fetching of artist

This commit is contained in:
Hazel Noack
2025-10-09 14:37:13 +02:00
parent 1ae859b9b9
commit 3565f14181
3 changed files with 281 additions and 3 deletions

View File

@@ -8,6 +8,7 @@ import (
"net/http"
"net/http/cookiejar"
"net/url"
"strings"
"time"
"golang.org/x/net/publicsuffix"
@@ -118,6 +119,33 @@ func (s *Session) PostMultipartForm(url string, data map[string]string, headers
return s.client.Do(req)
}
func (s *Session) PostForm(rawUrl string, data map[string]string, headers ...map[string]string) (*http.Response, error) {
fullURL := s.buildURL(rawUrl)
// Prepare form data
formData := url.Values{}
for k, v := range data {
formData.Add(k, v)
}
body := strings.NewReader(formData.Encode())
req, err := http.NewRequest("POST", fullURL, body)
if err != nil {
return nil, err
}
s.setDefaultHeaders(req)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
// Add any additional headers provided
if len(headers) > 0 {
for key, value := range headers[0] {
req.Header.Set(key, value)
}
}
return s.client.Do(req)
}
// PostJSON performs a POST request with JSON data
func (s *Session) PostJSON(url string, data interface{}, headers ...map[string]string) (*http.Response, error) {
fullURL := s.buildURL(url)