Adds list of author computation
This commit is contained in:
31
album.go
31
album.go
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
@@ -70,3 +71,33 @@ type Album struct {
|
||||
func AlbumIDString(ID AlbumID) string {
|
||||
return strconv.FormatUint(uint64(ID), 10)
|
||||
}
|
||||
|
||||
var rxAuthorSkip = regexp.MustCompile(`\A<.*>\z`)
|
||||
|
||||
func (a *Album) Authors() []string {
|
||||
authorsUnsafe := make([]string, 0, len(a.Scenarists)+len(a.Colorists)+len(a.Designers))
|
||||
authors := make([]string, 0, len(a.Scenarists)+len(a.Colorists)+len(a.Designers))
|
||||
set := map[string]bool{}
|
||||
|
||||
authorsUnsafe = append(authorsUnsafe, a.Designers...)
|
||||
authorsUnsafe = append(authorsUnsafe, a.Scenarists...)
|
||||
authorsUnsafe = append(authorsUnsafe, a.Colorists...)
|
||||
|
||||
for _, author := range authorsUnsafe {
|
||||
if rxAuthorSkip.MatchString(author) == true || set[author] == true {
|
||||
continue
|
||||
}
|
||||
authors = append(authors, author)
|
||||
set[author] = true
|
||||
}
|
||||
|
||||
return authors
|
||||
}
|
||||
|
||||
func (a *Album) String() string {
|
||||
res := strconv.FormatUint(uint64(a.ID), 10) + ": "
|
||||
if len(a.Collection) > 0 {
|
||||
res += a.Collection + ": "
|
||||
}
|
||||
return res + a.Title
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user