mirror of
https://github.com/lidarr/Lidarr
synced 2025-01-03 05:25:10 +00:00
New: Preserve replaygain tags
This commit is contained in:
parent
0121095b3e
commit
2a8c67badc
2 changed files with 49 additions and 1 deletions
|
@ -326,7 +326,7 @@ public void should_remove_date_from_tags_when_not_in_metadata(string filename, s
|
|||
[Test]
|
||||
public void should_ignore_non_parsable_id3v23_date()
|
||||
{
|
||||
GivenFileCopy("nin.mp2");
|
||||
GivenFileCopy("nin.mp3");
|
||||
|
||||
using (var file = TagLib.File.Create(_copiedFile))
|
||||
{
|
||||
|
@ -440,5 +440,37 @@ public void write_tags_should_not_update_tags_if_already_updated(string filename
|
|||
Mocker.GetMock<IEventAggregator>()
|
||||
.Verify(v => v.PublishEvent(It.IsAny<TrackFileRetaggedEvent>()), Times.Once());
|
||||
}
|
||||
|
||||
[TestCase("nin.mp3")]
|
||||
public void should_ignore_replaygain_tags_during_scrub(string filename)
|
||||
{
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.Setup(x => x.ScrubAudioTags)
|
||||
.Returns(true);
|
||||
|
||||
GivenFileCopy(filename);
|
||||
|
||||
using (var preFile = TagLib.File.Create(_copiedFile))
|
||||
{
|
||||
preFile.Tag.ReplayGainAlbumPeak = 1;
|
||||
preFile.Tag.ReplayGainAlbumGain = 500;
|
||||
preFile.Tag.ReplayGainTrackPeak = 2;
|
||||
preFile.Tag.ReplayGainTrackGain = 250;
|
||||
preFile.Save();
|
||||
}
|
||||
|
||||
var file = GivenPopulatedTrackfile(0);
|
||||
|
||||
file.Path = _copiedFile;
|
||||
Subject.WriteTags(file, false, true);
|
||||
|
||||
using (var postFile = TagLib.File.Create(_copiedFile))
|
||||
{
|
||||
postFile.Tag.ReplayGainAlbumGain.Should().Be(500);
|
||||
postFile.Tag.ReplayGainAlbumPeak.Should().Be(1);
|
||||
postFile.Tag.ReplayGainTrackGain.Should().Be(250);
|
||||
postFile.Tag.ReplayGainTrackPeak.Should().Be(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,8 +151,24 @@ public void RemoveAllTags(string path)
|
|||
try
|
||||
{
|
||||
file = TagLib.File.Create(path);
|
||||
|
||||
var replayGainAlbumGain = file.Tag.ReplayGainAlbumGain;
|
||||
var replayGainAlbumPeak = file.Tag.ReplayGainAlbumPeak;
|
||||
var replayGainTrackGain = file.Tag.ReplayGainTrackGain;
|
||||
var replayGainTrackPeak = file.Tag.ReplayGainTrackPeak;
|
||||
|
||||
file.RemoveTags(TagLib.TagTypes.AllTags);
|
||||
file.Save();
|
||||
file.Dispose();
|
||||
|
||||
file = TagLib.File.Create(path);
|
||||
|
||||
file.Tag.ReplayGainAlbumGain = replayGainAlbumGain;
|
||||
file.Tag.ReplayGainAlbumPeak = replayGainAlbumPeak;
|
||||
file.Tag.ReplayGainTrackGain = replayGainTrackGain;
|
||||
file.Tag.ReplayGainTrackPeak = replayGainTrackPeak;
|
||||
|
||||
file.Save();
|
||||
}
|
||||
catch (CorruptFileException ex)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue