mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-26 17:47:08 +00:00
Fixed: Import of single-file anime torrents.
This commit is contained in:
parent
2b6c915e32
commit
dc2c1f7928
2 changed files with 57 additions and 7 deletions
|
@ -255,6 +255,53 @@ public void should_not_delete_if_there_is_large_rar_file()
|
|||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_use_folder_if_folder_import()
|
||||
{
|
||||
GivenValidSeries();
|
||||
|
||||
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();
|
||||
|
||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists(folderName))
|
||||
.Returns(true);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.GetFiles(folderName, SearchOption.TopDirectoryOnly))
|
||||
.Returns(new[] { fileName });
|
||||
|
||||
var localEpisode = new LocalEpisode();
|
||||
|
||||
var imported = new List<ImportDecision>();
|
||||
imported.Add(new ImportDecision(localEpisode));
|
||||
|
||||
|
||||
var result = Subject.ProcessPath(fileName);
|
||||
|
||||
Mocker.GetMock<IMakeImportDecision>()
|
||||
.Verify(s => s.GetImportDecisions(It.IsAny<List<String>>(), It.IsAny<Series>(), It.Is<ParsedEpisodeInfo>(v => v.AbsoluteEpisodeNumbers.First() == 9), true), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_use_folder_if_file_import()
|
||||
{
|
||||
GivenValidSeries();
|
||||
|
||||
var fileName = @"C:\media\ba09030e-1234-1234-1234-123456789abc\Torrents\[HorribleSubs] Maria the Virgin Witch - 09 [720p].mkv".AsOsAgnostic();
|
||||
|
||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists(fileName))
|
||||
.Returns(false);
|
||||
|
||||
var localEpisode = new LocalEpisode();
|
||||
|
||||
var imported = new List<ImportDecision>();
|
||||
imported.Add(new ImportDecision(localEpisode));
|
||||
|
||||
var result = Subject.ProcessPath(fileName);
|
||||
|
||||
Mocker.GetMock<IMakeImportDecision>()
|
||||
.Verify(s => s.GetImportDecisions(It.IsAny<List<String>>(), It.IsAny<Series>(), null, true), Times.Once());
|
||||
}
|
||||
|
||||
private void VerifyNoImport()
|
||||
{
|
||||
Mocker.GetMock<IImportApprovedEpisodes>().Verify(c => c.Import(It.IsAny<List<ImportDecision>>(), true, null),
|
||||
|
|
|
@ -72,20 +72,24 @@ public List<ImportResult> ProcessPath(string path, Series series = null, Downloa
|
|||
{
|
||||
if (_diskProvider.FolderExists(path))
|
||||
{
|
||||
var directoryInfo = new DirectoryInfo(path);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
return ProcessFolder(new DirectoryInfo(path), downloadClientItem);
|
||||
return ProcessFolder(directoryInfo, downloadClientItem);
|
||||
}
|
||||
|
||||
return ProcessFolder(new DirectoryInfo(path), series, downloadClientItem);
|
||||
return ProcessFolder(directoryInfo, series, downloadClientItem);
|
||||
}
|
||||
|
||||
var fileInfo = new FileInfo(path);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
return ProcessFile(new FileInfo(path), downloadClientItem);
|
||||
return ProcessFile(fileInfo, downloadClientItem);
|
||||
}
|
||||
|
||||
return ProcessFile(new FileInfo(path), series, downloadClientItem);
|
||||
return ProcessFile(fileInfo, series, downloadClientItem);
|
||||
}
|
||||
|
||||
private List<ImportResult> ProcessFolder(DirectoryInfo directoryInfo, DownloadClientItem downloadClientItem = null)
|
||||
|
@ -120,7 +124,7 @@ private List<ImportResult> ProcessFolder(DirectoryInfo directoryInfo, Series ser
|
|||
|
||||
if (folderInfo != null)
|
||||
{
|
||||
_logger.Debug("{0} folder quality: {1}", cleanedUpName, folderInfo.Quality);
|
||||
_logger.Debug("{0} folder quality: {1}", cleanedUpName, folderInfo.Quality);
|
||||
}
|
||||
|
||||
var videoFiles = _diskScanService.GetVideoFiles(directoryInfo.FullName);
|
||||
|
@ -181,8 +185,7 @@ private List<ImportResult> ProcessFile(FileInfo fileInfo, Series series, Downloa
|
|||
}
|
||||
}
|
||||
|
||||
var folderInfo = Parser.Parser.ParseTitle(fileInfo.DirectoryName);
|
||||
var decisions = _importDecisionMaker.GetImportDecisions(new List<string>() { fileInfo.FullName }, series, folderInfo, true);
|
||||
var decisions = _importDecisionMaker.GetImportDecisions(new List<string>() { fileInfo.FullName }, series, null, true);
|
||||
|
||||
return _importApprovedEpisodes.Import(decisions, true, downloadClientItem);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue