Fixed: Tag writing when release country is missing (#700)

pull/6/head
ta264 6 years ago committed by GitHub
parent 7fd0089884
commit 038deb0e8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -279,5 +279,51 @@ namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture
tag.Quality.Should().NotBeNull();
tag.MediaInfo.Should().NotBeNull();
}
private TrackFile GivenPopulatedTrackfile()
{
var meta = Builder<ArtistMetadata>.CreateNew().Build();
var artist = Builder<Artist>.CreateNew()
.With(x => x.Metadata = meta)
.Build();
var album = Builder<Album>.CreateNew()
.With(x => x.Artist = artist)
.Build();
var media = Builder<Medium>.CreateListOfSize(2).Build() as List<Medium>;
var release = Builder<AlbumRelease>.CreateNew()
.With(x => x.Album = album)
.With(x => x.Media = media)
.With(x => x.Country = new List<string>())
.With(x => x.Label = new List<string>())
.Build();
var tracks = Builder<Track>.CreateListOfSize(10)
.All()
.With(x => x.AlbumRelease = release)
.With(x => x.ArtistMetadata = meta)
.TheFirst(5)
.With(x => x.MediumNumber = 1)
.TheNext(5)
.With(x => x.MediumNumber = 2)
.Build() as List<Track>;
release.Tracks = tracks;
var file = Builder<TrackFile>.CreateNew()
.With(x => x.Tracks = new List<Track> { tracks[0] })
.Build();
return file;
}
[Test]
public void get_metadata_should_not_fail_with_missing_country()
{
var file = GivenPopulatedTrackfile();
var tag = Subject.GetTrackMetadata(file);
tag.MusicBrainzReleaseCountry.Should().BeNull();
}
}
}

@ -67,7 +67,7 @@ namespace NzbDrone.Core.MediaFiles
return new AudioTag(path);
}
private AudioTag GetTrackMetadata(TrackFile trackfile)
public AudioTag GetTrackMetadata(TrackFile trackfile)
{
var track = trackfile.Tracks.Value[0];
var release = track.AlbumRelease.Value;
@ -90,7 +90,7 @@ namespace NzbDrone.Core.MediaFiles
OriginalReleaseDate = album.ReleaseDate,
OriginalYear = (uint)album.ReleaseDate?.Year,
Publisher = release.Label.FirstOrDefault(),
MusicBrainzReleaseCountry = IsoCountries.Find(release.Country.FirstOrDefault()).TwoLetterCode,
MusicBrainzReleaseCountry = IsoCountries.Find(release.Country.FirstOrDefault())?.TwoLetterCode,
MusicBrainzReleaseStatus = release.Status.ToLower(),
MusicBrainzReleaseType = album.AlbumType.ToLower(),
MusicBrainzReleaseId = release.ForeignReleaseId,

Loading…
Cancel
Save