refactor: unexport internal identifiers and fix naming nits

This commit is contained in:
Mathis Maquenne
2026-08-05 21:55:59 +02:00
parent c1775e5c04
commit eea049aae9
13 changed files with 34 additions and 34 deletions
+1 -1
View File
@@ -51,6 +51,6 @@ func TestDecryptBlowfishRoundTrip(t *testing.T) {
func TestDecryptBlowfishInvalidKey(t *testing.T) {
if _, err := DecryptBlowfish(make([]byte, 8), nil); err == nil {
t.Error("expected error for empty key")
t.Error("expected error for nil key")
}
}
+2 -2
View File
@@ -78,7 +78,7 @@ func (c *Client) FetchResource(ctx context.Context, kind Kind, id string) (Resou
return nil, err
}
url := fmt.Sprintf("https://www.deezer.com/ajax/gw-light.php?method=deezer.page%s&input=3&api_version=1.0&api_token=%s", kind.pageMethod(), c.Session.APIToken)
url := fmt.Sprintf("https://www.deezer.com/ajax/gw-light.php?method=deezer.page%s&input=3&api_version=1.0&api_token=%s", kind.pageMethod(), c.Session.apiToken)
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewBuffer(jsonData))
if err != nil {
return nil, err
@@ -132,7 +132,7 @@ func (c *Client) FetchMedia(ctx context.Context, track *Track, quality string) (
"flac": `[{"cipher":"BF_CBC_STRIPE","format":"FLAC"},{"cipher":"BF_CBC_STRIPE","format":"MP3_320"},{"cipher":"BF_CBC_STRIPE","format":"MP3_128"}]`,
}
reqBody := fmt.Sprintf(`{"license_token":"%s","media":[{"type":"FULL","formats":%s}],"track_tokens":["%s"]}`, c.Session.LicenseToken, qualityFormats[quality], track.TrackToken)
reqBody := fmt.Sprintf(`{"license_token":"%s","media":[{"type":"FULL","formats":%s}],"track_tokens":["%s"]}`, c.Session.licenseToken, qualityFormats[quality], track.TrackToken)
req, err := http.NewRequestWithContext(ctx, http.MethodPost, "https://media.deezer.com/v1/get_url", bytes.NewBuffer([]byte(reqBody)))
if err != nil {
return nil, err
+2 -2
View File
@@ -19,7 +19,7 @@ type Credentials struct {
ARL string `json:"arl,omitempty"`
}
func LoadCredentials() (*Credentials, error) {
func loadCredentials() (*Credentials, error) {
secret, err := keyring.Get(keyringService, keyringUser)
if err != nil {
if errors.Is(err, keyring.ErrNotFound) {
@@ -36,7 +36,7 @@ func LoadCredentials() (*Credentials, error) {
return &creds, nil
}
func SaveCredentials(creds *Credentials) error {
func saveCredentials(creds *Credentials) error {
data, err := json.Marshal(creds)
if err != nil {
return err
+2 -2
View File
@@ -7,7 +7,7 @@ import (
)
func resolveARL(ctx context.Context, validate func(ctx context.Context, arl string) error) (string, error) {
creds, err := LoadCredentials()
creds, err := loadCredentials()
if err != nil {
return "", err
}
@@ -46,7 +46,7 @@ func Login(ctx context.Context, email, password string) (string, string, error)
return "", "", err
}
if err := SaveCredentials(creds); err != nil {
if err := saveCredentials(creds); err != nil {
return "", "", err
}
+4 -4
View File
@@ -14,8 +14,8 @@ import (
var ErrInvalidARL = errors.New("invalid or expired ARL cookie")
type Session struct {
APIToken string
LicenseToken string
apiToken string
licenseToken string
HTTPClient *http.Client
Premium bool
}
@@ -79,8 +79,8 @@ func authenticate(ctx context.Context, arlCookie string) (*Session, error) {
opts := res.Results.User.Options
return &Session{
APIToken: res.Results.APIToken,
LicenseToken: opts.LicenseToken,
apiToken: res.Results.APIToken,
licenseToken: opts.LicenseToken,
HTTPClient: client,
Premium: opts.MobileOffline || opts.WebOffline,
}, nil
+4 -4
View File
@@ -69,17 +69,17 @@ func (t *Track) Filename(kind Kind, mediaFormat string) string {
return base + "." + ext
}
func truncateBytes(s string, max int) string {
if max <= 0 {
func truncateBytes(s string, maxLen int) string {
if maxLen <= 0 {
return ""
}
if len(s) <= max {
if len(s) <= maxLen {
return s
}
last := 0
for i := range s {
if i > max {
if i > maxLen {
return s[:last]
}
last = i