feat(subsonic): expose album isCompilation and releaseTypes
This commit is contained in:
No files matched your search
@@ -19,6 +19,7 @@ func NewAlbumByFolder(f *db.Album) *Album {
|
||||
Duration: f.Duration,
|
||||
Created: f.CreatedAt,
|
||||
AverageRating: formatRating(f.AverageRating),
|
||||
ReleaseTypes: []string{},
|
||||
}
|
||||
if f.AlbumStar != nil {
|
||||
a.Starred = &f.AlbumStar.StarDate
|
||||
|
||||
@@ -22,6 +22,8 @@ func NewAlbumByTags(a *db.Album, artists []*db.Artist) *Album {
|
||||
Year: a.TagYear,
|
||||
Tracks: []*TrackChild{},
|
||||
AverageRating: formatRating(a.AverageRating),
|
||||
IsCompilation: a.TagCompilation,
|
||||
ReleaseTypes: formatReleaseTypes(a.TagReleaseType),
|
||||
}
|
||||
if a.Cover != "" {
|
||||
ret.CoverID = a.SID()
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
"go.senan.xyz/gonic"
|
||||
"go.senan.xyz/gonic/server/ctrlsubsonic/specid"
|
||||
@@ -150,6 +151,9 @@ type Album struct {
|
||||
Year int `xml:"year,attr,omitempty" json:"year,omitempty"`
|
||||
Tracks []*TrackChild `xml:"song,omitempty" json:"song,omitempty"`
|
||||
|
||||
IsCompilation bool `xml:"isCompilation" json:"isCompilation"`
|
||||
ReleaseTypes []string `xml:"releaseTypes" json:"releaseTypes"`
|
||||
|
||||
// star / rating
|
||||
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
|
||||
UserRating int `xml:"userRating,attr,omitempty" json:"userRating,omitempty"`
|
||||
@@ -488,6 +492,25 @@ func formatExt(ext string) string {
|
||||
return strings.TrimPrefix(ext, ".")
|
||||
}
|
||||
|
||||
func formatReleaseTypes(types string) []string {
|
||||
parts := strings.Split(types, ",")
|
||||
if len(parts) == 0 {
|
||||
return []string{}
|
||||
}
|
||||
for i, part := range parts {
|
||||
part = strings.TrimSpace(part)
|
||||
if len(part) == 0 {
|
||||
continue
|
||||
}
|
||||
part = string(unicode.ToUpper([]rune(part)[0])) + string([]rune(part)[1:])
|
||||
if part == "Ep" {
|
||||
part = "EP"
|
||||
}
|
||||
parts[i] = part
|
||||
}
|
||||
return parts
|
||||
}
|
||||
|
||||
var doublePuncExpr = regexp.MustCompile(`\.\s+\.\s+`)
|
||||
var licenceExpr = regexp.MustCompile(`(?i)\buser-contributed text.*`)
|
||||
var readMoreExpr = regexp.MustCompile(`(?i)\bread more on.*`)
|
||||
|
||||
Reference in New Issue
Block a user