Cleanup ParsingService

pull/8422/head
Qstick 1 year ago
parent c3f30fb237
commit a03323703a

@ -32,8 +32,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[SetUp]
public void Setup()
{
ParseMovieTitle();
_pass1 = new Mock<IDecisionEngineSpecification>();
_pass2 = new Mock<IDecisionEngineSpecification>();
_pass3 = new Mock<IDecisionEngineSpecification>();

@ -58,8 +58,6 @@ namespace NzbDrone.Core.Test.Download.TrackedDownloads
.Setup(s => s.Map(It.Is<ParsedMovieInfo>(i => i.PrimaryMovieTitle == "A Movie"), It.IsAny<string>(), null))
.Returns(remoteMovie);
ParseMovieTitle();
var client = new DownloadClientDefinition()
{
Id = 1,
@ -110,8 +108,6 @@ namespace NzbDrone.Core.Test.Download.TrackedDownloads
.Setup(s => s.FindByDownloadId(It.IsAny<string>()))
.Returns(new List<MovieHistory>());
ParseMovieTitle();
var client = new DownloadClientDefinition()
{
Id = 1,
@ -169,8 +165,6 @@ namespace NzbDrone.Core.Test.Download.TrackedDownloads
.Setup(s => s.FindByDownloadId(It.IsAny<string>()))
.Returns(new List<MovieHistory>());
ParseMovieTitle();
var client = new DownloadClientDefinition()
{
Id = 1,

@ -31,28 +31,6 @@ namespace NzbDrone.Core.Test.Framework
Mocker.SetConstant<IHttpClient>(new HttpClient(Array.Empty<IHttpRequestInterceptor>(), Mocker.Resolve<CacheManager>(), Mocker.Resolve<RateLimitService>(), Mocker.Resolve<IHttpDispatcher>(), TestLogger));
Mocker.SetConstant<IRadarrCloudRequestBuilder>(new RadarrCloudRequestBuilder());
}
// Used for tests that rely on parsing working correctly.
protected void UseRealParsingService()
{
// Mocker.SetConstant<IParsingService>(new ParsingService(Mocker.Resolve<MovieService>(), Mocker.Resolve<ConfigService>(), Mocker.Resolve<QualityDefinitionService>(), TestLogger));
}
// Used for tests that rely on parsing working correctly. Does some minimal parsing using the old static methods.
protected void ParseMovieTitle()
{
Mocker.GetMock<IParsingService>().Setup(c => c.ParseMovieInfo(It.IsAny<string>(), It.IsAny<System.Collections.Generic.List<object>>()))
.Returns<string, System.Collections.Generic.List<object>>((title, helpers) =>
{
var result = Parser.Parser.ParseMovieTitle(title);
if (result != null)
{
result.Quality = QualityParser.ParseQuality(title);
}
return result;
});
}
}
public abstract class CoreTest<TSubject> : CoreTest

@ -30,9 +30,6 @@ namespace NzbDrone.Core.Test.MediaFiles
[SetUp]
public void Setup()
{
ParseMovieTitle();
// UseRealParsingService();
Mocker.GetMock<IDiskScanService>().Setup(c => c.GetVideoFiles(It.IsAny<string>(), It.IsAny<bool>()))
.Returns(_videoFiles);

@ -76,7 +76,7 @@ namespace NzbDrone.Core.DecisionEngine
try
{
var parsedMovieInfo = _parsingService.ParseMovieInfo(report.Title, new List<object> { report });
var parsedMovieInfo = Parser.Parser.ParseMovieTitle(report.Title);
if (parsedMovieInfo != null && !parsedMovieInfo.PrimaryMovieTitle.IsNullOrWhiteSpace())
{

@ -118,7 +118,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads
var grabbedHistoryItem = historyItems.FirstOrDefault(h => h.EventType == MovieHistoryEventType.Grabbed);
// TODO: Create release info from history and use that here, so we don't loose indexer flags!
var parsedMovieInfo = _parsingService.ParseMovieInfo(trackedDownload.DownloadItem.Title, new List<object> { grabbedHistoryItem });
var parsedMovieInfo = Parser.Parser.ParseMovieTitle(trackedDownload.DownloadItem.Title);
if (parsedMovieInfo != null)
{

@ -193,7 +193,7 @@ namespace NzbDrone.Core.MediaFiles
var cleanedUpName = GetCleanedUpFolderName(directoryInfo.Name);
var historyItems = _historyService.FindByDownloadId(downloadClientItem?.DownloadId ?? "");
var firstHistoryItem = historyItems?.OrderByDescending(h => h.Date).FirstOrDefault();
var folderInfo = _parsingService.ParseMovieInfo(cleanedUpName, new List<object> { firstHistoryItem });
var folderInfo = Parser.Parser.ParseMovieTitle(cleanedUpName);
if (folderInfo != null)
{

@ -15,8 +15,6 @@ namespace NzbDrone.Core.Parser
Movie GetMovie(string title);
RemoteMovie Map(ParsedMovieInfo parsedMovieInfo, string imdbId, SearchCriteriaBase searchCriteria = null);
RemoteMovie Map(ParsedMovieInfo parsedMovieInfo, int movieId);
ParsedMovieInfo ParseMovieInfo(string title, List<object> helpers);
ParsedMovieInfo ParseMinimalMovieInfo(string path, bool isDir = false);
ParsedMovieInfo ParseMinimalPathMovieInfo(string path);
}
@ -39,39 +37,22 @@ namespace NzbDrone.Core.Parser
}
}
public ParsedMovieInfo ParseMovieInfo(string title, List<object> helpers)
{
var result = Parser.ParseMovieTitle(title);
if (result == null)
{
return null;
}
return result;
}
public ParsedMovieInfo ParseMinimalMovieInfo(string file, bool isDir = false)
{
return Parser.ParseMovieTitle(file, isDir);
}
public ParsedMovieInfo ParseMinimalPathMovieInfo(string path)
{
var fileInfo = new FileInfo(path);
var result = ParseMinimalMovieInfo(fileInfo.Name, true);
var result = Parser.ParseMovieTitle(fileInfo.Name, true);
if (result == null)
{
_logger.Debug("Attempting to parse movie info using directory and file names. {0}", fileInfo.Directory.Name);
result = ParseMinimalMovieInfo(fileInfo.Directory.Name + " " + fileInfo.Name);
result = Parser.ParseMovieTitle(fileInfo.Directory.Name + " " + fileInfo.Name);
}
if (result == null)
{
_logger.Debug("Attempting to parse movie info using directory name. {0}", fileInfo.Directory.Name);
result = ParseMinimalMovieInfo(fileInfo.Directory.Name + fileInfo.Extension);
result = Parser.ParseMovieTitle(fileInfo.Directory.Name + fileInfo.Extension);
}
return result;

@ -33,7 +33,7 @@ namespace Radarr.Api.V3.Parse
return null;
}
var parsedMovieInfo = _parsingService.ParseMovieInfo(title, new List<object>());
var parsedMovieInfo = Parser.ParseMovieTitle(title);
if (parsedMovieInfo == null)
{

Loading…
Cancel
Save