You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
unlock-music-cli/algo/ncm/meta.go

121 lines
3.3 KiB
Go

4 years ago
package ncm
import (
"strings"
"unlock-music.dev/cli/algo/common"
4 years ago
)
type ncmMeta interface {
common.AudioMeta
// GetFormat return the audio format, e.g. mp3, flac
4 years ago
GetFormat() string
// GetAlbumImageURL return the album image url
4 years ago
GetAlbumImageURL() string
}
type ncmMetaMusic struct {
4 years ago
Format string `json:"format"`
MusicID int `json:"musicId"`
MusicName string `json:"musicName"`
Artist [][]interface{} `json:"artist"`
Album string `json:"album"`
AlbumID int `json:"albumId"`
AlbumPicDocID interface{} `json:"albumPicDocId"`
AlbumPic string `json:"albumPic"`
MvID int `json:"mvId"`
Flag int `json:"flag"`
Bitrate int `json:"bitrate"`
Duration int `json:"duration"`
Alias []interface{} `json:"alias"`
TransNames []interface{} `json:"transNames"`
}
func (m *ncmMetaMusic) GetAlbumImageURL() string {
4 years ago
return m.AlbumPic
}
func (m *ncmMetaMusic) GetArtists() (artists []string) {
4 years ago
for _, artist := range m.Artist {
for _, item := range artist {
name, ok := item.(string)
if ok {
artists = append(artists, name)
}
}
}
return
}
func (m *ncmMetaMusic) GetTitle() string {
4 years ago
return m.MusicName
}
func (m *ncmMetaMusic) GetAlbum() string {
4 years ago
return m.Album
}
func (m *ncmMetaMusic) GetFormat() string {
4 years ago
return m.Format
}
//goland:noinspection SpellCheckingInspection
type ncmMetaDJ struct {
4 years ago
ProgramID int `json:"programId"`
ProgramName string `json:"programName"`
MainMusic ncmMetaMusic `json:"mainMusic"`
4 years ago
DjID int `json:"djId"`
DjName string `json:"djName"`
DjAvatarURL string `json:"djAvatarUrl"`
CreateTime int64 `json:"createTime"`
Brand string `json:"brand"`
Serial int `json:"serial"`
ProgramDesc string `json:"programDesc"`
ProgramFeeType int `json:"programFeeType"`
ProgramBuyed bool `json:"programBuyed"`
RadioID int `json:"radioId"`
RadioName string `json:"radioName"`
RadioCategory string `json:"radioCategory"`
RadioCategoryID int `json:"radioCategoryId"`
RadioDesc string `json:"radioDesc"`
RadioFeeType int `json:"radioFeeType"`
RadioFeeScope int `json:"radioFeeScope"`
RadioBuyed bool `json:"radioBuyed"`
RadioPrice int `json:"radioPrice"`
RadioPurchaseCount int `json:"radioPurchaseCount"`
}
func (m *ncmMetaDJ) GetArtists() []string {
4 years ago
if m.DjName != "" {
return []string{m.DjName}
}
return m.MainMusic.GetArtists()
}
func (m *ncmMetaDJ) GetTitle() string {
4 years ago
if m.ProgramName != "" {
return m.ProgramName
}
return m.MainMusic.GetTitle()
}
func (m *ncmMetaDJ) GetAlbum() string {
4 years ago
if m.Brand != "" {
return m.Brand
}
return m.MainMusic.GetAlbum()
}
func (m *ncmMetaDJ) GetFormat() string {
4 years ago
return m.MainMusic.GetFormat()
}
func (m *ncmMetaDJ) GetAlbumImageURL() string {
4 years ago
if strings.HasPrefix(m.MainMusic.GetAlbumImageURL(), "http") {
return m.MainMusic.GetAlbumImageURL()
}
return m.DjAvatarURL
}