feat(subsonic): expose album isCompilation and releaseTypes

This commit is contained in:
sentriz
2025-07-06 22:01:24 +01:00
parent 7d095ede6b
commit 29b754973d
23 changed files with 478 additions and 242 deletions

No files matched your search

+2
View File
@@ -339,6 +339,8 @@ type Album struct {
TagTitleUDec string `sql:"default: null"` TagTitleUDec string `sql:"default: null"`
TagBrainzID string `sql:"default: null"` TagBrainzID string `sql:"default: null"`
TagYear int `sql:"default: null"` TagYear int `sql:"default: null"`
TagCompilation bool `sql:"default: null"`
TagReleaseType string `sql:"default: null"`
Tracks []*Track Tracks []*Track
ChildCount int `sql:"-"` ChildCount int `sql:"-"`
Duration int `sql:"-"` Duration int `sql:"-"`
+7
View File
@@ -79,6 +79,7 @@ func (db *DB) Migrate(ctx MigrationContext) error {
construct(ctx, "202504132036", migratePodcast), construct(ctx, "202504132036", migratePodcast),
construct(ctx, "202505211202", migrateTrackAddIndexOnBrainzID), construct(ctx, "202505211202", migrateTrackAddIndexOnBrainzID),
construct(ctx, "202505262025", migrateAlbumAddIndexOnBrainzID), construct(ctx, "202505262025", migrateAlbumAddIndexOnBrainzID),
construct(ctx, "202507062103", migrateAlbumCompilationReleaseType),
} }
return gormigrate. return gormigrate.
@@ -854,3 +855,9 @@ func migrateAlbumAddIndexOnBrainzID(tx *gorm.DB, _ MigrationContext) error {
CREATE INDEX idx_albums_brainz_id ON "albums" (tag_brainz_id); CREATE INDEX idx_albums_brainz_id ON "albums" (tag_brainz_id);
`).Error `).Error
} }
func migrateAlbumCompilationReleaseType(tx *gorm.DB, _ MigrationContext) error {
return tx.AutoMigrate(
Album{},
).Error
}
+3
View File
@@ -363,6 +363,9 @@ func (i *TagInfo) TrackNumber() int { return 1 }
func (i *TagInfo) DiscNumber() int { return 1 } func (i *TagInfo) DiscNumber() int { return 1 }
func (i *TagInfo) Year() int { return 2021 } func (i *TagInfo) Year() int { return 2021 }
func (i *TagInfo) Compilation() bool { return false }
func (i *TagInfo) ReleaseType() string { return "album" }
func (i *TagInfo) ReplayGainTrackGain() float32 { return 0 } func (i *TagInfo) ReplayGainTrackGain() float32 { return 0 }
func (i *TagInfo) ReplayGainTrackPeak() float32 { return 0 } func (i *TagInfo) ReplayGainTrackPeak() float32 { return 0 }
func (i *TagInfo) ReplayGainAlbumGain() float32 { return 0 } func (i *TagInfo) ReplayGainAlbumGain() float32 { return 0 }
+2
View File
@@ -424,6 +424,8 @@ func populateAlbum(tx *db.DB, album *db.Album, trags tagcommon.Info, modTime, cr
album.TagAlbumArtist = tagcommon.MustAlbumArtist(trags) album.TagAlbumArtist = tagcommon.MustAlbumArtist(trags)
album.TagBrainzID = trags.AlbumBrainzID() album.TagBrainzID = trags.AlbumBrainzID()
album.TagYear = trags.Year() album.TagYear = trags.Year()
album.TagCompilation = trags.Compilation()
album.TagReleaseType = trags.ReleaseType()
album.ModifiedAt = modTime album.ModifiedAt = modTime
if album.CreatedAt.After(createTime) { if album.CreatedAt.After(createTime) {
@@ -19,6 +19,7 @@ func NewAlbumByFolder(f *db.Album) *Album {
Duration: f.Duration, Duration: f.Duration,
Created: f.CreatedAt, Created: f.CreatedAt,
AverageRating: formatRating(f.AverageRating), AverageRating: formatRating(f.AverageRating),
ReleaseTypes: []string{},
} }
if f.AlbumStar != nil { if f.AlbumStar != nil {
a.Starred = &f.AlbumStar.StarDate a.Starred = &f.AlbumStar.StarDate
@@ -22,6 +22,8 @@ func NewAlbumByTags(a *db.Album, artists []*db.Artist) *Album {
Year: a.TagYear, Year: a.TagYear,
Tracks: []*TrackChild{}, Tracks: []*TrackChild{},
AverageRating: formatRating(a.AverageRating), AverageRating: formatRating(a.AverageRating),
IsCompilation: a.TagCompilation,
ReleaseTypes: formatReleaseTypes(a.TagReleaseType),
} }
if a.Cover != "" { if a.Cover != "" {
ret.CoverID = a.SID() ret.CoverID = a.SID()
+23
View File
@@ -5,6 +5,7 @@ import (
"regexp" "regexp"
"strings" "strings"
"time" "time"
"unicode"
"go.senan.xyz/gonic" "go.senan.xyz/gonic"
"go.senan.xyz/gonic/server/ctrlsubsonic/specid" "go.senan.xyz/gonic/server/ctrlsubsonic/specid"
@@ -150,6 +151,9 @@ type Album struct {
Year int `xml:"year,attr,omitempty" json:"year,omitempty"` Year int `xml:"year,attr,omitempty" json:"year,omitempty"`
Tracks []*TrackChild `xml:"song,omitempty" json:"song,omitempty"` Tracks []*TrackChild `xml:"song,omitempty" json:"song,omitempty"`
IsCompilation bool `xml:"isCompilation" json:"isCompilation"`
ReleaseTypes []string `xml:"releaseTypes" json:"releaseTypes"`
// star / rating // star / rating
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"` Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
UserRating int `xml:"userRating,attr,omitempty" json:"userRating,omitempty"` UserRating int `xml:"userRating,attr,omitempty" json:"userRating,omitempty"`
@@ -488,6 +492,25 @@ func formatExt(ext string) string {
return strings.TrimPrefix(ext, ".") 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 doublePuncExpr = regexp.MustCompile(`\.\s+\.\s+`)
var licenceExpr = regexp.MustCompile(`(?i)\buser-contributed text.*`) var licenceExpr = regexp.MustCompile(`(?i)\buser-contributed text.*`)
var readMoreExpr = regexp.MustCompile(`(?i)\bread more on.*`) var readMoreExpr = regexp.MustCompile(`(?i)\bread more on.*`)
@@ -21,7 +21,9 @@
"name": "album-0", "name": "album-0",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-4", "id": "al-4",
@@ -37,7 +39,9 @@
"name": "album-1", "name": "album-1",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-5", "id": "al-5",
@@ -53,7 +57,9 @@
"name": "album-2", "name": "album-2",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-7", "id": "al-7",
@@ -69,7 +75,9 @@
"name": "album-0", "name": "album-0",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-8", "id": "al-8",
@@ -85,7 +93,9 @@
"name": "album-1", "name": "album-1",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-9", "id": "al-9",
@@ -101,7 +111,9 @@
"name": "album-2", "name": "album-2",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-11", "id": "al-11",
@@ -117,7 +129,9 @@
"name": "album-0", "name": "album-0",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-12", "id": "al-12",
@@ -133,7 +147,9 @@
"name": "album-1", "name": "album-1",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-13", "id": "al-13",
@@ -149,7 +165,9 @@
"name": "album-2", "name": "album-2",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
} }
] ]
} }
+27 -9
View File
@@ -21,7 +21,9 @@
"name": "album-0", "name": "album-0",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-7", "id": "al-7",
@@ -37,7 +39,9 @@
"name": "album-0", "name": "album-0",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-11", "id": "al-11",
@@ -53,7 +57,9 @@
"name": "album-0", "name": "album-0",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-4", "id": "al-4",
@@ -69,7 +75,9 @@
"name": "album-1", "name": "album-1",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-8", "id": "al-8",
@@ -85,7 +93,9 @@
"name": "album-1", "name": "album-1",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-12", "id": "al-12",
@@ -101,7 +111,9 @@
"name": "album-1", "name": "album-1",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-5", "id": "al-5",
@@ -117,7 +129,9 @@
"name": "album-2", "name": "album-2",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-9", "id": "al-9",
@@ -133,7 +147,9 @@
"name": "album-2", "name": "album-2",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-13", "id": "al-13",
@@ -149,7 +165,9 @@
"name": "album-2", "name": "album-2",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
} }
] ]
} }
+27 -9
View File
@@ -21,7 +21,9 @@
"name": "album-0", "name": "album-0",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-4", "id": "al-4",
@@ -37,7 +39,9 @@
"name": "album-1", "name": "album-1",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-5", "id": "al-5",
@@ -53,7 +57,9 @@
"name": "album-2", "name": "album-2",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-7", "id": "al-7",
@@ -69,7 +75,9 @@
"name": "album-0", "name": "album-0",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-8", "id": "al-8",
@@ -85,7 +93,9 @@
"name": "album-1", "name": "album-1",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-9", "id": "al-9",
@@ -101,7 +111,9 @@
"name": "album-2", "name": "album-2",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-11", "id": "al-11",
@@ -117,7 +129,9 @@
"name": "album-0", "name": "album-0",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-12", "id": "al-12",
@@ -133,7 +147,9 @@
"name": "album-1", "name": "album-1",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-13", "id": "al-13",
@@ -149,7 +165,9 @@
"name": "album-2", "name": "album-2",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
} }
] ]
} }
+102 -84
View File
@@ -7,6 +7,24 @@
"openSubsonic": true, "openSubsonic": true,
"albumList": { "albumList": {
"album": [ "album": [
{
"id": "al-11",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-2",
"artists": null,
"displayArtist": "",
"title": "album-0",
"album": "album-0",
"parent": "al-10",
"isDir": true,
"coverArt": "al-11",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{ {
"id": "al-5", "id": "al-5",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
@@ -21,7 +39,9 @@
"name": "album-2", "name": "album-2",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-7", "id": "al-7",
@@ -37,71 +57,9 @@
"name": "album-0", "name": "album-0",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
}, "isCompilation": false,
{ "releaseTypes": []
"id": "al-13",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-2",
"artists": null,
"displayArtist": "",
"title": "album-2",
"album": "album-2",
"parent": "al-10",
"isDir": true,
"coverArt": "al-13",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0
},
{
"id": "al-3",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-0",
"artists": null,
"displayArtist": "",
"title": "album-0",
"album": "album-0",
"parent": "al-2",
"isDir": true,
"coverArt": "al-3",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0
},
{
"id": "al-4",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-0",
"artists": null,
"displayArtist": "",
"title": "album-1",
"album": "album-1",
"parent": "al-2",
"isDir": true,
"coverArt": "al-4",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0
},
{
"id": "al-9",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-1",
"artists": null,
"displayArtist": "",
"title": "album-2",
"album": "album-2",
"parent": "al-6",
"isDir": true,
"coverArt": "al-9",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0
}, },
{ {
"id": "al-12", "id": "al-12",
@@ -117,7 +75,81 @@
"name": "album-1", "name": "album-1",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-9",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-1",
"artists": null,
"displayArtist": "",
"title": "album-2",
"album": "album-2",
"parent": "al-6",
"isDir": true,
"coverArt": "al-9",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-4",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-0",
"artists": null,
"displayArtist": "",
"title": "album-1",
"album": "album-1",
"parent": "al-2",
"isDir": true,
"coverArt": "al-4",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-3",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-0",
"artists": null,
"displayArtist": "",
"title": "album-0",
"album": "album-0",
"parent": "al-2",
"isDir": true,
"coverArt": "al-3",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-13",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-2",
"artists": null,
"displayArtist": "",
"title": "album-2",
"album": "album-2",
"parent": "al-10",
"isDir": true,
"coverArt": "al-13",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
}, },
{ {
"id": "al-8", "id": "al-8",
@@ -133,23 +165,9 @@
"name": "album-1", "name": "album-1",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0 "playCount": 0,
}, "isCompilation": false,
{ "releaseTypes": []
"id": "al-11",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-2",
"artists": null,
"displayArtist": "",
"title": "album-0",
"album": "album-0",
"parent": "al-10",
"isDir": true,
"coverArt": "al-11",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0
} }
] ]
} }
@@ -21,7 +21,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-4", "id": "al-4",
@@ -37,7 +39,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-5", "id": "al-5",
@@ -53,7 +57,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-7", "id": "al-7",
@@ -69,7 +75,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-8", "id": "al-8",
@@ -85,7 +93,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-9", "id": "al-9",
@@ -101,7 +111,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-11", "id": "al-11",
@@ -117,7 +129,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-12", "id": "al-12",
@@ -133,7 +147,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-13", "id": "al-13",
@@ -149,7 +165,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
} }
] ]
} }
@@ -21,7 +21,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-7", "id": "al-7",
@@ -37,7 +39,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-11", "id": "al-11",
@@ -53,7 +57,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-4", "id": "al-4",
@@ -69,7 +75,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-8", "id": "al-8",
@@ -85,7 +93,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-12", "id": "al-12",
@@ -101,7 +111,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-5", "id": "al-5",
@@ -117,7 +129,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-9", "id": "al-9",
@@ -133,7 +147,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-13", "id": "al-13",
@@ -149,7 +165,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
} }
] ]
} }
+27 -9
View File
@@ -21,7 +21,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-4", "id": "al-4",
@@ -37,7 +39,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-5", "id": "al-5",
@@ -53,7 +57,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-7", "id": "al-7",
@@ -69,7 +75,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-8", "id": "al-8",
@@ -85,7 +93,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-9", "id": "al-9",
@@ -101,7 +111,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-11", "id": "al-11",
@@ -117,7 +129,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-12", "id": "al-12",
@@ -133,7 +147,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-13", "id": "al-13",
@@ -149,7 +165,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
} }
] ]
} }
+102 -84
View File
@@ -21,39 +21,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
}, "isCompilation": false,
{ "releaseTypes": ["Album"]
"id": "al-7",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-2",
"artist": "artist-1",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "artist-1",
"title": "album-0",
"album": "album-0",
"coverArt": "al-7",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
},
{
"id": "al-11",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-3",
"artist": "artist-2",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "artist-2",
"title": "album-0",
"album": "album-0",
"coverArt": "al-11",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
}, },
{ {
"id": "al-13", "id": "al-13",
@@ -69,55 +39,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
}, "isCompilation": false,
{ "releaseTypes": ["Album"]
"id": "al-4",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-1",
"artist": "artist-0",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "artist-0",
"title": "album-1",
"album": "album-1",
"coverArt": "al-4",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
},
{
"id": "al-12",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-3",
"artist": "artist-2",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "artist-2",
"title": "album-1",
"album": "album-1",
"coverArt": "al-12",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
},
{
"id": "al-5",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-1",
"artist": "artist-0",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "artist-0",
"title": "album-2",
"album": "album-2",
"coverArt": "al-5",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
}, },
{ {
"id": "al-8", "id": "al-8",
@@ -133,7 +57,9 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-9", "id": "al-9",
@@ -149,7 +75,99 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-5",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-1",
"artist": "artist-0",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "artist-0",
"title": "album-2",
"album": "album-2",
"coverArt": "al-5",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-12",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-3",
"artist": "artist-2",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "artist-2",
"title": "album-1",
"album": "album-1",
"coverArt": "al-12",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-7",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-2",
"artist": "artist-1",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "artist-1",
"title": "album-0",
"album": "album-0",
"coverArt": "al-7",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-4",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-1",
"artist": "artist-0",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "artist-0",
"title": "album-1",
"album": "album-1",
"coverArt": "al-4",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-11",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-3",
"artist": "artist-2",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "artist-2",
"title": "album-0",
"album": "album-0",
"coverArt": "al-11",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
} }
] ]
} }
+3 -1
View File
@@ -107,7 +107,9 @@
"musicBrainzId": "", "musicBrainzId": "",
"replayGain": null "replayGain": null
} }
] ],
"isCompilation": false,
"releaseTypes": ["Album"]
} }
} }
} }
+3 -1
View File
@@ -16,7 +16,9 @@
"name": "", "name": "",
"songCount": 0, "songCount": 0,
"duration": 0, "duration": 0,
"playCount": 0 "playCount": 0,
"isCompilation": false,
"releaseTypes": [""]
} }
} }
} }
+9 -3
View File
@@ -26,7 +26,9 @@
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre", "genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-4", "id": "al-4",
@@ -44,7 +46,9 @@
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre", "genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-5", "id": "al-5",
@@ -62,7 +66,9 @@
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre", "genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
} }
] ]
} }
+9 -3
View File
@@ -26,7 +26,9 @@
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre", "genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-12", "id": "al-12",
@@ -44,7 +46,9 @@
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre", "genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-13", "id": "al-13",
@@ -62,7 +66,9 @@
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre", "genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
} }
] ]
} }
+9 -3
View File
@@ -26,7 +26,9 @@
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre", "genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-8", "id": "al-8",
@@ -44,7 +46,9 @@
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre", "genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-9", "id": "al-9",
@@ -62,7 +66,9 @@
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre", "genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
} }
] ]
} }
+27 -9
View File
@@ -23,7 +23,9 @@
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre", "genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-4", "id": "al-4",
@@ -41,7 +43,9 @@
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre", "genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-5", "id": "al-5",
@@ -59,7 +63,9 @@
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre", "genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-7", "id": "al-7",
@@ -77,7 +83,9 @@
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre", "genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-8", "id": "al-8",
@@ -95,7 +103,9 @@
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre", "genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-9", "id": "al-9",
@@ -113,7 +123,9 @@
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre", "genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-11", "id": "al-11",
@@ -131,7 +143,9 @@
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre", "genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-12", "id": "al-12",
@@ -149,7 +163,9 @@
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre", "genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-13", "id": "al-13",
@@ -167,7 +183,9 @@
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre", "genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021 "year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
} }
] ]
} }
+3
View File
@@ -26,6 +26,9 @@ type Info interface {
DiscNumber() int DiscNumber() int
Year() int Year() int
Compilation() bool
ReleaseType() string
ReplayGainTrackGain() float32 ReplayGainTrackGain() float32
ReplayGainTrackPeak() float32 ReplayGainTrackPeak() float32
ReplayGainAlbumGain() float32 ReplayGainAlbumGain() float32
+9
View File
@@ -52,6 +52,9 @@ func (i *info) TrackNumber() int { return intSep("/", first(find(i.raw, "t
func (i *info) DiscNumber() int { return intSep("/", first(find(i.raw, "discnumber"))) } // eg. 1/2 func (i *info) DiscNumber() int { return intSep("/", first(find(i.raw, "discnumber"))) } // eg. 1/2
func (i *info) Year() int { return intSep("-", first(find(i.raw, "originaldate", "date", "year"))) } // eg. 2023-12-01 func (i *info) Year() int { return intSep("-", first(find(i.raw, "originaldate", "date", "year"))) } // eg. 2023-12-01
func (i *info) Compilation() bool { return bl(first(find(i.raw, "compilation"))) }
func (i *info) ReleaseType() string { return first(find(i.raw, "releasetype")) }
func (i *info) ReplayGainTrackGain() float32 { return dB(first(find(i.raw, "replaygain_track_gain"))) } func (i *info) ReplayGainTrackGain() float32 { return dB(first(find(i.raw, "replaygain_track_gain"))) }
func (i *info) ReplayGainTrackPeak() float32 { return flt(first(find(i.raw, "replaygain_track_peak"))) } func (i *info) ReplayGainTrackPeak() float32 { return flt(first(find(i.raw, "replaygain_track_peak"))) }
func (i *info) ReplayGainAlbumGain() float32 { return dB(first(find(i.raw, "replaygain_album_gain"))) } func (i *info) ReplayGainAlbumGain() float32 { return dB(first(find(i.raw, "replaygain_album_gain"))) }
@@ -93,6 +96,12 @@ func flt(in string) float32 {
f, _ := strconv.ParseFloat(in, 32) f, _ := strconv.ParseFloat(in, 32)
return float32(f) return float32(f)
} }
func bl(in string) bool {
b, _ := strconv.ParseBool(in)
return b
}
func dB(in string) float32 { func dB(in string) float32 {
in = strings.ToLower(in) in = strings.ToLower(in)
in = strings.TrimSuffix(in, " db") in = strings.TrimSuffix(in, " db")