mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-24 22:35:39 -04:00
Whole album matching and fingerprinting (#592)
* Cache result of GetAllArtists
* Fixed: Manual import not respecting album import notifications
* Fixed: partial album imports stay in queue, prompting manual import
* Fixed: Allow release if tracks are missing
* Fixed: Be tolerant of missing/extra "The" at start of artist name
* Improve manual import UI
* Omit video tracks from DB entirely
* Revert "faster test packaging in build.sh"
This reverts commit 2723e2a7b8.
-u and -T are not supported on macOS
* Fix tests on linux and macOS
* Actually lint on linux
On linux yarn runs scripts with sh not bash so ** doesn't recursively glob
* Match whole albums
* Option to disable fingerprinting
* Rip out MediaInfo
* Don't split up things that have the same album selected in manual import
* Try to speed up IndentificationService
* More speedups
* Some fixes and increase power of recording id
* Fix NRE when no tags
* Fix NRE when some (but not all) files in a directory have missing tags
* Bump taglib, tidy up tag parsing
* Add a health check
* Remove media info setting
* Tags -> audioTags
* Add some tests where tags are null
* Rename history events
* Add missing method to interface
* Reinstate MediaInfo tags and update info with artist scan
Also adds migration to remove old format media info
* This file no longer exists
* Don't penalise year if missing from tags
* Formatting improvements
* Use correct system newline
* Switch to the netstandard2.0 library to support net 461
* TagLib.File is IDisposable so should be in a using
* Improve filename matching and add tests
* Neater logging of parsed tags
* Fix disk scan tests for new media info update
* Fix quality detection source
* Fix Inexact Artist/Album match
* Add button to clear track mapping
* Fix warning
* Pacify eslint
* Use \ not /
* Fix UI updates
* Fix media covers
Prevent localizing URL propaging back to the metadata object
* Reduce database overhead broadcasting UI updates
* Relax timings a bit to make test pass
* Remove irrelevant tests
* Test framework for identification service
* Fix PreferMissingToBadMatch test case
* Make fingerprinting more robust
* More logging
* Penalize unknown media format and country
* Prefer USA to UK
* Allow Data CD
* Fix exception if fingerprinting fails for all files
* Fix tests
* Fix NRE
* Allow apostrophes and remove accents in filename aggregation
* Address codacy issues
* Cope with old versions of fpcalc and suggest upgrade
* fpcalc health check passes if fingerprinting disabled
* Get the Artist meta with the artist
* Fix the mapper so that lazy loaded lists will be populated on Join
And therefore we can join TrackFiles on Tracks by default and avoid an
extra query
* Rename subtitle -> lyric
* Tidy up MediaInfoFormatter
This commit is contained in:
@@ -25,16 +25,16 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
[TestFixture]
|
||||
public class ImportApprovedTracksFixture : CoreTest<ImportApprovedTracks>
|
||||
{
|
||||
private List<ImportDecision> _rejectedDecisions;
|
||||
private List<ImportDecision> _approvedDecisions;
|
||||
private List<ImportDecision<LocalTrack>> _rejectedDecisions;
|
||||
private List<ImportDecision<LocalTrack>> _approvedDecisions;
|
||||
|
||||
private DownloadClientItem _downloadClientItem;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_rejectedDecisions = new List<ImportDecision>();
|
||||
_approvedDecisions = new List<ImportDecision>();
|
||||
_rejectedDecisions = new List<ImportDecision<LocalTrack>>();
|
||||
_approvedDecisions = new List<ImportDecision<LocalTrack>>();
|
||||
|
||||
var artist = Builder<Artist>.CreateNew()
|
||||
.With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
@@ -52,20 +52,21 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
|
||||
var release = Builder<AlbumRelease>.CreateNew()
|
||||
.With(e => e.AlbumId = album.Id)
|
||||
.With(e => e.Monitored = true)
|
||||
.Build();
|
||||
|
||||
album.AlbumReleases = new List<AlbumRelease> { release };
|
||||
|
||||
var tracks = Builder<Track>.CreateListOfSize(5)
|
||||
.Build();
|
||||
|
||||
|
||||
|
||||
_rejectedDecisions.Add(new ImportDecision(new LocalTrack(), new Rejection("Rejected!")));
|
||||
_rejectedDecisions.Add(new ImportDecision(new LocalTrack(), new Rejection("Rejected!")));
|
||||
_rejectedDecisions.Add(new ImportDecision(new LocalTrack(), new Rejection("Rejected!")));
|
||||
_rejectedDecisions.Add(new ImportDecision<LocalTrack>(new LocalTrack(), new Rejection("Rejected!")));
|
||||
_rejectedDecisions.Add(new ImportDecision<LocalTrack>(new LocalTrack(), new Rejection("Rejected!")));
|
||||
_rejectedDecisions.Add(new ImportDecision<LocalTrack>(new LocalTrack(), new Rejection("Rejected!")));
|
||||
|
||||
foreach (var track in tracks)
|
||||
{
|
||||
_approvedDecisions.Add(new ImportDecision
|
||||
_approvedDecisions.Add(new ImportDecision<LocalTrack>
|
||||
(
|
||||
new LocalTrack
|
||||
{
|
||||
@@ -75,7 +76,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
Tracks = new List<Track> { track },
|
||||
Path = Path.Combine(artist.Path, "Alien Ant Farm - 01 - Pilot.mp3"),
|
||||
Quality = new QualityModel(Quality.MP3_256),
|
||||
ParsedTrackInfo = new ParsedTrackInfo
|
||||
FileTrackInfo = new ParsedTrackInfo
|
||||
{
|
||||
ReleaseGroup = "DRONE"
|
||||
}
|
||||
@@ -91,6 +92,11 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Setup(s => s.GetFilesWithRelativePath(It.IsAny<int>(), It.IsAny<string>()))
|
||||
.Returns(new List<TrackFile>());
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Setup(s => s.GetFilesByAlbum(It.IsAny<int>()))
|
||||
.Returns(new List<TrackFile>());
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -110,7 +116,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
[Test]
|
||||
public void should_only_import_approved()
|
||||
{
|
||||
var all = new List<ImportDecision>();
|
||||
var all = new List<ImportDecision<LocalTrack>>();
|
||||
all.AddRange(_rejectedDecisions);
|
||||
all.AddRange(_approvedDecisions);
|
||||
|
||||
@@ -123,9 +129,9 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
[Test]
|
||||
public void should_only_import_each_track_once()
|
||||
{
|
||||
var all = new List<ImportDecision>();
|
||||
var all = new List<ImportDecision<LocalTrack>>();
|
||||
all.AddRange(_approvedDecisions);
|
||||
all.Add(new ImportDecision(_approvedDecisions.First().LocalTrack));
|
||||
all.Add(new ImportDecision<LocalTrack>(_approvedDecisions.First().Item));
|
||||
|
||||
var result = Subject.Import(all, false);
|
||||
|
||||
@@ -135,17 +141,17 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
[Test]
|
||||
public void should_move_new_downloads()
|
||||
{
|
||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true);
|
||||
Subject.Import(new List<ImportDecision<LocalTrack>> { _approvedDecisions.First() }, true);
|
||||
|
||||
Mocker.GetMock<IUpgradeMediaFiles>()
|
||||
.Verify(v => v.UpgradeTrackFile(It.IsAny<TrackFile>(), _approvedDecisions.First().LocalTrack, false),
|
||||
.Verify(v => v.UpgradeTrackFile(It.IsAny<TrackFile>(), _approvedDecisions.First().Item, false),
|
||||
Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_publish_TrackImportedEvent_for_new_downloads()
|
||||
{
|
||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true);
|
||||
Subject.Import(new List<ImportDecision<LocalTrack>> { _approvedDecisions.First() }, true);
|
||||
|
||||
Mocker.GetMock<IEventAggregator>()
|
||||
.Verify(v => v.PublishEvent(It.IsAny<TrackImportedEvent>()), Times.Once());
|
||||
@@ -154,10 +160,10 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
[Test]
|
||||
public void should_not_move_existing_files()
|
||||
{
|
||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, false);
|
||||
Subject.Import(new List<ImportDecision<LocalTrack>> { _approvedDecisions.First() }, false);
|
||||
|
||||
Mocker.GetMock<IUpgradeMediaFiles>()
|
||||
.Verify(v => v.UpgradeTrackFile(It.IsAny<TrackFile>(), _approvedDecisions.First().LocalTrack, false),
|
||||
.Verify(v => v.UpgradeTrackFile(It.IsAny<TrackFile>(), _approvedDecisions.First().Item, false),
|
||||
Times.Never());
|
||||
}
|
||||
|
||||
@@ -165,21 +171,21 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
public void should_import_larger_files_first()
|
||||
{
|
||||
var fileDecision = _approvedDecisions.First();
|
||||
fileDecision.LocalTrack.Size = 1.Gigabytes();
|
||||
fileDecision.Item.Size = 1.Gigabytes();
|
||||
|
||||
var sampleDecision = new ImportDecision
|
||||
var sampleDecision = new ImportDecision<LocalTrack>
|
||||
(new LocalTrack
|
||||
{
|
||||
Artist = fileDecision.LocalTrack.Artist,
|
||||
Album = fileDecision.LocalTrack.Album,
|
||||
Tracks = new List<Track> { fileDecision.LocalTrack.Tracks.First() },
|
||||
Artist = fileDecision.Item.Artist,
|
||||
Album = fileDecision.Item.Album,
|
||||
Tracks = new List<Track> { fileDecision.Item.Tracks.First() },
|
||||
Path = @"C:\Test\Music\Alien Ant Farm\Alien Ant Farm - 01 - Pilot.mp3".AsOsAgnostic(),
|
||||
Quality = new QualityModel(Quality.MP3_256),
|
||||
Size = 80.Megabytes()
|
||||
});
|
||||
|
||||
|
||||
var all = new List<ImportDecision>();
|
||||
var all = new List<ImportDecision<LocalTrack>>();
|
||||
all.Add(fileDecision);
|
||||
all.Add(sampleDecision);
|
||||
|
||||
@@ -187,25 +193,25 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
|
||||
results.Should().HaveCount(all.Count);
|
||||
results.Should().ContainSingle(d => d.Result == ImportResultType.Imported);
|
||||
results.Should().ContainSingle(d => d.Result == ImportResultType.Imported && d.ImportDecision.LocalTrack.Size == fileDecision.LocalTrack.Size);
|
||||
results.Should().ContainSingle(d => d.Result == ImportResultType.Imported && d.ImportDecision.Item.Size == fileDecision.Item.Size);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_copy_when_cannot_move_files_downloads()
|
||||
{
|
||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "Alien.Ant.Farm-Truant", CanMoveFiles = false });
|
||||
Subject.Import(new List<ImportDecision<LocalTrack>> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "Alien.Ant.Farm-Truant", CanMoveFiles = false });
|
||||
|
||||
Mocker.GetMock<IUpgradeMediaFiles>()
|
||||
.Verify(v => v.UpgradeTrackFile(It.IsAny<TrackFile>(), _approvedDecisions.First().LocalTrack, true), Times.Once());
|
||||
.Verify(v => v.UpgradeTrackFile(It.IsAny<TrackFile>(), _approvedDecisions.First().Item, true), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_use_override_importmode()
|
||||
{
|
||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "Alien.Ant.Farm-Truant", CanMoveFiles = false }, ImportMode.Move);
|
||||
Subject.Import(new List<ImportDecision<LocalTrack>> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "Alien.Ant.Farm-Truant", CanMoveFiles = false }, ImportMode.Move);
|
||||
|
||||
Mocker.GetMock<IUpgradeMediaFiles>()
|
||||
.Verify(v => v.UpgradeTrackFile(It.IsAny<TrackFile>(), _approvedDecisions.First().LocalTrack, false), Times.Once());
|
||||
.Verify(v => v.UpgradeTrackFile(It.IsAny<TrackFile>(), _approvedDecisions.First().Item, false), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -215,7 +221,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
.Setup(s => s.GetFilesWithRelativePath(It.IsAny<int>(), It.IsAny<string>()))
|
||||
.Returns(Builder<TrackFile>.CreateListOfSize(1).BuildList());
|
||||
|
||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, false);
|
||||
Subject.Import(new List<ImportDecision<LocalTrack>> { _approvedDecisions.First() }, false);
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Verify(v => v.Delete(It.IsAny<TrackFile>(), DeleteMediaFileReason.ManualOverride), Times.Once());
|
||||
|
||||
Reference in New Issue
Block a user