- 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>
56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package models
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
// ArtistAlbums represents a page of albums by an artist
|
|
type ArtistAlbums struct {
|
|
BaseModel
|
|
Albums []Album `json:"albums"`
|
|
Pager *Pager `json:"pager"`
|
|
}
|
|
|
|
// DeJSON deserializes an ArtistAlbums from JSON
|
|
func (aa *ArtistAlbums) DeJSON(data []byte, c ClientInterface) (Model, error) {
|
|
var raw map[string]json.RawMessage
|
|
if err := json.Unmarshal(data, &raw); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
albums := &ArtistAlbums{BaseModel: *NewBaseModel(c)}
|
|
|
|
if v, ok := raw["albums"]; ok {
|
|
var albumList []Album
|
|
if err := json.Unmarshal(v, &albumList); err == nil {
|
|
albums.Albums = albumList
|
|
}
|
|
}
|
|
if v, ok := raw["pager"]; ok {
|
|
var pager Pager
|
|
if err := json.Unmarshal(v, &pager); err == nil {
|
|
albums.Pager = &pager
|
|
}
|
|
}
|
|
|
|
return albums, nil
|
|
}
|
|
|
|
// DeList deserializes a list of ArtistAlbums
|
|
func (aa *ArtistAlbums) DeList(data []byte, c ClientInterface) ([]Model, error) {
|
|
var rawList []json.RawMessage
|
|
if err := json.Unmarshal(data, &rawList); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
result := make([]Model, 0, len(rawList))
|
|
for _, item := range rawList {
|
|
albums := &ArtistAlbums{BaseModel: *NewBaseModel(c)}
|
|
if err := json.Unmarshal(item, albums); err != nil {
|
|
continue
|
|
}
|
|
result = append(result, albums)
|
|
}
|
|
return result, nil
|
|
}
|