Fix ID fields to accept both JSON strings and numbers
The Yandex Music API returns IDs as both JSON strings and numbers depending on the endpoint. Added JSONID custom type in internal/models/base.go that implements json.Unmarshaler to accept both formats and store as string. Changed ID fields from string to JSONID: - Track.ID, Major.ID, TrackLyricsInfo.ID (track.go) - Album.ID, TrailerInfo.TrackID, TrailerInfo.AlbumID (album.go) Updated example to convert JSONID to string when passing to client methods. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
1 parent
0456ca0665
commit
5535d2a941
4 files changed
+49
-20
No files matched your search
@@ -8,7 +8,7 @@ import (
|
||||
// Track represents a full track from the Yandex Music API.
|
||||
type Track struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
ID JSONID `json:"id"`
|
||||
Title string `json:"title"`
|
||||
DurationMs int `json:"duration_ms"`
|
||||
StorageID string `json:"storage_id"`
|
||||
@@ -149,14 +149,14 @@ func (t *Track) GetDownloadInfo(quality string) *DownloadInfo {
|
||||
|
||||
// Major represents major label info for a track.
|
||||
type Major struct {
|
||||
ID string `json:"id"`
|
||||
ID JSONID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// TrackLyricsInfo represents minimal lyrics info for a track.
|
||||
type TrackLyricsInfo struct {
|
||||
ID string `json:"id"`
|
||||
ID JSONID `json:"id"`
|
||||
Text string `json:"text"`
|
||||
Major *Major `json:"major"`
|
||||
Available bool `json:"available"`
|
||||
|
||||
Reference in new issue
Block a user