From 9d3bcc4a9b4c5968fe820efeddcd9a3f55a42a1c Mon Sep 17 00:00:00 2001 From: Vladimir Zagainov Date: Sun, 18 Oct 2026 13:18:24 +0300 Subject: [PATCH] Add missing model fields from Python audit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LandingList: Added type, type_for_from, title, id, new_releases, new_playlists, podcasts New type: PlaylistID Presaves: Added upcoming_albums, released_albums Presaves: Added DeJSON method QueueItem: Added id, context, modified fields (fixed duplicate context) Clip: Fixed PreviewURI → PreviewURL field name --- internal/models/landing.go | 59 +++++++++++++++++++++++++++++++++++--- internal/models/pin.go | 47 +++++++++++++++++++++++++++--- internal/models/queue.go | 20 +++++++------ 3 files changed, 109 insertions(+), 17 deletions(-) diff --git a/internal/models/landing.go b/internal/models/landing.go index f043599..65b444a 100644 --- a/internal/models/landing.go +++ b/internal/models/landing.go @@ -102,10 +102,61 @@ type LandingBlockData struct { // LandingList represents a list of landings. type LandingList struct { BaseModel - Landings []Landing `json:"landings"` - Total int `json:"total"` - Page int `json:"page"` - PageSize int `json:"page_size"` + Type string `json:"type"` + TypeForFrom string `json:"type_for_from"` + Title string `json:"title"` + ID string `json:"id"` + Landings []Landing `json:"landings"` + NewReleases []int `json:"new_releases"` + NewPlaylists []PlaylistID `json:"new_playlists"` + Podcasts []int `json:"podcasts"` + Total int `json:"total"` + Page int `json:"page"` + PageSize int `json:"page_size"` +} + +// PlaylistID represents a playlist ID reference. +type PlaylistID struct { + BaseModel + UID int `json:"uid"` + Kind int `json:"kind"` +} + +// DeJSON deserializes a PlaylistID from JSON data. +func (pid *PlaylistID) DeJSON(data []byte, c ClientInterface) (Model, error) { + var raw map[string]json.RawMessage + if err := json.Unmarshal(data, &raw); err != nil { + return nil, err + } + + playlistID := &PlaylistID{BaseModel: *NewBaseModel(c)} + + if v, ok := raw["uid"]; ok { + json.Unmarshal(v, &playlistID.UID) + } + if v, ok := raw["kind"]; ok { + json.Unmarshal(v, &playlistID.Kind) + } + + return playlistID, nil +} + +// DeList deserializes a list of PlaylistID from JSON data. +func (pid *PlaylistID) 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 { + pid := &PlaylistID{BaseModel: *NewBaseModel(c)} + if err := json.Unmarshal(item, pid); err != nil { + continue + } + result = append(result, pid) + } + return result, nil } // DeJSON deserializes a LandingList from JSON data. diff --git a/internal/models/pin.go b/internal/models/pin.go index a33327c..005116f 100644 --- a/internal/models/pin.go +++ b/internal/models/pin.go @@ -127,10 +127,12 @@ type PinsList struct { // Presaves represents presaves. type Presaves struct { BaseModel - Presaves []Presave `json:"presaves"` - Total int `json:"total"` - Page int `json:"page"` - PageSize int `json:"page_size"` + UpcomingAlbums []Album `json:"upcoming_albums"` + ReleasedAlbums []Album `json:"released_albums"` + Presaves []Presave `json:"presaves"` + Total int `json:"total"` + Page int `json:"page"` + PageSize int `json:"page_size"` } // Presave represents a presave. @@ -219,3 +221,40 @@ func (p *Presave) DeList(data []byte, client ClientInterface) ([]Model, error) { } return result, nil } + +// DeJSON deserializes Presaves from JSON data. +func (p *Presaves) DeJSON(data []byte, client ClientInterface) (Model, error) { + var raw map[string]json.RawMessage + if err := json.Unmarshal(data, &raw); err != nil { + return nil, err + } + + presaves := &Presaves{BaseModel: *NewBaseModel(client)} + + if v, ok := raw["upcoming_albums"]; ok { + var albums []Album + json.Unmarshal(v, &albums) + presaves.UpcomingAlbums = albums + } + if v, ok := raw["released_albums"]; ok { + var albums []Album + json.Unmarshal(v, &albums) + presaves.ReleasedAlbums = albums + } + if v, ok := raw["presaves"]; ok { + var presaveList []Presave + json.Unmarshal(v, &presaveList) + presaves.Presaves = presaveList + } + if v, ok := raw["total"]; ok { + json.Unmarshal(v, &presaves.Total) + } + if v, ok := raw["page"]; ok { + json.Unmarshal(v, &presaves.Page) + } + if v, ok := raw["page_size"]; ok { + json.Unmarshal(v, &presaves.PageSize) + } + + return presaves, nil +} diff --git a/internal/models/queue.go b/internal/models/queue.go index 2212324..6d4c645 100644 --- a/internal/models/queue.go +++ b/internal/models/queue.go @@ -93,13 +93,15 @@ func (q *Queue) DeList(data []byte, c ClientInterface) ([]Model, error) { // QueueItem represents a queue item. type QueueItem struct { BaseModel - TrackID string `json:"track_id"` - Track *Track `json:"track"` - Position int `json:"position"` - AddedAt string `json:"added_at"` - AddedBy string `json:"added_by"` - Playable bool `json:"playable"` - PlayContext *PlayContext `json:"play_context"` + ID JSONID `json:"id"` + TrackID string `json:"track_id"` + Track *Track `json:"track"` + Position int `json:"position"` + AddedAt string `json:"added_at"` + AddedBy string `json:"added_by"` + Playable bool `json:"playable"` + Modified string `json:"modified"` + Context *PlayContext `json:"context"` } // DeJSON deserializes a QueueItem from JSON data. @@ -132,10 +134,10 @@ func (qi *QueueItem) DeJSON(data []byte, c ClientInterface) (Model, error) { json.Unmarshal(v, &track) item.Track = &track } - if v, ok := raw["play_context"]; ok { + if v, ok := raw["context"]; ok { var ctx PlayContext json.Unmarshal(v, &ctx) - item.PlayContext = &ctx + item.Context = &ctx } return item, nil