- artists/{artist_id}/tracks and /direct-albums: artistID in path, return ArtistTracks/ArtistAlbums with pager
- likes: /users/me/likes/{type}s/{add-multiple|remove}, IDs as body params
- queue: /queues/{queue_id}/... instead of /queue/...?queue_id=...
- radio: /rotor/station/{station_id}/info and /tracks
- concerts: /concerts/{concert_id}/info, /concerts/tab-config
- playlists: /users/{user_id}/playlists
- labels: /labels/{label_id}, /albums, /artists
- clips: /clips/will/like, /artists/{artist_id}/blocks/artist-clips
- feed: /landing3/* endpoints
Co-Authored-By: Claude Code <noreply@anthropic.com>
71 lines
1.8 KiB
Go
71 lines
1.8 KiB
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"gitea.mrixs.me/Mrixs/yandex-music-api-go/internal/models"
|
|
)
|
|
|
|
// GetLabels gets all labels
|
|
func (c *Client) GetLabels(ctx context.Context) ([]*models.Label, error) {
|
|
var result []models.Label
|
|
if err := c.request.Get(ctx, "/labels", nil, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
labels := make([]*models.Label, len(result))
|
|
for i := range result {
|
|
result[i].SetClient(c)
|
|
labels[i] = &result[i]
|
|
}
|
|
return labels, nil
|
|
}
|
|
|
|
// GetLabel gets a label by ID
|
|
// GET /labels/{labelID}
|
|
func (c *Client) GetLabel(ctx context.Context, labelID string) (*models.Label, error) {
|
|
var result models.Label
|
|
if err := c.request.Get(ctx, fmt.Sprintf("/labels/%s", labelID), nil, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
result.SetClient(c)
|
|
return &result, nil
|
|
}
|
|
|
|
// GetLabelAlbums gets albums for a label
|
|
// GET /labels/{labelID}/albums
|
|
func (c *Client) GetLabelAlbums(ctx context.Context, labelID string, page, pageSize int) (*models.LabelAlbums, error) {
|
|
params := map[string]string{}
|
|
if page > 0 {
|
|
params["page"] = fmt.Sprintf("%d", page)
|
|
}
|
|
if pageSize > 0 {
|
|
params["page_size"] = fmt.Sprintf("%d", pageSize)
|
|
}
|
|
|
|
var result models.LabelAlbums
|
|
if err := c.request.Get(ctx, fmt.Sprintf("/labels/%s/albums", labelID), params, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return &result, nil
|
|
}
|
|
|
|
// GetLabelArtists gets artists for a label
|
|
// GET /labels/{labelID}/artists
|
|
func (c *Client) GetLabelArtists(ctx context.Context, labelID string, page, pageSize int) (*models.LabelArtists, error) {
|
|
params := map[string]string{}
|
|
if page > 0 {
|
|
params["page"] = fmt.Sprintf("%d", page)
|
|
}
|
|
if pageSize > 0 {
|
|
params["page_size"] = fmt.Sprintf("%d", pageSize)
|
|
}
|
|
|
|
var result models.LabelArtists
|
|
if err := c.request.Get(ctx, fmt.Sprintf("/labels/%s/artists", labelID), params, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return &result, nil
|
|
}
|