removed function fetch list

This commit is contained in:
Hazel Noack
2025-10-09 12:35:00 +02:00
parent 6bd957b09e
commit e79e364ff9
4 changed files with 46 additions and 42 deletions

View File

@@ -11,6 +11,7 @@ type MusicObject interface {
Compile() MusicObject
GetIndices() []string
Merge(other MusicObject) MusicObject
Related() []MusicObject
}
func dedupeMusicObjects[T MusicObject](inputMusicObjects []T) []T {
@@ -71,6 +72,20 @@ type Song struct {
Sources []Source
}
func (m Song) Related() []MusicObject {
res := []MusicObject{}
for _, a := range m.Artists {
res = append(res, a)
}
if m.Album.Name != "" {
res = append(res, m.Album)
}
res = append(res, m)
return res
}
func (m Song) GetSources() []Source {
return m.Sources
}
@@ -127,6 +142,20 @@ type Album struct {
Sources []Source
}
func (m Album) Related() []MusicObject {
res := []MusicObject{}
for _, a := range m.Artists {
res = append(res, a)
}
res = append(res, m)
for _, a := range m.Songs {
res = append(res, a)
}
return res
}
func (m Album) GetSources() []Source {
return m.Sources
}
@@ -183,6 +212,16 @@ type Artist struct {
Sources []Source
}
func (m Artist) Related() []MusicObject {
res := []MusicObject{m}
for _, a := range m.Albums {
res = append(res, a)
}
return res
}
func (m Artist) GetSources() []Source {
return m.Sources
}