mirror of https://github.com/lidarr/Lidarr
Download Handling, Clean Up Drone Folder Leftovers
This commit is contained in:
parent
9f689c0233
commit
405e7f981d
|
@ -1,4 +1,4 @@
|
|||
using FluentValidation;
|
||||
using FluentValidation;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Validation.Paths;
|
||||
|
||||
|
@ -6,19 +6,10 @@ namespace NzbDrone.Api.Config
|
|||
{
|
||||
public class DownloadClientConfigModule : NzbDroneConfigModule<DownloadClientConfigResource>
|
||||
{
|
||||
public DownloadClientConfigModule(IConfigService configService,
|
||||
RootFolderValidator rootFolderValidator,
|
||||
PathExistsValidator pathExistsValidator,
|
||||
MappedNetworkDriveValidator mappedNetworkDriveValidator)
|
||||
public DownloadClientConfigModule(IConfigService configService)
|
||||
: base(configService)
|
||||
{
|
||||
SharedValidator.RuleFor(c => c.DownloadedAlbumsFolder)
|
||||
.Cascade(CascadeMode.StopOnFirstFailure)
|
||||
.IsValidPath()
|
||||
.SetValidator(rootFolderValidator)
|
||||
.SetValidator(mappedNetworkDriveValidator)
|
||||
.SetValidator(pathExistsValidator)
|
||||
.When(c => !string.IsNullOrWhiteSpace(c.DownloadedAlbumsFolder));
|
||||
|
||||
}
|
||||
|
||||
protected override DownloadClientConfigResource ToResource(IConfigService model)
|
||||
|
@ -26,4 +17,4 @@ namespace NzbDrone.Api.Config
|
|||
return DownloadClientConfigResourceMapper.ToResource(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,7 @@ namespace NzbDrone.Api.Config
|
|||
{
|
||||
public class DownloadClientConfigResource : RestResource
|
||||
{
|
||||
public string DownloadedAlbumsFolder { get; set; }
|
||||
public string DownloadClientWorkingFolders { get; set; }
|
||||
public int DownloadedAlbumsScanInterval { get; set; }
|
||||
|
||||
public bool EnableCompletedDownloadHandling { get; set; }
|
||||
public bool RemoveCompletedDownloads { get; set; }
|
||||
|
@ -22,9 +20,7 @@ namespace NzbDrone.Api.Config
|
|||
{
|
||||
return new DownloadClientConfigResource
|
||||
{
|
||||
DownloadedAlbumsFolder = model.DownloadedAlbumsFolder,
|
||||
DownloadClientWorkingFolders = model.DownloadClientWorkingFolders,
|
||||
DownloadedAlbumsScanInterval = model.DownloadedAlbumsScanInterval,
|
||||
|
||||
EnableCompletedDownloadHandling = model.EnableCompletedDownloadHandling,
|
||||
RemoveCompletedDownloads = model.RemoveCompletedDownloads,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
@ -101,34 +101,5 @@ namespace NzbDrone.Core.Test.DiskSpace
|
|||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(v => v.GetAvailableSpace(It.IsAny<string>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_check_diskspace_for_dronefactory_folder()
|
||||
{
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.SetupGet(v => v.DownloadedAlbumsFolder)
|
||||
.Returns(_droneFactoryFolder);
|
||||
|
||||
GivenExistingFolder(_droneFactoryFolder);
|
||||
|
||||
var freeSpace = Subject.GetFreeSpace();
|
||||
|
||||
freeSpace.Should().NotBeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_check_diskspace_for_missing_dronefactory_folder()
|
||||
{
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.SetupGet(v => v.DownloadedAlbumsFolder)
|
||||
.Returns(_droneFactoryFolder);
|
||||
|
||||
var freeSpace = Subject.GetFreeSpace();
|
||||
|
||||
freeSpace.Should().BeEmpty();
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(v => v.GetAvailableSpace(It.IsAny<string>()), Times.Never());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,12 +35,12 @@ namespace NzbDrone.Core.Test.Download
|
|||
.With(h => h.Title = "Drone.S01E01.HDTV")
|
||||
.Build();
|
||||
|
||||
var remoteEpisode = BuildRemoteEpisode();
|
||||
var remoteAlbum = BuildRemoteAlbum();
|
||||
|
||||
_trackedDownload = Builder<TrackedDownload>.CreateNew()
|
||||
.With(c => c.State = TrackedDownloadStage.Downloading)
|
||||
.With(c => c.DownloadItem = completed)
|
||||
.With(c => c.RemoteEpisode = remoteEpisode)
|
||||
.With(c => c.RemoteAlbum = remoteAlbum)
|
||||
.Build();
|
||||
|
||||
|
||||
|
@ -57,17 +57,17 @@ namespace NzbDrone.Core.Test.Download
|
|||
.Returns(new History.History());
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(s => s.GetSeries("Drone.S01E01.HDTV"))
|
||||
.Returns(remoteEpisode.Series);
|
||||
.Setup(s => s.GetArtist("Drone.S01E01.HDTV"))
|
||||
.Returns(remoteAlbum.Artist);
|
||||
|
||||
}
|
||||
|
||||
private RemoteEpisode BuildRemoteEpisode()
|
||||
private RemoteAlbum BuildRemoteAlbum()
|
||||
{
|
||||
return new RemoteEpisode
|
||||
return new RemoteAlbum
|
||||
{
|
||||
Series = new Series(),
|
||||
Episodes = new List<Episode> { new Episode { Id = 1 } }
|
||||
Artist = new Artist(),
|
||||
Albums = new List<Album> { new Album { Id = 1 } }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -81,8 +81,8 @@ namespace NzbDrone.Core.Test.Download
|
|||
|
||||
private void GivenSuccessfulImport()
|
||||
{
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
||||
Mocker.GetMock<IDownloadedTracksImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Artist>(), It.IsAny<DownloadClientItem>()))
|
||||
.Returns(new List<ImportResult>
|
||||
{
|
||||
new ImportResult(new ImportDecision(new LocalTrack() { Path = @"C:\TestPath\Droned.S01E01.mkv" }))
|
||||
|
@ -99,19 +99,19 @@ namespace NzbDrone.Core.Test.Download
|
|||
.Returns(new History.History() { SourceTitle = "Droned S01E01" });
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(s => s.GetSeries(It.IsAny<string>()))
|
||||
.Returns((Series)null);
|
||||
.Setup(s => s.GetArtist(It.IsAny<string>()))
|
||||
.Returns((Artist)null);
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(s => s.GetSeries("Droned S01E01"))
|
||||
.Returns(BuildRemoteEpisode().Series);
|
||||
.Setup(s => s.GetArtist("Droned S01E01"))
|
||||
.Returns(BuildRemoteAlbum().Artist);
|
||||
}
|
||||
|
||||
private void GivenSeriesMatch()
|
||||
private void GivenArtistMatch()
|
||||
{
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(s => s.GetSeries(It.IsAny<string>()))
|
||||
.Returns(_trackedDownload.RemoteEpisode.Series);
|
||||
.Setup(s => s.GetArtist(It.IsAny<string>()))
|
||||
.Returns(_trackedDownload.RemoteAlbum.Artist);
|
||||
}
|
||||
|
||||
[TestCase(DownloadItemStatus.Downloading)]
|
||||
|
@ -144,7 +144,7 @@ namespace NzbDrone.Core.Test.Download
|
|||
{
|
||||
_trackedDownload.DownloadItem.Category = "tv";
|
||||
GivenNoGrabbedHistory();
|
||||
GivenSeriesMatch();
|
||||
GivenArtistMatch();
|
||||
GivenSuccessfulImport();
|
||||
|
||||
Subject.Process(_trackedDownload);
|
||||
|
@ -152,20 +152,6 @@ namespace NzbDrone.Core.Test.Download
|
|||
AssertCompletedDownload();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_process_if_storage_directory_in_drone_factory()
|
||||
{
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.SetupGet(v => v.DownloadedAlbumsFolder)
|
||||
.Returns(@"C:\DropFolder".AsOsAgnostic());
|
||||
|
||||
_trackedDownload.DownloadItem.OutputPath = new OsPath(@"C:\DropFolder\SomeOtherFolder".AsOsAgnostic());
|
||||
|
||||
Subject.Process(_trackedDownload);
|
||||
|
||||
AssertNoAttemptedImport();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_process_if_output_path_is_empty()
|
||||
{
|
||||
|
@ -179,8 +165,8 @@ namespace NzbDrone.Core.Test.Download
|
|||
[Test]
|
||||
public void should_mark_as_imported_if_all_episodes_were_imported()
|
||||
{
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
||||
Mocker.GetMock<IDownloadedTracksImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Artist>(), It.IsAny<DownloadClientItem>()))
|
||||
.Returns(new List<ImportResult>
|
||||
{
|
||||
new ImportResult(
|
||||
|
@ -200,8 +186,8 @@ namespace NzbDrone.Core.Test.Download
|
|||
[Test]
|
||||
public void should_not_mark_as_imported_if_all_files_were_rejected()
|
||||
{
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
||||
Mocker.GetMock<IDownloadedTracksImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Artist>(), It.IsAny<DownloadClientItem>()))
|
||||
.Returns(new List<ImportResult>
|
||||
{
|
||||
new ImportResult(
|
||||
|
@ -224,8 +210,8 @@ namespace NzbDrone.Core.Test.Download
|
|||
[Test]
|
||||
public void should_not_mark_as_imported_if_no_episodes_were_parsed()
|
||||
{
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
||||
Mocker.GetMock<IDownloadedTracksImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Artist>(), It.IsAny<DownloadClientItem>()))
|
||||
.Returns(new List<ImportResult>
|
||||
{
|
||||
new ImportResult(
|
||||
|
@ -237,7 +223,7 @@ namespace NzbDrone.Core.Test.Download
|
|||
new LocalTrack {Path = @"C:\TestPath\Droned.S01E02.mkv"},new Rejection("Rejected!")), "Test Failure")
|
||||
});
|
||||
|
||||
_trackedDownload.RemoteEpisode.Episodes.Clear();
|
||||
_trackedDownload.RemoteAlbum.Albums.Clear();
|
||||
|
||||
Subject.Process(_trackedDownload);
|
||||
|
||||
|
@ -247,8 +233,8 @@ namespace NzbDrone.Core.Test.Download
|
|||
[Test]
|
||||
public void should_not_mark_as_imported_if_all_files_were_skipped()
|
||||
{
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
||||
Mocker.GetMock<IDownloadedTracksImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Artist>(), It.IsAny<DownloadClientItem>()))
|
||||
.Returns(new List<ImportResult>
|
||||
{
|
||||
new ImportResult(new ImportDecision(new LocalTrack {Path = @"C:\TestPath\Droned.S01E01.mkv"}),"Test Failure"),
|
||||
|
@ -264,15 +250,15 @@ namespace NzbDrone.Core.Test.Download
|
|||
[Test]
|
||||
public void should_mark_as_imported_if_all_episodes_were_imported_but_extra_files_were_not()
|
||||
{
|
||||
GivenSeriesMatch();
|
||||
GivenArtistMatch();
|
||||
|
||||
_trackedDownload.RemoteEpisode.Episodes = new List<Episode>
|
||||
_trackedDownload.RemoteAlbum.Albums = new List<Album>
|
||||
{
|
||||
new Episode()
|
||||
new Album()
|
||||
};
|
||||
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
||||
Mocker.GetMock<IDownloadedTracksImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Artist>(), It.IsAny<DownloadClientItem>()))
|
||||
.Returns(new List<ImportResult>
|
||||
{
|
||||
new ImportResult(new ImportDecision(new LocalTrack {Path = @"C:\TestPath\Droned.S01E01.mkv"})),
|
||||
|
@ -287,15 +273,15 @@ namespace NzbDrone.Core.Test.Download
|
|||
[Test]
|
||||
public void should_mark_as_failed_if_some_of_episodes_were_not_imported()
|
||||
{
|
||||
_trackedDownload.RemoteEpisode.Episodes = new List<Episode>
|
||||
_trackedDownload.RemoteAlbum.Albums = new List<Album>
|
||||
{
|
||||
new Episode(),
|
||||
new Episode(),
|
||||
new Episode()
|
||||
new Album(),
|
||||
new Album(),
|
||||
new Album()
|
||||
};
|
||||
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
||||
Mocker.GetMock<IDownloadedTracksImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Artist>(), It.IsAny<DownloadClientItem>()))
|
||||
.Returns(new List<ImportResult>
|
||||
{
|
||||
new ImportResult(new ImportDecision(new LocalTrack {Path = @"C:\TestPath\Droned.S01E01.mkv"})),
|
||||
|
@ -314,16 +300,16 @@ namespace NzbDrone.Core.Test.Download
|
|||
{
|
||||
GivenABadlyNamedDownload();
|
||||
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
||||
Mocker.GetMock<IDownloadedTracksImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Artist>(), It.IsAny<DownloadClientItem>()))
|
||||
.Returns(new List<ImportResult>
|
||||
{
|
||||
new ImportResult(new ImportDecision(new LocalTrack {Path = @"C:\TestPath\Droned.S01E01.mkv"}))
|
||||
});
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Setup(v => v.GetSeries(It.IsAny<int>()))
|
||||
.Returns(BuildRemoteEpisode().Series);
|
||||
Mocker.GetMock<IArtistService>()
|
||||
.Setup(v => v.GetArtist(It.IsAny<int>()))
|
||||
.Returns(BuildRemoteAlbum().Artist);
|
||||
|
||||
Subject.Process(_trackedDownload);
|
||||
|
||||
|
@ -335,8 +321,8 @@ namespace NzbDrone.Core.Test.Download
|
|||
{
|
||||
GivenABadlyNamedDownload();
|
||||
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
||||
Mocker.GetMock<IDownloadedTracksImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Artist>(), It.IsAny<DownloadClientItem>()))
|
||||
.Returns(new List<ImportResult>
|
||||
{
|
||||
new ImportResult(new ImportDecision(new LocalTrack {Path = @"C:\TestPath\Droned.S01E01.mkv"}))
|
||||
|
@ -354,8 +340,8 @@ namespace NzbDrone.Core.Test.Download
|
|||
public void should_not_import_when_there_is_a_title_mismatch()
|
||||
{
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(s => s.GetSeries("Drone.S01E01.HDTV"))
|
||||
.Returns((Series)null);
|
||||
.Setup(s => s.GetArtist("Drone.S01E01.HDTV"))
|
||||
.Returns((Artist)null);
|
||||
|
||||
Subject.Process(_trackedDownload);
|
||||
|
||||
|
@ -365,13 +351,13 @@ namespace NzbDrone.Core.Test.Download
|
|||
[Test]
|
||||
public void should_mark_as_import_title_mismatch_if_ignore_warnings_is_true()
|
||||
{
|
||||
_trackedDownload.RemoteEpisode.Episodes = new List<Episode>
|
||||
_trackedDownload.RemoteAlbum.Albums = new List<Album>
|
||||
{
|
||||
new Episode()
|
||||
new Album()
|
||||
};
|
||||
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
||||
Mocker.GetMock<IDownloadedTracksImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Artist>(), It.IsAny<DownloadClientItem>()))
|
||||
.Returns(new List<ImportResult>
|
||||
{
|
||||
new ImportResult(new ImportDecision(new LocalTrack {Path = @"C:\TestPath\Droned.S01E01.mkv"}))
|
||||
|
@ -408,8 +394,8 @@ namespace NzbDrone.Core.Test.Download
|
|||
|
||||
private void AssertNoAttemptedImport()
|
||||
{
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
||||
.Verify(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()), Times.Never());
|
||||
Mocker.GetMock<IDownloadedTracksImportService>()
|
||||
.Verify(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Artist>(), It.IsAny<DownloadClientItem>()), Times.Never());
|
||||
|
||||
AssertNoCompletedDownload();
|
||||
}
|
||||
|
@ -424,8 +410,8 @@ namespace NzbDrone.Core.Test.Download
|
|||
|
||||
private void AssertCompletedDownload()
|
||||
{
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
||||
.Verify(v => v.ProcessPath(_trackedDownload.DownloadItem.OutputPath.FullPath, ImportMode.Auto, _trackedDownload.RemoteEpisode.Series, _trackedDownload.DownloadItem), Times.Once());
|
||||
Mocker.GetMock<IDownloadedTracksImportService>()
|
||||
.Verify(v => v.ProcessPath(_trackedDownload.DownloadItem.OutputPath.FullPath, ImportMode.Auto, _trackedDownload.RemoteAlbum.Artist, _trackedDownload.DownloadItem), Times.Once());
|
||||
|
||||
Mocker.GetMock<IEventAggregator>()
|
||||
.Verify(v => v.PublishEvent(It.IsAny<DownloadCompletedEvent>()), Times.Once());
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Download.Clients.Pneumatic;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
@ -19,9 +18,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
|||
private const string _nzbUrl = "http://www.nzbs.com/url";
|
||||
private const string _title = "30.Rock.S01E05.hdtv.xvid-LoL";
|
||||
private string _pneumaticFolder;
|
||||
private string _sabDrop;
|
||||
private string _strmFolder;
|
||||
private string _nzbPath;
|
||||
private RemoteAlbum _remoteEpisode;
|
||||
private RemoteAlbum _remoteAlbum;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
|
@ -29,21 +28,20 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
|||
_pneumaticFolder = @"d:\nzb\pneumatic\".AsOsAgnostic();
|
||||
|
||||
_nzbPath = Path.Combine(_pneumaticFolder, _title + ".nzb").AsOsAgnostic();
|
||||
_sabDrop = @"d:\unsorted tv\".AsOsAgnostic();
|
||||
_strmFolder = @"d:\unsorted tv\".AsOsAgnostic();
|
||||
|
||||
Mocker.GetMock<IConfigService>().SetupGet(c => c.DownloadedAlbumsFolder).Returns(_sabDrop);
|
||||
_remoteAlbum = new RemoteAlbum();
|
||||
_remoteAlbum.Release = new ReleaseInfo();
|
||||
_remoteAlbum.Release.Title = _title;
|
||||
_remoteAlbum.Release.DownloadUrl = _nzbUrl;
|
||||
|
||||
_remoteEpisode = new RemoteAlbum();
|
||||
_remoteEpisode.Release = new ReleaseInfo();
|
||||
_remoteEpisode.Release.Title = _title;
|
||||
_remoteEpisode.Release.DownloadUrl = _nzbUrl;
|
||||
|
||||
_remoteEpisode.ParsedAlbumInfo = new ParsedAlbumInfo();
|
||||
_remoteAlbum.ParsedAlbumInfo = new ParsedAlbumInfo();
|
||||
|
||||
Subject.Definition = new DownloadClientDefinition();
|
||||
Subject.Definition.Settings = new PneumaticSettings
|
||||
{
|
||||
NzbFolder = _pneumaticFolder
|
||||
NzbFolder = _pneumaticFolder,
|
||||
StrmFolder = _strmFolder
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -55,26 +53,25 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
|||
[Test]
|
||||
public void should_download_file_if_it_doesnt_exist()
|
||||
{
|
||||
Subject.Download(_remoteEpisode);
|
||||
Subject.Download(_remoteAlbum);
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.DownloadFile(_nzbUrl, _nzbPath), Times.Once());
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_throw_on_failed_download()
|
||||
{
|
||||
WithFailedDownload();
|
||||
|
||||
Assert.Throws<WebException>(() => Subject.Download(_remoteEpisode));
|
||||
Assert.Throws<WebException>(() => Subject.Download(_remoteAlbum));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_if_full_season_download()
|
||||
{
|
||||
_remoteEpisode.Release.Title = "30 Rock - Season 1";
|
||||
_remoteAlbum.Release.Title = "30 Rock - Season 1";
|
||||
|
||||
Assert.Throws<NotSupportedException>(() => Subject.Download(_remoteEpisode));
|
||||
Assert.Throws<NotSupportedException>(() => Subject.Download(_remoteAlbum));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -88,9 +85,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
|||
{
|
||||
var illegalTitle = "Saturday Night Live - S38E08 - Jeremy Renner/Maroon 5 [SDTV]";
|
||||
var expectedFilename = Path.Combine(_pneumaticFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV].nzb");
|
||||
_remoteEpisode.Release.Title = illegalTitle;
|
||||
_remoteAlbum.Release.Title = illegalTitle;
|
||||
|
||||
Subject.Download(_remoteEpisode);
|
||||
Subject.Download(_remoteAlbum);
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.DownloadFile(It.IsAny<string>(), expectedFilename), Times.Once());
|
||||
}
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.HealthCheck.Checks;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||
{
|
||||
[TestFixture]
|
||||
public class DroneFactoryCheckFixture : CoreTest<DroneFactoryCheck>
|
||||
{
|
||||
private const string DRONE_FACTORY_FOLDER = @"C:\Test\Unsorted";
|
||||
|
||||
private void GivenDroneFactoryFolder(bool exists = false, bool writable = true)
|
||||
{
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.SetupGet(s => s.DownloadedAlbumsFolder)
|
||||
.Returns(DRONE_FACTORY_FOLDER);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.FolderExists(DRONE_FACTORY_FOLDER))
|
||||
.Returns(exists);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.FolderWritable(It.IsAny<string>()))
|
||||
.Returns(exists && writable);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_error_when_drone_factory_folder_does_not_exist()
|
||||
{
|
||||
GivenDroneFactoryFolder();
|
||||
|
||||
Subject.Check().ShouldBeError();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_error_when_unable_to_write_to_drone_factory_folder()
|
||||
{
|
||||
GivenDroneFactoryFolder(true, false);
|
||||
|
||||
Subject.Check().ShouldBeError();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_ok_when_no_issues_found()
|
||||
{
|
||||
GivenDroneFactoryFolder(true);
|
||||
|
||||
Subject.Check().ShouldBeOk();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using NUnit.Framework;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.HealthCheck.Checks;
|
||||
|
@ -10,8 +10,6 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
|||
[TestFixture]
|
||||
public class ImportMechanismCheckFixture : CoreTest<ImportMechanismCheck>
|
||||
{
|
||||
private const string DRONE_FACTORY_FOLDER = @"C:\Test\Unsorted";
|
||||
|
||||
|
||||
private void GivenCompletedDownloadHandling(bool? enabled = null)
|
||||
{
|
||||
|
@ -27,17 +25,6 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
|||
}
|
||||
}
|
||||
|
||||
private void GivenDroneFactoryFolder(bool exists = false)
|
||||
{
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.SetupGet(s => s.DownloadedAlbumsFolder)
|
||||
.Returns(DRONE_FACTORY_FOLDER.AsOsAgnostic());
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.FolderExists(DRONE_FACTORY_FOLDER.AsOsAgnostic()))
|
||||
.Returns(exists);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_warning_when_completed_download_handling_not_configured()
|
||||
{
|
||||
|
@ -56,7 +43,6 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
|||
public void should_return_ok_when_no_issues_found()
|
||||
{
|
||||
GivenCompletedDownloadHandling(true);
|
||||
GivenDroneFactoryFolder(true);
|
||||
|
||||
Subject.Check().ShouldBeOk();
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Download.TrackedDownloads;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
|
@ -12,7 +12,7 @@ using NzbDrone.Core.MediaFiles.Commands;
|
|||
using NzbDrone.Core.MediaFiles.TrackImport;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFiles
|
||||
|
@ -20,7 +20,6 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
[TestFixture]
|
||||
public class DownloadedAlbumsCommandServiceFixture : CoreTest<DownloadedAlbumsCommandService>
|
||||
{
|
||||
private string _droneFactory = "c:\\drop\\".AsOsAgnostic();
|
||||
private string _downloadFolder = "c:\\drop_other\\Show.S01E01\\".AsOsAgnostic();
|
||||
private string _downloadFile = "c:\\drop_other\\Show.S01E01.mkv".AsOsAgnostic();
|
||||
|
||||
|
@ -29,15 +28,13 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.GetMock<IConfigService>().SetupGet(c => c.DownloadedAlbumsFolder)
|
||||
.Returns(_droneFactory);
|
||||
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
||||
Mocker.GetMock<IDownloadedTracksImportService>()
|
||||
.Setup(v => v.ProcessRootFolder(It.IsAny<DirectoryInfo>()))
|
||||
.Returns(new List<ImportResult>());
|
||||
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
||||
Mocker.GetMock<IDownloadedTracksImportService>()
|
||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Artist>(), It.IsAny<DownloadClientItem>()))
|
||||
.Returns(new List<ImportResult>());
|
||||
|
||||
var downloadItem = Builder<DownloadClientItem>.CreateNew()
|
||||
|
@ -45,14 +42,14 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
.With(v => v.Status = DownloadItemStatus.Downloading)
|
||||
.Build();
|
||||
|
||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||
.With(v => v.Series = new Series())
|
||||
var remoteAlbum = Builder<RemoteAlbum>.CreateNew()
|
||||
.With(v => v.Artist = new Artist())
|
||||
.Build();
|
||||
|
||||
_trackedDownload = new TrackedDownload
|
||||
{
|
||||
DownloadItem = downloadItem,
|
||||
RemoteEpisode = remoteEpisode,
|
||||
RemoteAlbum = remoteAlbum,
|
||||
State = TrackedDownloadStage.Downloading
|
||||
};
|
||||
}
|
||||
|
@ -76,35 +73,15 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
.Returns(_trackedDownload);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_process_dronefactory_if_path_is_not_specified()
|
||||
{
|
||||
GivenExistingFolder(_droneFactory);
|
||||
|
||||
Subject.Execute(new DownloadedAlbumsScanCommand());
|
||||
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessRootFolder(It.IsAny<DirectoryInfo>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_skip_import_if_dronefactory_doesnt_exist()
|
||||
{
|
||||
Subject.Execute(new DownloadedAlbumsScanCommand());
|
||||
Assert.Throws<ArgumentException>(() => Subject.Execute(new DownloadedAlbumsScanCommand()));
|
||||
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessRootFolder(It.IsAny<DirectoryInfo>()), Times.Never());
|
||||
Mocker.GetMock<IDownloadedTracksImportService>().Verify(c => c.ProcessRootFolder(It.IsAny<DirectoryInfo>()), Times.Never());
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_ignore_downloadclientid_if_path_is_not_specified()
|
||||
{
|
||||
GivenExistingFolder(_droneFactory);
|
||||
|
||||
Subject.Execute(new DownloadedAlbumsScanCommand() { DownloadClientId = "sab1" });
|
||||
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessRootFolder(It.IsAny<DirectoryInfo>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_process_folder_if_downloadclientid_is_not_specified()
|
||||
|
@ -113,7 +90,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
|
||||
Subject.Execute(new DownloadedAlbumsScanCommand() { Path = _downloadFolder });
|
||||
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessPath(It.IsAny<string>(), ImportMode.Auto, null, null), Times.Once());
|
||||
Mocker.GetMock<IDownloadedTracksImportService>().Verify(c => c.ProcessPath(It.IsAny<string>(), ImportMode.Auto, null, null), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -123,7 +100,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
|
||||
Subject.Execute(new DownloadedAlbumsScanCommand() { Path = _downloadFile });
|
||||
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessPath(It.IsAny<string>(), ImportMode.Auto, null, null), Times.Once());
|
||||
Mocker.GetMock<IDownloadedTracksImportService>().Verify(c => c.ProcessPath(It.IsAny<string>(), ImportMode.Auto, null, null), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -134,7 +111,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
|
||||
Subject.Execute(new DownloadedAlbumsScanCommand() { Path = _downloadFolder, DownloadClientId = "sab1" });
|
||||
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessPath(_downloadFolder, ImportMode.Auto, _trackedDownload.RemoteEpisode.Series, _trackedDownload.DownloadItem), Times.Once());
|
||||
Mocker.GetMock<IDownloadedTracksImportService>().Verify(c => c.ProcessPath(_downloadFolder, ImportMode.Auto, _trackedDownload.RemoteAlbum.Artist, _trackedDownload.DownloadItem), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -144,7 +121,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
|
||||
Subject.Execute(new DownloadedAlbumsScanCommand() { Path = _downloadFolder, DownloadClientId = "sab1" });
|
||||
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessPath(_downloadFolder, ImportMode.Auto, null, null), Times.Once());
|
||||
Mocker.GetMock<IDownloadedTracksImportService>().Verify(c => c.ProcessPath(_downloadFolder, ImportMode.Auto, null, null), Times.Once());
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
@ -154,7 +131,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
{
|
||||
Subject.Execute(new DownloadedAlbumsScanCommand() { Path = _downloadFolder });
|
||||
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessPath(It.IsAny<string>(), ImportMode.Auto, null, null), Times.Never());
|
||||
Mocker.GetMock<IDownloadedTracksImportService>().Verify(c => c.ProcessPath(It.IsAny<string>(), ImportMode.Auto, null, null), Times.Never());
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
@ -166,7 +143,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
|
||||
Subject.Execute(new DownloadedAlbumsScanCommand() { Path = _downloadFile, ImportMode = ImportMode.Copy });
|
||||
|
||||
Mocker.GetMock<IDownloadedEpisodesImportService>().Verify(c => c.ProcessPath(It.IsAny<string>(), ImportMode.Copy, null, null), Times.Once());
|
||||
Mocker.GetMock<IDownloadedTracksImportService>().Verify(c => c.ProcessPath(It.IsAny<string>(), ImportMode.Copy, null, null), Times.Once());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ using NzbDrone.Core.Parser;
|
|||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Test.Common;
|
||||
using FluentAssertions;
|
||||
|
@ -19,7 +18,7 @@ using FluentAssertions;
|
|||
namespace NzbDrone.Core.Test.MediaFiles
|
||||
{
|
||||
[TestFixture]
|
||||
public class DownloadedTracksImportServiceFixture : CoreTest<DownloadedEpisodesImportService>
|
||||
public class DownloadedTracksImportServiceFixture : CoreTest<DownloadedTracksImportService>
|
||||
{
|
||||
private string _droneFactory = "c:\\drop\\".AsOsAgnostic();
|
||||
private string[] _subFolders = new[] { "c:\\root\\foldername".AsOsAgnostic() };
|
||||
|
@ -42,25 +41,25 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
.Returns(new List<ImportResult>());
|
||||
}
|
||||
|
||||
private void GivenValidSeries()
|
||||
private void GivenValidArtist()
|
||||
{
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(s => s.GetSeries(It.IsAny<string>()))
|
||||
.Returns(Builder<Series>.CreateNew().Build());
|
||||
.Setup(s => s.GetArtist(It.IsAny<string>()))
|
||||
.Returns(Builder<Artist>.CreateNew().Build());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_search_for_series_using_folder_name()
|
||||
public void should_search_for_artist_using_folder_name()
|
||||
{
|
||||
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
|
||||
|
||||
Mocker.GetMock<IParsingService>().Verify(c => c.GetSeries("foldername"), Times.Once());
|
||||
Mocker.GetMock<IParsingService>().Verify(c => c.GetArtist("foldername"), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_skip_if_file_is_in_use_by_another_process()
|
||||
{
|
||||
GivenValidSeries();
|
||||
GivenValidArtist();
|
||||
|
||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.IsFileLocked(It.IsAny<string>()))
|
||||
.Returns(true);
|
||||
|
@ -71,9 +70,9 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void should_skip_if_no_series_found()
|
||||
public void should_skip_if_no_artist_found()
|
||||
{
|
||||
Mocker.GetMock<IParsingService>().Setup(c => c.GetSeries("foldername")).Returns((Series)null);
|
||||
Mocker.GetMock<IParsingService>().Setup(c => c.GetArtist("foldername")).Returns((Artist)null);
|
||||
|
||||
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
|
||||
|
||||
|
@ -85,12 +84,12 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_import_if_folder_is_a_series_path()
|
||||
public void should_not_import_if_folder_is_a_artist_path()
|
||||
{
|
||||
GivenValidSeries();
|
||||
GivenValidArtist();
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Setup(s => s.SeriesPathExists(It.IsAny<string>()))
|
||||
Mocker.GetMock<IArtistService>()
|
||||
.Setup(s => s.ArtistPathExists(It.IsAny<string>()))
|
||||
.Returns(true);
|
||||
|
||||
Mocker.GetMock<IDiskScanService>()
|
||||
|
@ -108,7 +107,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
[Test]
|
||||
public void should_not_delete_folder_if_no_files_were_imported()
|
||||
{
|
||||
Mocker.GetMock<IImportApprovedEpisodes>()
|
||||
Mocker.GetMock<IImportApprovedTracks>()
|
||||
.Setup(s => s.Import(It.IsAny<List<ImportDecision>>(), false, null, ImportMode.Auto))
|
||||
.Returns(new List<ImportResult>());
|
||||
|
||||
|
@ -121,18 +120,18 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
[Test]
|
||||
public void should_not_delete_folder_if_files_were_imported_and_video_files_remain()
|
||||
{
|
||||
GivenValidSeries();
|
||||
GivenValidArtist();
|
||||
|
||||
var localEpisode = new LocalTrack();
|
||||
var localTrack = new LocalTrack();
|
||||
|
||||
var imported = new List<ImportDecision>();
|
||||
imported.Add(new ImportDecision(localEpisode));
|
||||
imported.Add(new ImportDecision(localTrack));
|
||||
|
||||
Mocker.GetMock<IMakeImportDecision>()
|
||||
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Artist>(), null))
|
||||
.Returns(imported);
|
||||
|
||||
Mocker.GetMock<IImportApprovedEpisodes>()
|
||||
Mocker.GetMock<IImportApprovedTracks>()
|
||||
.Setup(s => s.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto))
|
||||
.Returns(imported.Select(i => new ImportResult(i)).ToList());
|
||||
|
||||
|
@ -147,7 +146,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
[Test]
|
||||
public void should_delete_folder_if_files_were_imported_and_only_sample_files_remain()
|
||||
{
|
||||
GivenValidSeries();
|
||||
GivenValidArtist();
|
||||
|
||||
var localEpisode = new LocalTrack();
|
||||
|
||||
|
@ -158,17 +157,17 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Artist>(), null))
|
||||
.Returns(imported);
|
||||
|
||||
Mocker.GetMock<IImportApprovedEpisodes>()
|
||||
Mocker.GetMock<IImportApprovedTracks>()
|
||||
.Setup(s => s.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto))
|
||||
.Returns(imported.Select(i => new ImportResult(i)).ToList());
|
||||
|
||||
Mocker.GetMock<IDetectSample>()
|
||||
.Setup(s => s.IsSample(It.IsAny<Series>(),
|
||||
It.IsAny<QualityModel>(),
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<long>(),
|
||||
It.IsAny<bool>()))
|
||||
.Returns(true);
|
||||
//Mocker.GetMock<IDetectSample>()
|
||||
// .Setup(s => s.IsSample(It.IsAny<Artist>(),
|
||||
// It.IsAny<QualityModel>(),
|
||||
// It.IsAny<string>(),
|
||||
// It.IsAny<long>(),
|
||||
// It.IsAny<bool>()))
|
||||
// .Returns(true);
|
||||
|
||||
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
|
||||
|
||||
|
@ -190,14 +189,14 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Verify(v => v.GetSeries(folderName), Times.Once());
|
||||
.Verify(v => v.GetArtist(folderName), Times.Once());
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Verify(v => v.GetSeries(It.Is<string>(s => s.StartsWith(prefix))), Times.Never());
|
||||
.Verify(v => v.GetArtist(It.Is<string>(s => s.StartsWith(prefix))), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_importresult_on_unknown_series()
|
||||
public void should_return_importresult_on_unknown_artist()
|
||||
{
|
||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists(It.IsAny<string>()))
|
||||
.Returns(false);
|
||||
|
@ -219,7 +218,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
[Test]
|
||||
public void should_not_delete_if_there_is_large_rar_file()
|
||||
{
|
||||
GivenValidSeries();
|
||||
GivenValidArtist();
|
||||
|
||||
var localEpisode = new LocalTrack();
|
||||
|
||||
|
@ -230,17 +229,17 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Artist>(), null))
|
||||
.Returns(imported);
|
||||
|
||||
Mocker.GetMock<IImportApprovedEpisodes>()
|
||||
Mocker.GetMock<IImportApprovedTracks>()
|
||||
.Setup(s => s.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto))
|
||||
.Returns(imported.Select(i => new ImportResult(i)).ToList());
|
||||
|
||||
Mocker.GetMock<IDetectSample>()
|
||||
.Setup(s => s.IsSample(It.IsAny<Series>(),
|
||||
It.IsAny<QualityModel>(),
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<long>(),
|
||||
It.IsAny<bool>()))
|
||||
.Returns(true);
|
||||
//Mocker.GetMock<IDetectSample>()
|
||||
// .Setup(s => s.IsSample(It.IsAny<Artist>(),
|
||||
// It.IsAny<QualityModel>(),
|
||||
// It.IsAny<string>(),
|
||||
// It.IsAny<long>(),
|
||||
// It.IsAny<bool>()))
|
||||
// .Returns(true);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.GetFiles(It.IsAny<string>(), SearchOption.AllDirectories))
|
||||
|
@ -261,7 +260,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
[Test]
|
||||
public void should_use_folder_if_folder_import()
|
||||
{
|
||||
GivenValidSeries();
|
||||
GivenValidArtist();
|
||||
|
||||
var folderName = @"C:\media\ba09030e-1234-1234-1234-123456789abc\[HorribleSubs] Maria the Virgin Witch - 09 [720p]".AsOsAgnostic();
|
||||
var fileName = @"C:\media\ba09030e-1234-1234-1234-123456789abc\[HorribleSubs] Maria the Virgin Witch - 09 [720p]\[HorribleSubs] Maria the Virgin Witch - 09 [720p].mkv".AsOsAgnostic();
|
||||
|
@ -287,7 +286,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
[Test]
|
||||
public void should_not_use_folder_if_file_import()
|
||||
{
|
||||
GivenValidSeries();
|
||||
GivenValidArtist();
|
||||
|
||||
var fileName = @"C:\media\ba09030e-1234-1234-1234-123456789abc\Torrents\[HorribleSubs] Maria the Virgin Witch - 09 [720p].mkv".AsOsAgnostic();
|
||||
|
||||
|
@ -322,7 +321,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
Subject.ProcessPath(folderName).Should().BeEmpty();
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Verify(v => v.GetSeries(It.IsAny<string>()), Times.Never());
|
||||
.Verify(v => v.GetArtist(It.IsAny<string>()), Times.Never());
|
||||
|
||||
ExceptionVerification.ExpectedErrors(1);
|
||||
}
|
||||
|
@ -330,7 +329,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
[Test]
|
||||
public void should_not_delete_if_no_files_were_imported()
|
||||
{
|
||||
GivenValidSeries();
|
||||
GivenValidArtist();
|
||||
|
||||
var localEpisode = new LocalTrack();
|
||||
|
||||
|
@ -341,17 +340,17 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Artist>(), null))
|
||||
.Returns(imported);
|
||||
|
||||
Mocker.GetMock<IImportApprovedEpisodes>()
|
||||
Mocker.GetMock<IImportApprovedTracks>()
|
||||
.Setup(s => s.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto))
|
||||
.Returns(new List<ImportResult>());
|
||||
|
||||
Mocker.GetMock<IDetectSample>()
|
||||
.Setup(s => s.IsSample(It.IsAny<Series>(),
|
||||
It.IsAny<QualityModel>(),
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<long>(),
|
||||
It.IsAny<bool>()))
|
||||
.Returns(true);
|
||||
//Mocker.GetMock<IDetectSample>()
|
||||
// .Setup(s => s.IsSample(It.IsAny<Artist>(),
|
||||
// It.IsAny<QualityModel>(),
|
||||
// It.IsAny<string>(),
|
||||
// It.IsAny<long>(),
|
||||
// It.IsAny<bool>()))
|
||||
// .Returns(true);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.GetFileSize(It.IsAny<string>()))
|
||||
|
@ -365,13 +364,13 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
|
||||
private void VerifyNoImport()
|
||||
{
|
||||
Mocker.GetMock<IImportApprovedEpisodes>().Verify(c => c.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto),
|
||||
Mocker.GetMock<IImportApprovedTracks>().Verify(c => c.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto),
|
||||
Times.Never());
|
||||
}
|
||||
|
||||
private void VerifyImport()
|
||||
{
|
||||
Mocker.GetMock<IImportApprovedEpisodes>().Verify(c => c.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto),
|
||||
Mocker.GetMock<IImportApprovedTracks>().Verify(c => c.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto),
|
||||
Times.Once());
|
||||
}
|
||||
}
|
|
@ -219,7 +219,6 @@
|
|||
<Compile Include="HealthCheck\Checks\DeleteBadMediaCovers.cs" />
|
||||
<Compile Include="HealthCheck\Checks\AppDataLocationFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\DownloadClientCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\DroneFactoryCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\HealthCheckFixtureExtensions.cs" />
|
||||
<Compile Include="HealthCheck\Checks\ImportMechanismCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\IndexerSearchCheckFixture.cs" />
|
||||
|
@ -283,7 +282,7 @@
|
|||
<Compile Include="MediaCoverTests\MediaCoverServiceFixture.cs" />
|
||||
<Compile Include="MediaFiles\DiskScanServiceTests\ScanFixture.cs" />
|
||||
<Compile Include="MediaFiles\DownloadedAlbumsCommandServiceFixture.cs" />
|
||||
<Compile Include="MediaFiles\DownloadedEpisodesImportServiceFixture.cs" />
|
||||
<Compile Include="MediaFiles\DownloadedTracksImportServiceFixture.cs" />
|
||||
<Compile Include="MediaFiles\MediaInfo\MediaInfoFormatterTests\FormatAudioCodecFixture.cs" />
|
||||
<Compile Include="MediaFiles\TrackFileMovingServiceTests\MoveTrackFileFixture.cs" />
|
||||
<Compile Include="MediaFiles\TrackImport\ImportDecisionMakerFixture.cs" />
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -96,18 +96,6 @@ namespace NzbDrone.Core.Test.RootFolderTests
|
|||
Assert.Throws<UnauthorizedAccessException>(() => Subject.Add(new RootFolder { Path = @"C:\TV".AsOsAgnostic() }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_when_same_path_as_drone_factory()
|
||||
{
|
||||
var path = @"C:\TV".AsOsAgnostic();
|
||||
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.SetupGet(s => s.DownloadedAlbumsFolder)
|
||||
.Returns(path);
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() => Subject.Add(new RootFolder { Path = path }));
|
||||
}
|
||||
|
||||
[TestCase("$recycle.bin")]
|
||||
[TestCase("system volume information")]
|
||||
[TestCase("recycler")]
|
||||
|
@ -152,4 +140,4 @@ namespace NzbDrone.Core.Test.RootFolderTests
|
|||
unmappedFolders.Should().NotContain(u => u.Name == subFolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,13 +74,6 @@ namespace NzbDrone.Core.Configuration
|
|||
return _repository.Get(key.ToLower()) != null;
|
||||
}
|
||||
|
||||
public string DownloadedAlbumsFolder
|
||||
{
|
||||
get { return GetValue(ConfigKey.DownloadedAlbumsFolder.ToString()); }
|
||||
|
||||
set { SetValue(ConfigKey.DownloadedAlbumsFolder.ToString(), value); }
|
||||
}
|
||||
|
||||
public bool AutoUnmonitorPreviouslyDownloadedTracks
|
||||
{
|
||||
get { return GetValueBoolean("AutoUnmonitorPreviouslyDownloadedTracks"); }
|
||||
|
@ -168,13 +161,6 @@ namespace NzbDrone.Core.Configuration
|
|||
set { SetValue("DownloadClientWorkingFolders", value); }
|
||||
}
|
||||
|
||||
public int DownloadedAlbumsScanInterval
|
||||
{
|
||||
get { return GetValueInt("DownloadedAlbumsScanInterval", 1); }
|
||||
|
||||
set { SetValue("DownloadedAlbumsScanInterval", value); }
|
||||
}
|
||||
|
||||
public int DownloadClientHistoryLimit
|
||||
{
|
||||
get { return GetValueInt("DownloadClientHistoryLimit", 30); }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Common.Http.Proxy;
|
||||
|
||||
|
@ -11,9 +11,7 @@ namespace NzbDrone.Core.Configuration
|
|||
bool IsDefined(string key);
|
||||
|
||||
//Download Client
|
||||
string DownloadedAlbumsFolder { get; set; }
|
||||
string DownloadClientWorkingFolders { get; set; }
|
||||
int DownloadedAlbumsScanInterval { get; set; }
|
||||
int DownloadClientHistoryLimit { get; set; }
|
||||
|
||||
//Completed/Failed Download Handling (Download client)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using FluentValidation.Results;
|
||||
|
@ -113,25 +113,14 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic
|
|||
|
||||
private string WriteStrmFile(string title, string nzbFile)
|
||||
{
|
||||
string folder;
|
||||
|
||||
if (Settings.StrmFolder.IsNullOrWhiteSpace())
|
||||
{
|
||||
folder = _configService.DownloadedAlbumsFolder;
|
||||
|
||||
if (folder.IsNullOrWhiteSpace())
|
||||
{
|
||||
throw new DownloadClientException("Strm Folder needs to be set for Pneumatic Downloader");
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
folder = Settings.StrmFolder;
|
||||
throw new DownloadClientException("Strm Folder needs to be set for Pneumatic Downloader");
|
||||
}
|
||||
|
||||
var contents = string.Format("plugin://plugin.program.pneumatic/?mode=strm&type=add_file&nzb={0}&nzbname={1}", nzbFile, title);
|
||||
var filename = Path.Combine(folder, title + ".strm");
|
||||
var filename = Path.Combine(Settings.StrmFolder, title + ".strm");
|
||||
|
||||
_diskProvider.WriteAllText(filename, contents);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ using NzbDrone.Core.History;
|
|||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.MediaFiles.TrackImport;
|
||||
|
||||
namespace NzbDrone.Core.Download
|
||||
|
@ -26,26 +26,26 @@ namespace NzbDrone.Core.Download
|
|||
private readonly IConfigService _configService;
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
private readonly IHistoryService _historyService;
|
||||
private readonly IDownloadedEpisodesImportService _downloadedEpisodesImportService;
|
||||
private readonly IDownloadedTracksImportService _downloadedTracksImportService;
|
||||
private readonly IParsingService _parsingService;
|
||||
private readonly Logger _logger;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly IArtistService _artistService;
|
||||
|
||||
public CompletedDownloadService(IConfigService configService,
|
||||
IEventAggregator eventAggregator,
|
||||
IHistoryService historyService,
|
||||
IDownloadedEpisodesImportService downloadedEpisodesImportService,
|
||||
IDownloadedTracksImportService downloadedTracksImportService,
|
||||
IParsingService parsingService,
|
||||
ISeriesService seriesService,
|
||||
IArtistService artistService,
|
||||
Logger logger)
|
||||
{
|
||||
_configService = configService;
|
||||
_eventAggregator = eventAggregator;
|
||||
_historyService = historyService;
|
||||
_downloadedEpisodesImportService = downloadedEpisodesImportService;
|
||||
_downloadedTracksImportService = downloadedTracksImportService;
|
||||
_parsingService = parsingService;
|
||||
_logger = logger;
|
||||
_seriesService = seriesService;
|
||||
_artistService = artistService;
|
||||
}
|
||||
|
||||
public void Process(TrackedDownload trackedDownload, bool ignoreWarnings = false)
|
||||
|
@ -80,26 +80,18 @@ namespace NzbDrone.Core.Download
|
|||
return;
|
||||
}
|
||||
|
||||
var downloadedEpisodesFolder = new OsPath(_configService.DownloadedAlbumsFolder);
|
||||
var artist = trackedDownload.RemoteAlbum.Artist;
|
||||
|
||||
if (downloadedEpisodesFolder.Contains(downloadItemOutputPath))
|
||||
{
|
||||
trackedDownload.Warn("Intermediate Download path inside drone factory, Skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
var series = _parsingService.GetSeries(trackedDownload.DownloadItem.Title);
|
||||
|
||||
if (series == null)
|
||||
if (artist == null)
|
||||
{
|
||||
if (historyItem != null)
|
||||
{
|
||||
series = _seriesService.GetSeries(historyItem.ArtistId);
|
||||
artist = _artistService.GetArtist(historyItem.ArtistId);
|
||||
}
|
||||
|
||||
if (series == null)
|
||||
if (artist == null)
|
||||
{
|
||||
trackedDownload.Warn("Series title mismatch, automatic import is not possible.");
|
||||
trackedDownload.Warn("Artist name mismatch, automatic import is not possible.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +103,7 @@ namespace NzbDrone.Core.Download
|
|||
private void Import(TrackedDownload trackedDownload)
|
||||
{
|
||||
var outputPath = trackedDownload.DownloadItem.OutputPath.FullPath;
|
||||
var importResults = _downloadedEpisodesImportService.ProcessPath(outputPath, ImportMode.Auto, trackedDownload.RemoteEpisode.Series, trackedDownload.DownloadItem);
|
||||
var importResults = _downloadedTracksImportService.ProcessPath(outputPath, ImportMode.Auto, trackedDownload.RemoteAlbum.Artist, trackedDownload.DownloadItem);
|
||||
|
||||
if (importResults.Empty())
|
||||
{
|
||||
|
@ -119,7 +111,7 @@ namespace NzbDrone.Core.Download
|
|||
return;
|
||||
}
|
||||
|
||||
if (importResults.Count(c => c.Result == ImportResultType.Imported) >= Math.Max(1, trackedDownload.RemoteEpisode.Episodes.Count))
|
||||
if (importResults.Count(c => c.Result == ImportResultType.Imported) >= Math.Max(1, trackedDownload.RemoteAlbum.Albums.Count))
|
||||
{
|
||||
trackedDownload.State = TrackedDownloadStage.Imported;
|
||||
_eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload));
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
namespace NzbDrone.Core.HealthCheck.Checks
|
||||
{
|
||||
public class DroneFactoryCheck : HealthCheckBase
|
||||
{
|
||||
private readonly IConfigService _configService;
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
|
||||
public DroneFactoryCheck(IConfigService configService, IDiskProvider diskProvider)
|
||||
{
|
||||
_configService = configService;
|
||||
_diskProvider = diskProvider;
|
||||
}
|
||||
|
||||
public override HealthCheck Check()
|
||||
{
|
||||
var droneFactoryFolder = _configService.DownloadedAlbumsFolder;
|
||||
|
||||
if (droneFactoryFolder.IsNullOrWhiteSpace())
|
||||
{
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
|
||||
if (!_diskProvider.FolderExists(droneFactoryFolder))
|
||||
{
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Error, "Drone factory folder does not exist");
|
||||
}
|
||||
|
||||
if (!_diskProvider.FolderWritable(droneFactoryFolder))
|
||||
{
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Error, "Unable to write to drone factory folder");
|
||||
}
|
||||
|
||||
//Todo: Unable to import one or more files/folders from
|
||||
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Download.Clients;
|
||||
|
@ -24,7 +23,6 @@ namespace NzbDrone.Core.HealthCheck.Checks
|
|||
|
||||
public override HealthCheck Check()
|
||||
{
|
||||
var droneFactoryFolder = new OsPath(_configService.DownloadedAlbumsFolder);
|
||||
List<ImportMechanismCheckStatus> downloadClients;
|
||||
|
||||
try
|
||||
|
@ -42,9 +40,6 @@ namespace NzbDrone.Core.HealthCheck.Checks
|
|||
}
|
||||
|
||||
var downloadClientIsLocalHost = downloadClients.All(v => v.Status.IsLocalhost);
|
||||
var downloadClientOutputInDroneFactory = !droneFactoryFolder.IsEmpty &&
|
||||
downloadClients.Any(v => v.Status.OutputRootFolders != null &&
|
||||
v.Status.OutputRootFolders.Any(droneFactoryFolder.Contains));
|
||||
|
||||
if (!_configService.IsDefined("EnableCompletedDownloadHandling"))
|
||||
{
|
||||
|
@ -56,32 +51,20 @@ namespace NzbDrone.Core.HealthCheck.Checks
|
|||
|
||||
if (downloadClients.All(v => v.DownloadClient is Sabnzbd))
|
||||
{
|
||||
// With Sabnzbd we can check if the category should be changed.
|
||||
if (downloadClientOutputInDroneFactory)
|
||||
{
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Sabnzbd - Conflicting Category)", "Migrating-to-Completed-Download-Handling#sabnzbd-conflicting-download-client-category");
|
||||
}
|
||||
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Sabnzbd)", "Migrating-to-Completed-Download-Handling#sabnzbd-enable-completed-download-handling");
|
||||
}
|
||||
|
||||
if (downloadClients.All(v => v.DownloadClient is Nzbget))
|
||||
{
|
||||
// With Nzbget we can check if the category should be changed.
|
||||
if (downloadClientOutputInDroneFactory)
|
||||
{
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Nzbget - Conflicting Category)", "Migrating-to-Completed-Download-Handling#nzbget-conflicting-download-client-category");
|
||||
}
|
||||
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Nzbget)", "Migrating-to-Completed-Download-Handling#nzbget-enable-completed-download-handling");
|
||||
}
|
||||
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible", "Migrating-to-Completed-Download-Handling");
|
||||
}
|
||||
|
||||
if (!_configService.EnableCompletedDownloadHandling && droneFactoryFolder.IsEmpty)
|
||||
if (!_configService.EnableCompletedDownloadHandling)
|
||||
{
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling or configure Drone factory");
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling");
|
||||
}
|
||||
|
||||
return new HealthCheck(GetType());
|
||||
|
|
|
@ -11,10 +11,8 @@ using NzbDrone.Core.HealthCheck;
|
|||
using NzbDrone.Core.Housekeeping;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
using NzbDrone.Core.MediaFiles.Commands;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Tv.Commands;
|
||||
using NzbDrone.Core.Update.Commands;
|
||||
using NzbDrone.Core.Music.Commands;
|
||||
|
||||
|
@ -74,13 +72,7 @@ namespace NzbDrone.Core.Jobs
|
|||
{
|
||||
Interval = GetRssSyncInterval(),
|
||||
TypeName = typeof(RssSyncCommand).FullName
|
||||
},
|
||||
|
||||
new ScheduledTask
|
||||
{
|
||||
Interval = _configService.DownloadedAlbumsScanInterval,
|
||||
TypeName = typeof(DownloadedAlbumsScanCommand).FullName
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
var currentTasks = _scheduledTaskRepository.All().ToList();
|
||||
|
@ -144,10 +136,7 @@ namespace NzbDrone.Core.Jobs
|
|||
var rss = _scheduledTaskRepository.GetDefinition(typeof(RssSyncCommand));
|
||||
rss.Interval = _configService.RssSyncInterval;
|
||||
|
||||
var downloadedAlbums = _scheduledTaskRepository.GetDefinition(typeof(DownloadedAlbumsScanCommand));
|
||||
downloadedAlbums.Interval = _configService.DownloadedAlbumsScanInterval;
|
||||
|
||||
_scheduledTaskRepository.UpdateMany(new List<ScheduledTask> { rss, downloadedAlbums });
|
||||
_scheduledTaskRepository.Update(rss);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
|
@ -9,49 +9,28 @@ using NzbDrone.Core.Download.TrackedDownloads;
|
|||
using NzbDrone.Core.MediaFiles.Commands;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.MediaFiles.TrackImport;
|
||||
using NzbDrone.Common.Instrumentation.Extensions;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles
|
||||
{
|
||||
public class DownloadedAlbumsCommandService : IExecute<DownloadedAlbumsScanCommand>
|
||||
{
|
||||
private readonly IDownloadedEpisodesImportService _downloadedEpisodesImportService;
|
||||
private readonly IDownloadedTracksImportService _downloadedTracksImportService;
|
||||
private readonly ITrackedDownloadService _trackedDownloadService;
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
private readonly IConfigService _configService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public DownloadedAlbumsCommandService(IDownloadedEpisodesImportService downloadedEpisodesImportService,
|
||||
public DownloadedAlbumsCommandService(IDownloadedTracksImportService downloadedTracksImportService,
|
||||
ITrackedDownloadService trackedDownloadService,
|
||||
IDiskProvider diskProvider,
|
||||
IConfigService configService,
|
||||
Logger logger)
|
||||
{
|
||||
_downloadedEpisodesImportService = downloadedEpisodesImportService;
|
||||
_downloadedTracksImportService = downloadedTracksImportService;
|
||||
_trackedDownloadService = trackedDownloadService;
|
||||
_diskProvider = diskProvider;
|
||||
_configService = configService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
private List<ImportResult> ProcessDroneFactoryFolder()
|
||||
{
|
||||
var downloadedAlbumsFolder = _configService.DownloadedAlbumsFolder;
|
||||
|
||||
if (string.IsNullOrEmpty(downloadedAlbumsFolder))
|
||||
{
|
||||
_logger.Trace("Drone Factory folder is not configured");
|
||||
return new List<ImportResult>();
|
||||
}
|
||||
|
||||
if (!_diskProvider.FolderExists(downloadedAlbumsFolder))
|
||||
{
|
||||
_logger.Warn("Drone Factory folder [{0}] doesn't exist.", downloadedAlbumsFolder);
|
||||
return new List<ImportResult>();
|
||||
}
|
||||
|
||||
return _downloadedEpisodesImportService.ProcessRootFolder(new DirectoryInfo(downloadedAlbumsFolder));
|
||||
}
|
||||
|
||||
private List<ImportResult> ProcessPath(DownloadedAlbumsScanCommand message)
|
||||
{
|
||||
if (!_diskProvider.FolderExists(message.Path) && !_diskProvider.FileExists(message.Path))
|
||||
|
@ -68,17 +47,17 @@ namespace NzbDrone.Core.MediaFiles
|
|||
{
|
||||
_logger.Debug("External directory scan request for known download {0}. [{1}]", message.DownloadClientId, message.Path);
|
||||
|
||||
return _downloadedEpisodesImportService.ProcessPath(message.Path, message.ImportMode, trackedDownload.RemoteEpisode.Series, trackedDownload.DownloadItem);
|
||||
return _downloadedTracksImportService.ProcessPath(message.Path, message.ImportMode, trackedDownload.RemoteAlbum.Artist, trackedDownload.DownloadItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Warn("External directory scan request for unknown download {0}, attempting normal import. [{1}]", message.DownloadClientId, message.Path);
|
||||
|
||||
return _downloadedEpisodesImportService.ProcessPath(message.Path, message.ImportMode);
|
||||
return _downloadedTracksImportService.ProcessPath(message.Path, message.ImportMode);
|
||||
}
|
||||
}
|
||||
|
||||
return _downloadedEpisodesImportService.ProcessPath(message.Path, message.ImportMode);
|
||||
return _downloadedTracksImportService.ProcessPath(message.Path, message.ImportMode);
|
||||
}
|
||||
|
||||
public void Execute(DownloadedAlbumsScanCommand message)
|
||||
|
@ -91,7 +70,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
}
|
||||
else
|
||||
{
|
||||
importResults = ProcessDroneFactoryFolder();
|
||||
throw new ArgumentException("A path must be provided", "path");
|
||||
}
|
||||
|
||||
if (importResults == null || importResults.All(v => v.Result != ImportResultType.Imported))
|
||||
|
|
|
@ -1,270 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.MediaFiles.TrackImport;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles
|
||||
{
|
||||
public interface IDownloadedEpisodesImportService
|
||||
{
|
||||
List<ImportResult> ProcessRootFolder(DirectoryInfo directoryInfo);
|
||||
List<ImportResult> ProcessPath(string path, ImportMode importMode = ImportMode.Auto, Series series = null, DownloadClientItem downloadClientItem = null);
|
||||
bool ShouldDeleteFolder(DirectoryInfo directoryInfo, Series series);
|
||||
}
|
||||
|
||||
public class DownloadedEpisodesImportService : IDownloadedEpisodesImportService
|
||||
{
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
private readonly IDiskScanService _diskScanService;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly IParsingService _parsingService;
|
||||
private readonly IMakeImportDecision _importDecisionMaker;
|
||||
private readonly IImportApprovedEpisodes _importApprovedEpisodes;
|
||||
private readonly IDetectSample _detectSample;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public DownloadedEpisodesImportService(IDiskProvider diskProvider,
|
||||
IDiskScanService diskScanService,
|
||||
ISeriesService seriesService,
|
||||
IParsingService parsingService,
|
||||
IMakeImportDecision importDecisionMaker,
|
||||
IImportApprovedEpisodes importApprovedEpisodes,
|
||||
IDetectSample detectSample,
|
||||
Logger logger)
|
||||
{
|
||||
_diskProvider = diskProvider;
|
||||
_diskScanService = diskScanService;
|
||||
_seriesService = seriesService;
|
||||
_parsingService = parsingService;
|
||||
_importDecisionMaker = importDecisionMaker;
|
||||
_importApprovedEpisodes = importApprovedEpisodes;
|
||||
_detectSample = detectSample;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public List<ImportResult> ProcessRootFolder(DirectoryInfo directoryInfo)
|
||||
{
|
||||
var results = new List<ImportResult>();
|
||||
|
||||
foreach (var subFolder in _diskProvider.GetDirectories(directoryInfo.FullName))
|
||||
{
|
||||
var folderResults = ProcessFolder(new DirectoryInfo(subFolder), ImportMode.Auto, null);
|
||||
results.AddRange(folderResults);
|
||||
}
|
||||
|
||||
foreach (var videoFile in _diskScanService.GetNonAudioFiles(directoryInfo.FullName, false))
|
||||
{
|
||||
var fileResults = ProcessFile(new FileInfo(videoFile), ImportMode.Auto, null);
|
||||
results.AddRange(fileResults);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
public List<ImportResult> ProcessPath(string path, ImportMode importMode = ImportMode.Auto, Series series = null, DownloadClientItem downloadClientItem = null)
|
||||
{
|
||||
if (_diskProvider.FolderExists(path))
|
||||
{
|
||||
var directoryInfo = new DirectoryInfo(path);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
return ProcessFolder(directoryInfo, importMode, downloadClientItem);
|
||||
}
|
||||
|
||||
return ProcessFolder(directoryInfo, importMode, series, downloadClientItem);
|
||||
}
|
||||
|
||||
if (_diskProvider.FileExists(path))
|
||||
{
|
||||
var fileInfo = new FileInfo(path);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
return ProcessFile(fileInfo, importMode, downloadClientItem);
|
||||
}
|
||||
|
||||
return ProcessFile(fileInfo, importMode, series, downloadClientItem);
|
||||
}
|
||||
|
||||
_logger.Error("Import failed, path does not exist or is not accessible by Lidarr: {0}", path);
|
||||
return new List<ImportResult>();
|
||||
}
|
||||
|
||||
public bool ShouldDeleteFolder(DirectoryInfo directoryInfo, Series series)
|
||||
{
|
||||
var videoFiles = _diskScanService.GetNonAudioFiles(directoryInfo.FullName);
|
||||
var rarFiles = _diskProvider.GetFiles(directoryInfo.FullName, SearchOption.AllDirectories).Where(f => Path.GetExtension(f) == ".rar");
|
||||
|
||||
foreach (var videoFile in videoFiles)
|
||||
{
|
||||
var episodeParseResult = Parser.Parser.ParseTitle(Path.GetFileName(videoFile));
|
||||
|
||||
if (episodeParseResult == null)
|
||||
{
|
||||
_logger.Warn("Unable to parse file on import: [{0}]", videoFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
var size = _diskProvider.GetFileSize(videoFile);
|
||||
var quality = QualityParser.ParseQuality(videoFile);
|
||||
|
||||
if (!_detectSample.IsSample(series, quality, videoFile, size, episodeParseResult.IsPossibleSpecialEpisode))
|
||||
{
|
||||
_logger.Warn("Non-sample file detected: [{0}]", videoFile);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (rarFiles.Any(f => _diskProvider.GetFileSize(f) > 10.Megabytes()))
|
||||
{
|
||||
_logger.Warn("RAR file detected, will require manual cleanup");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private List<ImportResult> ProcessFolder(DirectoryInfo directoryInfo, ImportMode importMode, DownloadClientItem downloadClientItem)
|
||||
{
|
||||
var cleanedUpName = GetCleanedUpFolderName(directoryInfo.Name);
|
||||
var series = _parsingService.GetSeries(cleanedUpName);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
_logger.Debug("Unknown Series {0}", cleanedUpName);
|
||||
|
||||
return new List<ImportResult>
|
||||
{
|
||||
UnknownSeriesResult("Unknown Series")
|
||||
};
|
||||
}
|
||||
|
||||
return ProcessFolder(directoryInfo, importMode, series, downloadClientItem);
|
||||
}
|
||||
|
||||
private List<ImportResult> ProcessFolder(DirectoryInfo directoryInfo, ImportMode importMode, Series series, DownloadClientItem downloadClientItem)
|
||||
{
|
||||
throw new System.NotImplementedException("Will be removed");
|
||||
|
||||
//if (_seriesService.SeriesPathExists(directoryInfo.FullName))
|
||||
//{
|
||||
// _logger.Warn("Unable to process folder that is mapped to an existing show");
|
||||
// return new List<ImportResult>();
|
||||
//}
|
||||
|
||||
//var cleanedUpName = GetCleanedUpFolderName(directoryInfo.Name);
|
||||
//var folderInfo = Parser.Parser.ParseTitle(directoryInfo.Name);
|
||||
|
||||
//if (folderInfo != null)
|
||||
//{
|
||||
// _logger.Debug("{0} folder quality: {1}", cleanedUpName, folderInfo.Quality);
|
||||
//}
|
||||
|
||||
//var videoFiles = _diskScanService.GetVideoFiles(directoryInfo.FullName);
|
||||
|
||||
//if (downloadClientItem == null)
|
||||
//{
|
||||
// foreach (var videoFile in videoFiles)
|
||||
// {
|
||||
// if (_diskProvider.IsFileLocked(videoFile))
|
||||
// {
|
||||
// return new List<ImportResult>
|
||||
// {
|
||||
// FileIsLockedResult(videoFile)
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//var decisions = _importDecisionMaker.GetImportDecisions(videoFiles.ToList(), series, folderInfo, true);
|
||||
//var importResults = _importApprovedEpisodes.Import(decisions, true, downloadClientItem, importMode);
|
||||
|
||||
//if ((downloadClientItem == null || !downloadClientItem.IsReadOnly) &&
|
||||
// importResults.Any(i => i.Result == ImportResultType.Imported) &&
|
||||
// ShouldDeleteFolder(directoryInfo, series))
|
||||
//{
|
||||
// _logger.Debug("Deleting folder after importing valid files");
|
||||
// _diskProvider.DeleteFolder(directoryInfo.FullName, true);
|
||||
//}
|
||||
|
||||
//return importResults;
|
||||
}
|
||||
|
||||
private List<ImportResult> ProcessFile(FileInfo fileInfo, ImportMode importMode, DownloadClientItem downloadClientItem)
|
||||
{
|
||||
var series = _parsingService.GetSeries(Path.GetFileNameWithoutExtension(fileInfo.Name));
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
_logger.Debug("Unknown Series for file: {0}", fileInfo.Name);
|
||||
|
||||
return new List<ImportResult>
|
||||
{
|
||||
UnknownSeriesResult(string.Format("Unknown Series for file: {0}", fileInfo.Name), fileInfo.FullName)
|
||||
};
|
||||
}
|
||||
|
||||
return ProcessFile(fileInfo, importMode, series, downloadClientItem);
|
||||
}
|
||||
|
||||
private List<ImportResult> ProcessFile(FileInfo fileInfo, ImportMode importMode, Series series, DownloadClientItem downloadClientItem)
|
||||
{
|
||||
throw new System.NotImplementedException("Will be removed");
|
||||
//if (Path.GetFileNameWithoutExtension(fileInfo.Name).StartsWith("._"))
|
||||
//{
|
||||
// _logger.Debug("[{0}] starts with '._', skipping", fileInfo.FullName);
|
||||
|
||||
// return new List<ImportResult>
|
||||
// {
|
||||
// new ImportResult(new ImportDecision(new LocalTrack { Path = fileInfo.FullName }, new Rejection("Invalid music file, filename starts with '._'")), "Invalid music file, filename starts with '._'")
|
||||
// };
|
||||
//}
|
||||
|
||||
//if (downloadClientItem == null)
|
||||
//{
|
||||
// if (_diskProvider.IsFileLocked(fileInfo.FullName))
|
||||
// {
|
||||
// return new List<ImportResult>
|
||||
// {
|
||||
// FileIsLockedResult(fileInfo.FullName)
|
||||
// };
|
||||
// }
|
||||
//}
|
||||
|
||||
//var decisions = _importDecisionMaker.GetImportDecisions(new List<string>() { fileInfo.FullName }, series, null, true);
|
||||
|
||||
//return _importApprovedEpisodes.Import(decisions, true, downloadClientItem, importMode);
|
||||
}
|
||||
|
||||
private string GetCleanedUpFolderName(string folder)
|
||||
{
|
||||
folder = folder.Replace("_UNPACK_", "")
|
||||
.Replace("_FAILED_", "");
|
||||
|
||||
return folder;
|
||||
}
|
||||
|
||||
private ImportResult FileIsLockedResult(string videoFile)
|
||||
{
|
||||
throw new System.NotImplementedException("Will be removed");
|
||||
//_logger.Debug("[{0}] is currently locked by another process, skipping", videoFile);
|
||||
//return new ImportResult(new ImportDecision(new LocalEpisode { Path = videoFile }, new Rejection("Locked file, try again later")), "Locked file, try again later");
|
||||
}
|
||||
|
||||
private ImportResult UnknownSeriesResult(string message, string videoFile = null)
|
||||
{
|
||||
throw new System.NotImplementedException("Will be removed");
|
||||
//var localEpisode = videoFile == null ? null : new LocalEpisode { Path = videoFile };
|
||||
|
||||
//return new ImportResult(new ImportDecision(localEpisode, new Rejection("Unknown Series")), message);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,279 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.MediaFiles.TrackImport;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles
|
||||
{
|
||||
public interface IDownloadedTracksImportService
|
||||
{
|
||||
List<ImportResult> ProcessRootFolder(DirectoryInfo directoryInfo);
|
||||
List<ImportResult> ProcessPath(string path, ImportMode importMode = ImportMode.Auto, Artist artist = null, DownloadClientItem downloadClientItem = null);
|
||||
bool ShouldDeleteFolder(DirectoryInfo directoryInfo, Artist artist);
|
||||
}
|
||||
|
||||
public class DownloadedTracksImportService : IDownloadedTracksImportService
|
||||
{
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
private readonly IDiskScanService _diskScanService;
|
||||
private readonly IArtistService _artistService;
|
||||
private readonly IParsingService _parsingService;
|
||||
private readonly IMakeImportDecision _importDecisionMaker;
|
||||
private readonly IImportApprovedTracks _importApprovedTracks;
|
||||
private readonly IDetectSample _detectSample;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public DownloadedTracksImportService(IDiskProvider diskProvider,
|
||||
IDiskScanService diskScanService,
|
||||
IArtistService artistService,
|
||||
IParsingService parsingService,
|
||||
IMakeImportDecision importDecisionMaker,
|
||||
IImportApprovedTracks importApprovedTracks,
|
||||
IDetectSample detectSample,
|
||||
Logger logger)
|
||||
{
|
||||
_diskProvider = diskProvider;
|
||||
_diskScanService = diskScanService;
|
||||
_artistService = artistService;
|
||||
_parsingService = parsingService;
|
||||
_importDecisionMaker = importDecisionMaker;
|
||||
_importApprovedTracks = importApprovedTracks;
|
||||
_detectSample = detectSample;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public List<ImportResult> ProcessRootFolder(DirectoryInfo directoryInfo)
|
||||
{
|
||||
var results = new List<ImportResult>();
|
||||
|
||||
foreach (var subFolder in _diskProvider.GetDirectories(directoryInfo.FullName))
|
||||
{
|
||||
var folderResults = ProcessFolder(new DirectoryInfo(subFolder), ImportMode.Auto, null);
|
||||
results.AddRange(folderResults);
|
||||
}
|
||||
|
||||
foreach (var videoFile in _diskScanService.GetNonAudioFiles(directoryInfo.FullName, false))
|
||||
{
|
||||
var fileResults = ProcessFile(new FileInfo(videoFile), ImportMode.Auto, null);
|
||||
results.AddRange(fileResults);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
public List<ImportResult> ProcessPath(string path, ImportMode importMode = ImportMode.Auto, Artist artist = null, DownloadClientItem downloadClientItem = null)
|
||||
{
|
||||
if (_diskProvider.FolderExists(path))
|
||||
{
|
||||
var directoryInfo = new DirectoryInfo(path);
|
||||
|
||||
if (artist == null)
|
||||
{
|
||||
return ProcessFolder(directoryInfo, importMode, downloadClientItem);
|
||||
}
|
||||
|
||||
return ProcessFolder(directoryInfo, importMode, artist, downloadClientItem);
|
||||
}
|
||||
|
||||
if (_diskProvider.FileExists(path))
|
||||
{
|
||||
var fileInfo = new FileInfo(path);
|
||||
|
||||
if (artist == null)
|
||||
{
|
||||
return ProcessFile(fileInfo, importMode, downloadClientItem);
|
||||
}
|
||||
|
||||
return ProcessFile(fileInfo, importMode, artist, downloadClientItem);
|
||||
}
|
||||
|
||||
_logger.Error("Import failed, path does not exist or is not accessible by Lidarr: {0}", path);
|
||||
return new List<ImportResult>();
|
||||
}
|
||||
|
||||
public bool ShouldDeleteFolder(DirectoryInfo directoryInfo, Artist artist)
|
||||
{
|
||||
var audioFiles = _diskScanService.GetNonAudioFiles(directoryInfo.FullName);
|
||||
var rarFiles = _diskProvider.GetFiles(directoryInfo.FullName, SearchOption.AllDirectories).Where(f => Path.GetExtension(f) == ".rar");
|
||||
|
||||
foreach (var audioFile in audioFiles)
|
||||
{
|
||||
var albumParseResult = Parser.Parser.ParseMusicTitle(Path.GetFileName(audioFile));
|
||||
|
||||
if (albumParseResult == null)
|
||||
{
|
||||
_logger.Warn("Unable to parse file on import: [{0}]", audioFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
var size = _diskProvider.GetFileSize(audioFile);
|
||||
var quality = QualityParser.ParseQuality(audioFile);
|
||||
|
||||
//if (!_detectSample.IsSample(artist, quality, audioFile, size, albumParseResult.IsPossibleSpecialEpisode))
|
||||
//{
|
||||
// _logger.Warn("Non-sample file detected: [{0}]", audioFile);
|
||||
// return false;
|
||||
//}
|
||||
}
|
||||
|
||||
if (rarFiles.Any(f => _diskProvider.GetFileSize(f) > 10.Megabytes()))
|
||||
{
|
||||
_logger.Warn("RAR file detected, will require manual cleanup");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private List<ImportResult> ProcessFolder(DirectoryInfo directoryInfo, ImportMode importMode, DownloadClientItem downloadClientItem)
|
||||
{
|
||||
var cleanedUpName = GetCleanedUpFolderName(directoryInfo.Name);
|
||||
|
||||
var files = _diskScanService.GetAudioFiles(directoryInfo.FullName);
|
||||
var artist = _parsingService.GetArtist(files.First());
|
||||
|
||||
if (artist == null)
|
||||
{
|
||||
_logger.Debug("Unknown Artist {0}", cleanedUpName);
|
||||
|
||||
return new List<ImportResult>
|
||||
{
|
||||
UnknownArtistResult("Unknown Artist")
|
||||
};
|
||||
}
|
||||
|
||||
return ProcessFolder(directoryInfo, importMode, artist, downloadClientItem);
|
||||
}
|
||||
|
||||
private List<ImportResult> ProcessFolder(DirectoryInfo directoryInfo, ImportMode importMode, Artist artist, DownloadClientItem downloadClientItem)
|
||||
{
|
||||
if (_artistService.ArtistPathExists(directoryInfo.FullName))
|
||||
{
|
||||
_logger.Warn("Unable to process folder that is mapped to an existing artist");
|
||||
return new List<ImportResult>();
|
||||
}
|
||||
|
||||
var cleanedUpName = GetCleanedUpFolderName(directoryInfo.Name);
|
||||
var folderInfo = Parser.Parser.ParseAlbumTitle(directoryInfo.Name);
|
||||
var trackInfo = new ParsedTrackInfo { };
|
||||
|
||||
if (folderInfo != null)
|
||||
{
|
||||
_logger.Debug("{0} folder quality: {1}", cleanedUpName, folderInfo.Quality);
|
||||
|
||||
trackInfo = new ParsedTrackInfo
|
||||
{
|
||||
AlbumTitle = folderInfo.AlbumTitle,
|
||||
ArtistTitle = folderInfo.ArtistName,
|
||||
Quality = folderInfo.Quality,
|
||||
ReleaseGroup = folderInfo.ReleaseGroup,
|
||||
ReleaseHash = folderInfo.ReleaseHash,
|
||||
};
|
||||
}
|
||||
|
||||
var audioFiles = _diskScanService.GetAudioFiles(directoryInfo.FullName);
|
||||
|
||||
if (downloadClientItem == null)
|
||||
{
|
||||
foreach (var audioFile in audioFiles)
|
||||
{
|
||||
if (_diskProvider.IsFileLocked(audioFile))
|
||||
{
|
||||
return new List<ImportResult>
|
||||
{
|
||||
FileIsLockedResult(audioFile)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var decisions = _importDecisionMaker.GetImportDecisions(audioFiles.ToList(), artist, trackInfo);
|
||||
var importResults = _importApprovedTracks.Import(decisions, true, downloadClientItem, importMode);
|
||||
|
||||
if ((downloadClientItem == null || !downloadClientItem.IsReadOnly) &&
|
||||
importResults.Any(i => i.Result == ImportResultType.Imported) &&
|
||||
ShouldDeleteFolder(directoryInfo, artist))
|
||||
{
|
||||
_logger.Debug("Deleting folder after importing valid files");
|
||||
_diskProvider.DeleteFolder(directoryInfo.FullName, true);
|
||||
}
|
||||
|
||||
return importResults;
|
||||
}
|
||||
|
||||
private List<ImportResult> ProcessFile(FileInfo fileInfo, ImportMode importMode, DownloadClientItem downloadClientItem)
|
||||
{
|
||||
var artist = _parsingService.GetArtist(Path.GetFileNameWithoutExtension(fileInfo.Name));
|
||||
|
||||
if (artist == null)
|
||||
{
|
||||
_logger.Debug("Unknown Artist for file: {0}", fileInfo.Name);
|
||||
|
||||
return new List<ImportResult>
|
||||
{
|
||||
UnknownArtistResult(string.Format("Unknown Artist for file: {0}", fileInfo.Name), fileInfo.FullName)
|
||||
};
|
||||
}
|
||||
|
||||
return ProcessFile(fileInfo, importMode, artist, downloadClientItem);
|
||||
}
|
||||
|
||||
private List<ImportResult> ProcessFile(FileInfo fileInfo, ImportMode importMode, Artist artist, DownloadClientItem downloadClientItem)
|
||||
{
|
||||
if (Path.GetFileNameWithoutExtension(fileInfo.Name).StartsWith("._"))
|
||||
{
|
||||
_logger.Debug("[{0}] starts with '._', skipping", fileInfo.FullName);
|
||||
|
||||
return new List<ImportResult>
|
||||
{
|
||||
new ImportResult(new ImportDecision(new LocalTrack { Path = fileInfo.FullName }, new Rejection("Invalid music file, filename starts with '._'")), "Invalid music file, filename starts with '._'")
|
||||
};
|
||||
}
|
||||
|
||||
if (downloadClientItem == null)
|
||||
{
|
||||
if (_diskProvider.IsFileLocked(fileInfo.FullName))
|
||||
{
|
||||
return new List<ImportResult>
|
||||
{
|
||||
FileIsLockedResult(fileInfo.FullName)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
var decisions = _importDecisionMaker.GetImportDecisions(new List<string>() { fileInfo.FullName }, artist, null);
|
||||
|
||||
return _importApprovedTracks.Import(decisions, true, downloadClientItem, importMode);
|
||||
}
|
||||
|
||||
private string GetCleanedUpFolderName(string folder)
|
||||
{
|
||||
folder = folder.Replace("_UNPACK_", "")
|
||||
.Replace("_FAILED_", "");
|
||||
|
||||
return folder;
|
||||
}
|
||||
|
||||
private ImportResult FileIsLockedResult(string audioFile)
|
||||
{
|
||||
_logger.Debug("[{0}] is currently locked by another process, skipping", audioFile);
|
||||
return new ImportResult(new ImportDecision(new LocalTrack { Path = audioFile }, new Rejection("Locked file, try again later")), "Locked file, try again later");
|
||||
}
|
||||
|
||||
private ImportResult UnknownArtistResult(string message, string audioFile = null)
|
||||
{
|
||||
var localTrack = audioFile == null ? null : new LocalTrack { Path = audioFile };
|
||||
|
||||
return new ImportResult(new ImportDecision(localTrack, new Rejection("Unknown Artist")), message);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual
|
|||
private readonly IVideoFileInfoReader _videoFileInfoReader;
|
||||
private readonly IImportApprovedTracks _importApprovedTracks;
|
||||
private readonly ITrackedDownloadService _trackedDownloadService;
|
||||
private readonly IDownloadedEpisodesImportService _downloadedEpisodesImportService;
|
||||
private readonly IDownloadedTracksImportService _downloadedEpisodesImportService;
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
private readonly Logger _logger;
|
||||
|
||||
|
@ -49,7 +49,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual
|
|||
IVideoFileInfoReader videoFileInfoReader,
|
||||
IImportApprovedTracks importApprovedTracks,
|
||||
ITrackedDownloadService trackedDownloadService,
|
||||
IDownloadedEpisodesImportService downloadedEpisodesImportService,
|
||||
IDownloadedTracksImportService downloadedEpisodesImportService,
|
||||
IEventAggregator eventAggregator,
|
||||
Logger logger)
|
||||
{
|
||||
|
@ -258,7 +258,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual
|
|||
{
|
||||
if (_downloadedEpisodesImportService.ShouldDeleteFolder(
|
||||
new DirectoryInfo(trackedDownload.DownloadItem.OutputPath.FullPath),
|
||||
trackedDownload.RemoteEpisode.Series) && !trackedDownload.DownloadItem.IsReadOnly)
|
||||
trackedDownload.RemoteAlbum.Artist) && !trackedDownload.DownloadItem.IsReadOnly)
|
||||
{
|
||||
_diskProvider.DeleteFolder(trackedDownload.DownloadItem.OutputPath.FullPath, true);
|
||||
}
|
||||
|
|
|
@ -571,7 +571,6 @@
|
|||
<Compile Include="HealthCheck\CheckHealthCommand.cs" />
|
||||
<Compile Include="HealthCheck\Checks\AppDataLocationCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\DownloadClientCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\DroneFactoryCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\ImportMechanismCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\IndexerRssCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\IndexerStatusCheck.cs" />
|
||||
|
@ -748,7 +747,7 @@
|
|||
<Compile Include="MediaFiles\DiskScanService.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MediaFiles\DownloadedEpisodesImportService.cs">
|
||||
<Compile Include="MediaFiles\DownloadedTracksImportService.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MediaFiles\DownloadedAlbumsCommandService.cs" />
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
@ -107,11 +107,6 @@ namespace NzbDrone.Core.RootFolders
|
|||
throw new InvalidOperationException("Recent directory already exists.");
|
||||
}
|
||||
|
||||
if (_configService.DownloadedAlbumsFolder.IsNotNullOrWhiteSpace() && _configService.DownloadedAlbumsFolder.PathEquals(rootFolder.Path))
|
||||
{
|
||||
throw new InvalidOperationException("Drone Factory folder cannot be used.");
|
||||
}
|
||||
|
||||
if (!_diskProvider.FolderWritable(rootFolder.Path))
|
||||
{
|
||||
throw new UnauthorizedAccessException(string.Format("Root folder path '{0}' is not writable by user '{1}'", rootFolder.Path, Environment.UserName));
|
||||
|
@ -171,4 +166,4 @@ namespace NzbDrone.Core.RootFolders
|
|||
return rootFolder;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue