mirror of
https://github.com/riwiwa/muzi.git
synced 2026-03-04 00:51:59 -08:00
add multi-artist support for comma separated artists
This commit is contained in:
17
web/utils.go
17
web/utils.go
@@ -5,6 +5,8 @@ package web
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"muzi/db"
|
||||
)
|
||||
|
||||
// Subtracts two integers
|
||||
@@ -56,3 +58,18 @@ func formatTimestamp(timestamp time.Time) string {
|
||||
func formatTimestampFull(timestamp time.Time) string {
|
||||
return timestamp.Format("Monday 2 Jan 2006, 3:04pm")
|
||||
}
|
||||
|
||||
// GetArtistNames takes artist IDs and returns a slice of artist names
|
||||
func GetArtistNames(artistIds []int) []string {
|
||||
if artistIds == nil {
|
||||
return nil
|
||||
}
|
||||
var names []string
|
||||
for _, id := range artistIds {
|
||||
artist, err := db.GetArtistById(id)
|
||||
if err == nil {
|
||||
names = append(names, artist.Name)
|
||||
}
|
||||
}
|
||||
return names
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user