diff --git a/db/db.go b/db/db.go index f78e27e..f4b9ff7 100644 --- a/db/db.go +++ b/db/db.go @@ -339,6 +339,8 @@ type Album struct { TagTitleUDec string `sql:"default: null"` TagBrainzID string `sql:"default: null"` TagYear int `sql:"default: null"` + TagCompilation bool `sql:"default: null"` + TagReleaseType string `sql:"default: null"` Tracks []*Track ChildCount int `sql:"-"` Duration int `sql:"-"` diff --git a/db/migrations.go b/db/migrations.go index c1be333..5c37bc0 100644 --- a/db/migrations.go +++ b/db/migrations.go @@ -79,6 +79,7 @@ func (db *DB) Migrate(ctx MigrationContext) error { construct(ctx, "202504132036", migratePodcast), construct(ctx, "202505211202", migrateTrackAddIndexOnBrainzID), construct(ctx, "202505262025", migrateAlbumAddIndexOnBrainzID), + construct(ctx, "202507062103", migrateAlbumCompilationReleaseType), } return gormigrate. @@ -854,3 +855,9 @@ func migrateAlbumAddIndexOnBrainzID(tx *gorm.DB, _ MigrationContext) error { CREATE INDEX idx_albums_brainz_id ON "albums" (tag_brainz_id); `).Error } + +func migrateAlbumCompilationReleaseType(tx *gorm.DB, _ MigrationContext) error { + return tx.AutoMigrate( + Album{}, + ).Error +} diff --git a/mockfs/mockfs.go b/mockfs/mockfs.go index a109f80..949f917 100644 --- a/mockfs/mockfs.go +++ b/mockfs/mockfs.go @@ -363,6 +363,9 @@ func (i *TagInfo) TrackNumber() int { return 1 } func (i *TagInfo) DiscNumber() int { return 1 } 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) ReplayGainTrackPeak() float32 { return 0 } func (i *TagInfo) ReplayGainAlbumGain() float32 { return 0 } diff --git a/scanner/scanner.go b/scanner/scanner.go index bddf551..ca0b64a 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -424,6 +424,8 @@ func populateAlbum(tx *db.DB, album *db.Album, trags tagcommon.Info, modTime, cr album.TagAlbumArtist = tagcommon.MustAlbumArtist(trags) album.TagBrainzID = trags.AlbumBrainzID() album.TagYear = trags.Year() + album.TagCompilation = trags.Compilation() + album.TagReleaseType = trags.ReleaseType() album.ModifiedAt = modTime if album.CreatedAt.After(createTime) { diff --git a/server/ctrlsubsonic/spec/construct_by_folder.go b/server/ctrlsubsonic/spec/construct_by_folder.go index a720f18..c86fd3e 100644 --- a/server/ctrlsubsonic/spec/construct_by_folder.go +++ b/server/ctrlsubsonic/spec/construct_by_folder.go @@ -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 diff --git a/server/ctrlsubsonic/spec/construct_by_tags.go b/server/ctrlsubsonic/spec/construct_by_tags.go index 97b8332..3cfd1f3 100644 --- a/server/ctrlsubsonic/spec/construct_by_tags.go +++ b/server/ctrlsubsonic/spec/construct_by_tags.go @@ -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() diff --git a/server/ctrlsubsonic/spec/spec.go b/server/ctrlsubsonic/spec/spec.go index aa5bf95..53a1203 100644 --- a/server/ctrlsubsonic/spec/spec.go +++ b/server/ctrlsubsonic/spec/spec.go @@ -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.*`) diff --git a/server/ctrlsubsonic/testdata/test_get_album_list_alpha_artist b/server/ctrlsubsonic/testdata/test_get_album_list_alpha_artist index 7654a86..fd56b12 100644 --- a/server/ctrlsubsonic/testdata/test_get_album_list_alpha_artist +++ b/server/ctrlsubsonic/testdata/test_get_album_list_alpha_artist @@ -21,7 +21,9 @@ "name": "album-0", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-4", @@ -37,7 +39,9 @@ "name": "album-1", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-5", @@ -53,7 +57,9 @@ "name": "album-2", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-7", @@ -69,7 +75,9 @@ "name": "album-0", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-8", @@ -85,7 +93,9 @@ "name": "album-1", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-9", @@ -101,7 +111,9 @@ "name": "album-2", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-11", @@ -117,7 +129,9 @@ "name": "album-0", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-12", @@ -133,7 +147,9 @@ "name": "album-1", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-13", @@ -149,7 +165,9 @@ "name": "album-2", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] } ] } diff --git a/server/ctrlsubsonic/testdata/test_get_album_list_alpha_name b/server/ctrlsubsonic/testdata/test_get_album_list_alpha_name index 438dfaf..ed398d1 100644 --- a/server/ctrlsubsonic/testdata/test_get_album_list_alpha_name +++ b/server/ctrlsubsonic/testdata/test_get_album_list_alpha_name @@ -21,7 +21,9 @@ "name": "album-0", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-7", @@ -37,7 +39,9 @@ "name": "album-0", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-11", @@ -53,7 +57,9 @@ "name": "album-0", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-4", @@ -69,7 +75,9 @@ "name": "album-1", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-8", @@ -85,7 +93,9 @@ "name": "album-1", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-12", @@ -101,7 +111,9 @@ "name": "album-1", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-5", @@ -117,7 +129,9 @@ "name": "album-2", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-9", @@ -133,7 +147,9 @@ "name": "album-2", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-13", @@ -149,7 +165,9 @@ "name": "album-2", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] } ] } diff --git a/server/ctrlsubsonic/testdata/test_get_album_list_newest b/server/ctrlsubsonic/testdata/test_get_album_list_newest index 7654a86..fd56b12 100644 --- a/server/ctrlsubsonic/testdata/test_get_album_list_newest +++ b/server/ctrlsubsonic/testdata/test_get_album_list_newest @@ -21,7 +21,9 @@ "name": "album-0", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-4", @@ -37,7 +39,9 @@ "name": "album-1", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-5", @@ -53,7 +57,9 @@ "name": "album-2", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-7", @@ -69,7 +75,9 @@ "name": "album-0", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-8", @@ -85,7 +93,9 @@ "name": "album-1", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-9", @@ -101,7 +111,9 @@ "name": "album-2", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-11", @@ -117,7 +129,9 @@ "name": "album-0", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-12", @@ -133,7 +147,9 @@ "name": "album-1", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-13", @@ -149,7 +165,9 @@ "name": "album-2", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] } ] } diff --git a/server/ctrlsubsonic/testdata/test_get_album_list_random b/server/ctrlsubsonic/testdata/test_get_album_list_random index e88d80f..0085856 100644 --- a/server/ctrlsubsonic/testdata/test_get_album_list_random +++ b/server/ctrlsubsonic/testdata/test_get_album_list_random @@ -7,6 +7,24 @@ "openSubsonic": true, "albumList": { "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", "created": "2019-11-30T00:00:00Z", @@ -21,7 +39,9 @@ "name": "album-2", "songCount": 3, "duration": 300, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-7", @@ -37,71 +57,9 @@ "name": "album-0", "songCount": 3, "duration": 300, - "playCount": 0 - }, - { - "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 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] }, { "id": "al-12", @@ -117,7 +75,81 @@ "name": "album-1", "songCount": 3, "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", @@ -133,23 +165,9 @@ "name": "album-1", "songCount": 3, "duration": 300, - "playCount": 0 - }, - { - "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 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [] } ] } diff --git a/server/ctrlsubsonic/testdata/test_get_album_list_two_alpha_artist b/server/ctrlsubsonic/testdata/test_get_album_list_two_alpha_artist index e9d52e7..50bdb1f 100644 --- a/server/ctrlsubsonic/testdata/test_get_album_list_two_alpha_artist +++ b/server/ctrlsubsonic/testdata/test_get_album_list_two_alpha_artist @@ -21,7 +21,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-4", @@ -37,7 +39,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-5", @@ -53,7 +57,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-7", @@ -69,7 +75,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-8", @@ -85,7 +93,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-9", @@ -101,7 +111,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-11", @@ -117,7 +129,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-12", @@ -133,7 +147,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-13", @@ -149,7 +165,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] } ] } diff --git a/server/ctrlsubsonic/testdata/test_get_album_list_two_alpha_name b/server/ctrlsubsonic/testdata/test_get_album_list_two_alpha_name index 253ae22..2534a5e 100644 --- a/server/ctrlsubsonic/testdata/test_get_album_list_two_alpha_name +++ b/server/ctrlsubsonic/testdata/test_get_album_list_two_alpha_name @@ -21,7 +21,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-7", @@ -37,7 +39,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-11", @@ -53,7 +57,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-4", @@ -69,7 +75,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-8", @@ -85,7 +93,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-12", @@ -101,7 +111,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-5", @@ -117,7 +129,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-9", @@ -133,7 +147,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-13", @@ -149,7 +165,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] } ] } diff --git a/server/ctrlsubsonic/testdata/test_get_album_list_two_newest b/server/ctrlsubsonic/testdata/test_get_album_list_two_newest index e9d52e7..50bdb1f 100644 --- a/server/ctrlsubsonic/testdata/test_get_album_list_two_newest +++ b/server/ctrlsubsonic/testdata/test_get_album_list_two_newest @@ -21,7 +21,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-4", @@ -37,7 +39,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-5", @@ -53,7 +57,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-7", @@ -69,7 +75,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-8", @@ -85,7 +93,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-9", @@ -101,7 +111,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-11", @@ -117,7 +129,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-12", @@ -133,7 +147,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-13", @@ -149,7 +165,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] } ] } diff --git a/server/ctrlsubsonic/testdata/test_get_album_list_two_random b/server/ctrlsubsonic/testdata/test_get_album_list_two_random index dbcad0e..6dc3748 100644 --- a/server/ctrlsubsonic/testdata/test_get_album_list_two_random +++ b/server/ctrlsubsonic/testdata/test_get_album_list_two_random @@ -21,39 +21,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 - }, - { - "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 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-13", @@ -69,55 +39,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 - }, - { - "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 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-8", @@ -133,7 +57,9 @@ "songCount": 3, "duration": 300, "playCount": 0, - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-9", @@ -149,7 +75,99 @@ "songCount": 3, "duration": 300, "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"] } ] } diff --git a/server/ctrlsubsonic/testdata/test_get_album_with_cover b/server/ctrlsubsonic/testdata/test_get_album_with_cover index ba80c38..2c3eaf6 100644 --- a/server/ctrlsubsonic/testdata/test_get_album_with_cover +++ b/server/ctrlsubsonic/testdata/test_get_album_with_cover @@ -107,7 +107,9 @@ "musicBrainzId": "", "replayGain": null } - ] + ], + "isCompilation": false, + "releaseTypes": ["Album"] } } } diff --git a/server/ctrlsubsonic/testdata/test_get_album_without_cover b/server/ctrlsubsonic/testdata/test_get_album_without_cover index 0fd0572..7aad8d8 100644 --- a/server/ctrlsubsonic/testdata/test_get_album_without_cover +++ b/server/ctrlsubsonic/testdata/test_get_album_without_cover @@ -16,7 +16,9 @@ "name": "", "songCount": 0, "duration": 0, - "playCount": 0 + "playCount": 0, + "isCompilation": false, + "releaseTypes": [""] } } } diff --git a/server/ctrlsubsonic/testdata/test_get_artist_id_one b/server/ctrlsubsonic/testdata/test_get_artist_id_one index 0b02ff1..8fa4d81 100644 --- a/server/ctrlsubsonic/testdata/test_get_artist_id_one +++ b/server/ctrlsubsonic/testdata/test_get_artist_id_one @@ -26,7 +26,9 @@ "playCount": 0, "genre": "Unknown Genre", "genres": [{ "name": "Unknown Genre" }], - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-4", @@ -44,7 +46,9 @@ "playCount": 0, "genre": "Unknown Genre", "genres": [{ "name": "Unknown Genre" }], - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-5", @@ -62,7 +66,9 @@ "playCount": 0, "genre": "Unknown Genre", "genres": [{ "name": "Unknown Genre" }], - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] } ] } diff --git a/server/ctrlsubsonic/testdata/test_get_artist_id_three b/server/ctrlsubsonic/testdata/test_get_artist_id_three index 389ed9c..79cc850 100644 --- a/server/ctrlsubsonic/testdata/test_get_artist_id_three +++ b/server/ctrlsubsonic/testdata/test_get_artist_id_three @@ -26,7 +26,9 @@ "playCount": 0, "genre": "Unknown Genre", "genres": [{ "name": "Unknown Genre" }], - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-12", @@ -44,7 +46,9 @@ "playCount": 0, "genre": "Unknown Genre", "genres": [{ "name": "Unknown Genre" }], - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-13", @@ -62,7 +66,9 @@ "playCount": 0, "genre": "Unknown Genre", "genres": [{ "name": "Unknown Genre" }], - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] } ] } diff --git a/server/ctrlsubsonic/testdata/test_get_artist_id_two b/server/ctrlsubsonic/testdata/test_get_artist_id_two index b85d4d4..66003b1 100644 --- a/server/ctrlsubsonic/testdata/test_get_artist_id_two +++ b/server/ctrlsubsonic/testdata/test_get_artist_id_two @@ -26,7 +26,9 @@ "playCount": 0, "genre": "Unknown Genre", "genres": [{ "name": "Unknown Genre" }], - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-8", @@ -44,7 +46,9 @@ "playCount": 0, "genre": "Unknown Genre", "genres": [{ "name": "Unknown Genre" }], - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-9", @@ -62,7 +66,9 @@ "playCount": 0, "genre": "Unknown Genre", "genres": [{ "name": "Unknown Genre" }], - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] } ] } diff --git a/server/ctrlsubsonic/testdata/test_search_three_q_alb b/server/ctrlsubsonic/testdata/test_search_three_q_alb index 2d346c8..20d6b61 100644 --- a/server/ctrlsubsonic/testdata/test_search_three_q_alb +++ b/server/ctrlsubsonic/testdata/test_search_three_q_alb @@ -23,7 +23,9 @@ "playCount": 0, "genre": "Unknown Genre", "genres": [{ "name": "Unknown Genre" }], - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-4", @@ -41,7 +43,9 @@ "playCount": 0, "genre": "Unknown Genre", "genres": [{ "name": "Unknown Genre" }], - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-5", @@ -59,7 +63,9 @@ "playCount": 0, "genre": "Unknown Genre", "genres": [{ "name": "Unknown Genre" }], - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-7", @@ -77,7 +83,9 @@ "playCount": 0, "genre": "Unknown Genre", "genres": [{ "name": "Unknown Genre" }], - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-8", @@ -95,7 +103,9 @@ "playCount": 0, "genre": "Unknown Genre", "genres": [{ "name": "Unknown Genre" }], - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-9", @@ -113,7 +123,9 @@ "playCount": 0, "genre": "Unknown Genre", "genres": [{ "name": "Unknown Genre" }], - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-11", @@ -131,7 +143,9 @@ "playCount": 0, "genre": "Unknown Genre", "genres": [{ "name": "Unknown Genre" }], - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-12", @@ -149,7 +163,9 @@ "playCount": 0, "genre": "Unknown Genre", "genres": [{ "name": "Unknown Genre" }], - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] }, { "id": "al-13", @@ -167,7 +183,9 @@ "playCount": 0, "genre": "Unknown Genre", "genres": [{ "name": "Unknown Genre" }], - "year": 2021 + "year": 2021, + "isCompilation": false, + "releaseTypes": ["Album"] } ] } diff --git a/tags/tagcommon/tagcommmon.go b/tags/tagcommon/tagcommmon.go index 10da58d..609f5e4 100644 --- a/tags/tagcommon/tagcommmon.go +++ b/tags/tagcommon/tagcommmon.go @@ -26,6 +26,9 @@ type Info interface { DiscNumber() int Year() int + Compilation() bool + ReleaseType() string + ReplayGainTrackGain() float32 ReplayGainTrackPeak() float32 ReplayGainAlbumGain() float32 diff --git a/tags/taglib/taglib.go b/tags/taglib/taglib.go index ba2ab82..03ea647 100644 --- a/tags/taglib/taglib.go +++ b/tags/taglib/taglib.go @@ -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) 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) 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"))) } @@ -93,6 +96,12 @@ func flt(in string) float32 { f, _ := strconv.ParseFloat(in, 32) return float32(f) } + +func bl(in string) bool { + b, _ := strconv.ParseBool(in) + return b +} + func dB(in string) float32 { in = strings.ToLower(in) in = strings.TrimSuffix(in, " db")