diff --git a/app/models/track.rb b/app/models/track.rb index 788ccd74..b5bf99c0 100644 --- a/app/models/track.rb +++ b/app/models/track.rb @@ -34,7 +34,7 @@ def metadata artist_name: artist.name } - data[:release_date] = album.released_on if album.released_on + data[:release_year] = album.released_on.year if album.released_on data end diff --git a/app/models/transcode_command.rb b/app/models/transcode_command.rb index 3c42d8c6..e83f85d3 100644 --- a/app/models/transcode_command.rb +++ b/app/models/transcode_command.rb @@ -6,7 +6,7 @@ class TranscodeCommand track_number: 'TRCK', album_title: 'TALB', artist_name: 'TPE1', - release_date: 'DATE' + release_year: 'TORY' }.freeze METADATA_KEYS_VS_FLAC_TAGS = { @@ -14,7 +14,7 @@ class TranscodeCommand track_number: 'TRACKNUMBER', album_title: 'ALBUM', artist_name: 'ARTIST', - release_date: 'DATE' + release_year: 'DATE' }.freeze def initialize(input, output, format, metadata = {}, image = nil) diff --git a/test/jobs/transcode_job_test.rb b/test/jobs/transcode_job_test.rb index d8f8d1cf..88b14e32 100644 --- a/test/jobs/transcode_job_test.rb +++ b/test/jobs/transcode_job_test.rb @@ -53,7 +53,7 @@ class TranscodeJobTest < ActiveJob::TestCase end test 'it adds metadata to the generated MP3 file' do - album = create(:album, released_on: Time.zone.today) + album = create(:album, released_on: Date.parse('2024-10-03')) track = create(:track, album:) TranscodeJob.perform_now(track) @@ -66,12 +66,12 @@ class TranscodeJobTest < ActiveJob::TestCase assert_equal '01', metadata['format']['tags']['track'] assert_equal album.title, metadata['format']['tags']['album'] assert_equal album.artist.name, metadata['format']['tags']['artist'] - assert_equal album.released_on.to_s, metadata['format']['tags']['date'] + assert_equal '2024', metadata['format']['tags']['TORY'] end end test 'it adds metadata to the generated flac file' do - album = create(:album, released_on: Time.zone.today) + album = create(:album, released_on: Date.parse('2024-10-03')) track = create(:track, album:) TranscodeJob.perform_now(track, format: :flac) @@ -84,7 +84,7 @@ class TranscodeJobTest < ActiveJob::TestCase assert_equal '01', metadata['format']['tags']['track'] assert_equal album.title, metadata['format']['tags']['ALBUM'] assert_equal album.artist.name, metadata['format']['tags']['ARTIST'] - assert_equal album.released_on.to_s, metadata['format']['tags']['DATE'] + assert_equal '2024', metadata['format']['tags']['DATE'] end end end diff --git a/test/models/track_test.rb b/test/models/track_test.rb index b9342dd0..cda570b0 100644 --- a/test/models/track_test.rb +++ b/test/models/track_test.rb @@ -112,7 +112,7 @@ class TrackTest < ActiveSupport::TestCase metadata = track.metadata - assert_equal track.album.released_on, metadata[:release_date] + assert_equal track.album.released_on.year, metadata[:release_year] end test '#number' do diff --git a/test/models/transcode_command_test.rb b/test/models/transcode_command_test.rb index 11508446..7235e4b4 100644 --- a/test/models/transcode_command_test.rb +++ b/test/models/transcode_command_test.rb @@ -48,7 +48,7 @@ class TranscodeCommandTest < ActiveSupport::TestCase track_number: 'track-number', album_title: 'album-title', artist_name: 'artist-name', - release_date: 'release-date' + release_year: 'release-year' } command_string = TranscodeCommand.new(@input, @output, :mp3v0, metadata).generate assert_contains_pair(command_string, ['-write_id3v2', '1']) @@ -57,7 +57,7 @@ class TranscodeCommandTest < ActiveSupport::TestCase assert_contains_pair(command_string, ['-metadata', 'TRCK="track-number"']) assert_contains_pair(command_string, ['-metadata', 'TALB="album-title"']) assert_contains_pair(command_string, ['-metadata', 'TPE1="artist-name"']) - assert_contains_pair(command_string, ['-metadata', 'DATE="release-date"']) + assert_contains_pair(command_string, ['-metadata', 'TORY="release-year"']) end test 'adds metadata tags for FLAC format' do @@ -66,14 +66,14 @@ class TranscodeCommandTest < ActiveSupport::TestCase track_number: 'track-number', album_title: 'album-title', artist_name: 'artist-name', - release_date: 'release-date' + release_year: 'release-year' } command_string = TranscodeCommand.new(@input, @output, :flac, metadata).generate assert_contains_pair(command_string, ['-metadata', 'TITLE="track-title"']) assert_contains_pair(command_string, ['-metadata', 'TRACKNUMBER="track-number"']) assert_contains_pair(command_string, ['-metadata', 'ALBUM="album-title"']) assert_contains_pair(command_string, ['-metadata', 'ARTIST="artist-name"']) - assert_contains_pair(command_string, ['-metadata', 'DATE="release-date"']) + assert_contains_pair(command_string, ['-metadata', 'DATE="release-year"']) end test 'transcodes audio to mp3 using libmp3lame codec highest audio quality' do