diff --git a/consts/consts.go b/consts/consts.go index 9ed5c95bd..20825e751 100644 --- a/consts/consts.go +++ b/consts/consts.go @@ -157,7 +157,7 @@ const ( const ( //DefaultAlbumPID = "album_legacy" - DefaultAlbumPID = "musicbrainz_albumid|albumartistid,album,albumversion,releasedate" + DefaultAlbumPID = "musicbrainz_albumid|albumartistid,album,albumversion" DefaultTrackPID = "musicbrainz_trackid|albumid,discnumber,tracknumber,title" ) diff --git a/db/migrations/20261115120000_regroup_mp4_asf_albums.go b/db/migrations/20261115120000_regroup_mp4_asf_albums.go deleted file mode 100644 index 5fcf4649a..000000000 --- a/db/migrations/20261115120000_regroup_mp4_asf_albums.go +++ /dev/null @@ -1,43 +0,0 @@ -package migrations - -import ( - "context" - "database/sql" - - "github.com/navidrome/navidrome/conf" - "github.com/pressly/goose/v3" -) - -func init() { - goose.AddMigrationContext(upRegroupMp4AsfAlbums, downRegroupMp4AsfAlbums) -} - -// The raw ©day (MP4) and WM/Year (ASF) tags were releasedate aliases, so those files got a release date -// that MP3/FLAC files with the same DATE did not, and mixed-format albums split (#6467). With the aliases -// removed, album IDs that hash the release date change for these files. Clearing scanned_pid_album makes -// the scanner treat the library as having a changed PID: it rescans it in full and moves the annotations. -func upRegroupMp4AsfAlbums(ctx context.Context, tx *sql.Tx) error { - // A custom releasedate mapping replaces the default aliases, so the change does not apply - if tc, ok := conf.Server().Tags["releasedate"]; ok && (tc.Ignore || len(tc.Aliases) > 0) { - return nil - } - // album_legacy also appends the release date to the album ID - res, err := tx.ExecContext(ctx, ` -update library set scanned_pid_album = '' -where (coalesce(nullif(pid_album, ''), ?1) like '%releasedate%' or lower(coalesce(nullif(pid_album, ''), ?1)) = 'album_legacy') - and id in ( - select distinct library_id from media_file - where suffix in ('m4a', 'm4b', 'm4p', 'm4r', 'm4v', 'mp4', 'wma', 'asf') -)`, conf.Server().PID.Album) - if err != nil { - return err - } - if n, _ := res.RowsAffected(); n > 0 { - notice(ctx, tx, "Libraries with M4A or WMA files will be rescanned in full, to fix albums split by file format") - } - return nil -} - -func downRegroupMp4AsfAlbums(context.Context, *sql.Tx) error { - return nil -} diff --git a/db/migrations/20261117194126_keep_old_default_album_pid.sql b/db/migrations/20261117194126_keep_old_default_album_pid.sql new file mode 100644 index 000000000..72d5b1d11 --- /dev/null +++ b/db/migrations/20261117194126_keep_old_default_album_pid.sql @@ -0,0 +1,11 @@ +-- +goose Up +-- +goose StatementBegin +-- The default album PID no longer has releasedate. Libraries scanned with the old default keep it, +-- so their album IDs do not change. +update library set pid_album = 'musicbrainz_albumid|albumartistid,album,albumversion,releasedate' +where pid_album = '' + and lower(scanned_pid_album) = 'musicbrainz_albumid|albumartistid,album,albumversion,releasedate'; +-- +goose StatementEnd + +-- +goose Down +SELECT 1; diff --git a/model/metadata/map_mediafile_test.go b/model/metadata/map_mediafile_test.go index 5ab77db2c..0bd30b749 100644 --- a/model/metadata/map_mediafile_test.go +++ b/model/metadata/map_mediafile_test.go @@ -47,8 +47,7 @@ var _ = Describe("ToMediaFile", func() { Expect(byFolder.PID).ToNot(Equal(byTags.PID)) }) - // TagLib reports the year of M4A and WMA files as DATE, like MP3 and FLAC, and also - // sends the raw atom/attribute. The raw one must not become a release date (#6467). + // TagLib sends the M4A/WMA year as DATE and as the raw atom, which is a release date alias DescribeTable("gives the same album ID to tracks of one album in different formats", func(formatYearTag string) { albumTags := model.RawTags{"ALBUM": {"Hello"}, "ALBUMARTIST": {"Adele"}, "DATE": {"2022"}} @@ -59,7 +58,7 @@ var _ = Describe("ToMediaFile", func() { other := toMediaFile(otherTags) Expect(other.AlbumID).To(Equal(mp3.AlbumID)) - Expect(other.Year).To(Equal(2022)) + Expect(other.ReleaseDate).To(Equal("2022")) }, Entry("M4A", "©day"), Entry("WMA", "WM/Year"), diff --git a/resources/mappings.yaml b/resources/mappings.yaml index 15315a6c5..511f51135 100644 --- a/resources/mappings.yaml +++ b/resources/mappings.yaml @@ -124,7 +124,7 @@ main: aliases: [ tdrc, date, recordingdate, icrd, record date ] type: date releasedate: - aliases: [ tdrl, releasedate, year ] + aliases: [ tdrl, releasedate, ©day, wm/year, year ] type: date catalognumber: aliases: [ txxx:catalognumber, catalognumber, ----:com.apple.itunes:catalognumber, wm/catalogno ] diff --git a/scanner/README.md b/scanner/README.md index 6245a0d34..58dce51d7 100644 --- a/scanner/README.md +++ b/scanner/README.md @@ -457,7 +457,7 @@ The scanner's behavior can be customized through several configuration settings | Setting | Description | Default | |-------------|---------------------------------------------------------------------|---------------------------------------------------------------------| | `PID.Track` | Format for track persistent IDs (critical for tracking moved files) | "musicbrainz_trackid\|albumid,discnumber,tracknumber,title" | -| `PID.Album` | Format for album persistent IDs (affects album grouping) | "musicbrainz_albumid\|albumartistid,album,albumversion,releasedate" | +| `PID.Album` | Format for album persistent IDs (affects album grouping) | "musicbrainz_albumid\|albumartistid,album,albumversion" | These options can be set in the Navidrome configuration file (e.g., `navidrome.toml`) or via environment variables with the `ND_` prefix (e.g., `ND_SCANNER_ENABLED=false`). For environment variables, dots in option names are replaced with underscores. diff --git a/scanner/scanner_test.go b/scanner/scanner_test.go index 669c65d4e..b5869151f 100644 --- a/scanner/scanner_test.go +++ b/scanner/scanner_test.go @@ -511,7 +511,18 @@ var _ = Describe("Scanner", Ordered, func() { }) }) - It("should import as two distinct albums", func() { + It("should import as one album with the default album PID", func() { + Expect(runScanner(ctx, true)).To(Succeed()) + + albums, err := ds.Album().GetAll(ctx) + Expect(err).ToNot(HaveOccurred()) + Expect(albums).To(HaveLen(1)) + }) + + It("should import as two distinct albums when the album PID has releasedate", func() { + conf.Update(func(c *conf.Options) { + c.PID.Album = "musicbrainz_albumid|albumartistid,album,albumversion,releasedate" + }) Expect(runScanner(ctx, true)).To(Succeed()) albums, err := ds.Album().GetAll(ctx, model.QueryOptions{Sort: "release_date"}) diff --git a/ui/src/config.js b/ui/src/config.js index 62b3cb822..4ad426444 100644 --- a/ui/src/config.js +++ b/ui/src/config.js @@ -32,7 +32,7 @@ const defaultConfig = { listenBrainzEnabled: true, enableExternalServices: true, enableCoverAnimation: true, - pidAlbum: 'musicbrainz_albumid|albumartistid,album,albumversion,releasedate', // See consts.DefaultAlbumPID + pidAlbum: 'musicbrainz_albumid|albumartistid,album,albumversion', // See consts.DefaultAlbumPID pidTrack: 'musicbrainz_trackid|albumid,discnumber,tracknumber,title', // See consts.DefaultTrackPID enableNowPlaying: true, playbackReportIntervalMs: 60000,