Add missing Track, Album, Artist model types and client methods

Track: Added FileInfo, FileDownloadInfo, TrackFullInfo, SimilarTracks types
Album: Added AlbumSimilarEntities, AlbumTrailer, SimilarEntityItem types
Artist: Added ArtistSimilar, ArtistLinks, ArtistAbout, ArtistInfo, ArtistSkeleton,
       ArtistTrailerStatus, ArtistLink, Stats, SkeletonBlock types

Client methods added:
- artists.go: GetArtistBriefInfo, GetArtistSimilar, GetArtistLinks, GetArtistAlsoAlbums,
  GetArtistDiscographyAlbums, GetArtistSafeDirectAlbums, GetArtistTrackIds, GetArtistAbout,
  GetArtistDonation, GetArtistInfo, GetArtistSkeleton, GetArtistTrailer
- albums.go: GetAlbumSimilarEntities, GetAlbumTrailer
- tracks.go: GetTracksFileInfo, GetTracksSimilar, GetTrackTrailer, GetTrackFullInfo
This commit is contained in:
Mrixs committed 2026-10-18 13:24:41 +03:00
1 parent 9d3bcc4a9b
commit 49920d8908
6 files changed
+783

No files matched your search

+118
View File
@@ -535,3 +535,121 @@ func (tt *TrackTrailer) DeList(data []byte, c ClientInterface) ([]Model, error)
}
return result, nil
}
// FileInfo represents file info for a track.
type FileInfo struct {
BaseModel
DownloadInfo *FileDownloadInfo `json:"download_info"`
}
// DeJSON deserializes FileInfo from JSON data.
func (fi *FileInfo) DeJSON(data []byte, c ClientInterface) (Model, error) {
var raw map[string]json.RawMessage
if err := json.Unmarshal(data, &raw); err != nil {
return nil, err
}
info := &FileInfo{BaseModel: *NewBaseModel(c)}
if v, ok := raw["download_info"]; ok {
var di FileDownloadInfo
json.Unmarshal(v, &di)
info.DownloadInfo = &di
}
return info, nil
}
// DeList deserializes a list of FileInfo from JSON data.
func (fi *FileInfo) 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 {
info := &FileInfo{BaseModel: *NewBaseModel(c)}
if err := json.Unmarshal(item, info); err != nil {
continue
}
result = append(result, info)
}
return result, nil
}
// FileDownloadInfo represents file download info.
type FileDownloadInfo struct {
BaseModel
TrackID string `json:"track_id"`
Quality string `json:"quality"`
Codec string `json:"codec"`
Bitrate int `json:"bitrate"`
Transport string `json:"transport"`
URL string `json:"url"`
URLs []string `json:"urls"`
RealID string `json:"real_id"`
Gain bool `json:"gain"`
Key string `json:"key"`
}
// DeJSON deserializes FileDownloadInfo from JSON data.
func (fdi *FileDownloadInfo) DeJSON(data []byte, c ClientInterface) (Model, error) {
var raw map[string]json.RawMessage
if err := json.Unmarshal(data, &raw); err != nil {
return nil, err
}
info := &FileDownloadInfo{BaseModel: *NewBaseModel(c)}
if v, ok := raw["track_id"]; ok {
json.Unmarshal(v, &info.TrackID)
}
if v, ok := raw["quality"]; ok {
json.Unmarshal(v, &info.Quality)
}
if v, ok := raw["codec"]; ok {
json.Unmarshal(v, &info.Codec)
}
if v, ok := raw["bitrate"]; ok {
json.Unmarshal(v, &info.Bitrate)
}
if v, ok := raw["transport"]; ok {
json.Unmarshal(v, &info.Transport)
}
if v, ok := raw["url"]; ok {
json.Unmarshal(v, &info.URL)
}
if v, ok := raw["urls"]; ok {
json.Unmarshal(v, &info.URLs)
}
if v, ok := raw["real_id"]; ok {
json.Unmarshal(v, &info.RealID)
}
if v, ok := raw["gain"]; ok {
json.Unmarshal(v, &info.Gain)
}
if v, ok := raw["key"]; ok {
json.Unmarshal(v, &info.Key)
}
return info, nil
}
// DeList deserializes a list of FileDownloadInfo from JSON data.
func (fdi *FileDownloadInfo) 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 {
info := &FileDownloadInfo{BaseModel: *NewBaseModel(c)}
if err := json.Unmarshal(item, info); err != nil {
continue
}
result = append(result, info)
}
return result, nil
}