my god...it's finally done
This commit is contained in:
parent
2baf71214e
commit
19d76ebc47
43 changed files with 1008 additions and 550 deletions
|
@ -1,7 +1,5 @@
|
|||
package model
|
||||
|
||||
import "strings"
|
||||
|
||||
type (
|
||||
Artist struct {
|
||||
ID string `json:"id"`
|
||||
|
@ -21,56 +19,3 @@ func (artist Artist) GetAvatar() string {
|
|||
}
|
||||
return artist.Avatar
|
||||
}
|
||||
|
||||
func (release FullRelease) GetUniqueArtists(only_primary bool) []*Artist {
|
||||
var artists = []*Artist{}
|
||||
|
||||
for _, credit := range release.Credits {
|
||||
if only_primary && !credit.Primary {
|
||||
continue
|
||||
}
|
||||
|
||||
exists := false
|
||||
for _, a := range artists {
|
||||
if a.ID == credit.Artist.ID {
|
||||
exists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if exists {
|
||||
continue
|
||||
}
|
||||
|
||||
artists = append(artists, &credit.Artist)
|
||||
}
|
||||
|
||||
return artists
|
||||
}
|
||||
|
||||
func (release FullRelease) GetUniqueArtistNames(only_primary bool) []string {
|
||||
var names = []string{}
|
||||
for _, artist := range release.GetUniqueArtists(only_primary) {
|
||||
names = append(names, artist.Name)
|
||||
}
|
||||
|
||||
return names
|
||||
}
|
||||
|
||||
func (release FullRelease) PrintArtists(only_primary bool, ampersand bool) string {
|
||||
names := release.GetUniqueArtistNames(only_primary)
|
||||
|
||||
if len(names) == 0 {
|
||||
return "Unknown Artist"
|
||||
} else if len(names) == 1 {
|
||||
return names[0]
|
||||
}
|
||||
|
||||
if ampersand {
|
||||
res := strings.Join(names[:len(names)-1], ", ")
|
||||
res += " & " + names[len(names)-1]
|
||||
return res
|
||||
} else {
|
||||
return strings.Join(names[:], ", ")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue