From 45fde370d802564a0012a7b6c443a0018cac4aaa Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Tue, 17 May 2011 20:10:39 -0700 Subject: [PATCH] Removed post processor from solution --- NzbDrone.Core/CentralDispatch.cs | 1 - NzbDrone.Core/NzbDrone.Core.csproj | 1 - NzbDrone.Core/Providers/MediaFileProvider.cs | 43 ++++--------------- .../Providers/PostProcessingProvider.cs | 35 --------------- NzbDrone.Web/Controllers/ApiController.cs | 37 ---------------- NzbDrone.Web/Controllers/SeriesController.cs | 7 ++- NzbDrone.Web/NzbDrone.Web.csproj | 1 - NzbDrone.sln | 13 ------ 8 files changed, 12 insertions(+), 126 deletions(-) delete mode 100644 NzbDrone.Core/Providers/PostProcessingProvider.cs delete mode 100644 NzbDrone.Web/Controllers/ApiController.cs diff --git a/NzbDrone.Core/CentralDispatch.cs b/NzbDrone.Core/CentralDispatch.cs index daee295a2..73c0cf34a 100644 --- a/NzbDrone.Core/CentralDispatch.cs +++ b/NzbDrone.Core/CentralDispatch.cs @@ -90,7 +90,6 @@ namespace NzbDrone.Core _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); - _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().To().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 8fc58d7c9..9d844f434 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -203,7 +203,6 @@ - diff --git a/NzbDrone.Core/Providers/MediaFileProvider.cs b/NzbDrone.Core/Providers/MediaFileProvider.cs index 4ddb5de1a..a9816e527 100644 --- a/NzbDrone.Core/Providers/MediaFileProvider.cs +++ b/NzbDrone.Core/Providers/MediaFileProvider.cs @@ -25,9 +25,7 @@ namespace NzbDrone.Core.Providers _episodeProvider = episodeProvider; } - public MediaFileProvider() - { - } + public MediaFileProvider() { } /// /// Scans the specified series folder for media files @@ -47,24 +45,6 @@ namespace NzbDrone.Core.Providers return fileList; } - /// - /// Scans the specified series folder for media files - /// - /// The series to be scanned - public List Scan(Series series, string path) - { - var mediaFileList = GetMediaFileList(path); - var fileList = new List(); - - foreach (var filePath in mediaFileList) - { - var file = ImportFile(series, filePath); - if (file != null) - fileList.Add(file); - } - return fileList; - } - public EpisodeFile ImportFile(Series series, string filePath) { Logger.Trace("Importing file to database [{0}]", filePath); @@ -76,10 +56,11 @@ namespace NzbDrone.Core.Providers //If Size is less than 50MB and contains sample. Check for Size to ensure its not an episode with sample in the title if (size < 40000000 && filePath.ToLower().Contains("sample")) { - Logger.Trace("[{0}] appears to be a sample... skipping.", filePath); + Logger.Trace("[{0}] appears to be a sample. skipping.", filePath); return null; } + //Check to see if file already exists in the database if (!_repository.Exists(e => e.Path == Parser.NormalizePath(filePath))) { var parseResult = Parser.ParseEpisodeInfo(filePath); @@ -90,6 +71,7 @@ namespace NzbDrone.Core.Providers //Stores the list of episodes to add to the EpisodeFile var episodes = new List(); + //Check for daily shows if (parseResult.Episodes == null) { var episode = _episodeProvider.GetEpisode(series.SeriesId, parseResult.AirDate.Date); @@ -98,9 +80,10 @@ namespace NzbDrone.Core.Providers { episodes.Add(episode); } - else + { Logger.Warn("Unable to find '{0}' in the database. File:{1}", parseResult, filePath); + } } else { @@ -113,14 +96,15 @@ namespace NzbDrone.Core.Providers { episodes.Add(episode); } - else + { Logger.Warn("Unable to find '{0}' in the database. File:{1}", parseResult, filePath); + } } } //Return null if no Episodes exist in the DB for the parsed episodes from file - if (episodes.Count < 1) + if (episodes.Count <= 0) return null; var episodeFile = new EpisodeFile(); @@ -173,16 +157,7 @@ namespace NzbDrone.Core.Providers } } - public void DeleteFromDb(int fileId) - { - _repository.Delete(fileId); - } - public void DeleteFromDisk(int fileId, string path) - { - _diskProvider.DeleteFile(path); - _repository.Delete(fileId); - } public void Update(EpisodeFile episodeFile) { diff --git a/NzbDrone.Core/Providers/PostProcessingProvider.cs b/NzbDrone.Core/Providers/PostProcessingProvider.cs deleted file mode 100644 index 1ffe45f74..000000000 --- a/NzbDrone.Core/Providers/PostProcessingProvider.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace NzbDrone.Core.Providers -{ - public class PostProcessingProvider - { - private readonly MediaFileProvider _mediaFileProvider; - private readonly RenameProvider _renameProvider; - private readonly SeriesProvider _seriesProvider; - - public PostProcessingProvider(SeriesProvider seriesProvider, - MediaFileProvider mediaFileProvider, RenameProvider renameProvider) - { - _seriesProvider = seriesProvider; - _mediaFileProvider = mediaFileProvider; - _renameProvider = renameProvider; - } - - public virtual void ProcessEpisode(string dir, string nzbName) - { - var parsedSeries = Parser.ParseSeriesName(nzbName); - var series = _seriesProvider.FindSeries(parsedSeries); - - if (series == null) - return; - - //Import the files, and then rename the newly added ones. - var fileList = _mediaFileProvider.Scan(series, dir); - - foreach (var file in fileList) - { - //Notifications will be sent from the Renamer, depending on the bool NewDownload (which will be set to true from here), a normal rename will be treated as such. - _renameProvider.RenameEpisodeFile(file.EpisodeFileId, true); - } - } - } -} \ No newline at end of file diff --git a/NzbDrone.Web/Controllers/ApiController.cs b/NzbDrone.Web/Controllers/ApiController.cs deleted file mode 100644 index 5baade17c..000000000 --- a/NzbDrone.Web/Controllers/ApiController.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Web.Mvc; -using NLog; -using NzbDrone.Core.Providers; -using NzbDrone.Core.Providers.Core; - -namespace NzbDrone.Web.Controllers -{ - public class ApiController : Controller - { - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - private readonly ConfigProvider _configProvider; - private readonly PostProcessingProvider _postProcessingProvider; - - public ApiController(PostProcessingProvider postProcessingProvider, ConfigProvider configProvider) - { - _postProcessingProvider = postProcessingProvider; - _configProvider = configProvider; - } - - public ActionResult ProcessEpisode(string apiKey, string dir, string nzbName, string category) - { - if (apiKey != _configProvider.ApiKey) - { - Logger.Warn("API Key from Post Processing Script is Invalid"); - return Content("Invalid API Key"); - } - - if (_configProvider.SabTvCategory == category) - { - _postProcessingProvider.ProcessEpisode(dir, nzbName); - return Content("ok"); - } - - return Content("Category doesn't match what was configured for SAB TV Category..."); - } - } -} \ No newline at end of file diff --git a/NzbDrone.Web/Controllers/SeriesController.cs b/NzbDrone.Web/Controllers/SeriesController.cs index 80ba05d0f..0f716c715 100644 --- a/NzbDrone.Web/Controllers/SeriesController.cs +++ b/NzbDrone.Web/Controllers/SeriesController.cs @@ -76,7 +76,7 @@ namespace NzbDrone.Web.Controllers SeasonNumber = s.SeasonNumber, SeasonString = GetSeasonString(s.SeasonNumber), Monitored = s.Monitored - }).OrderBy(s=> s.SeasonNumber).ToList(); + }).OrderBy(s => s.SeasonNumber).ToList(); return View(model); } @@ -120,7 +120,7 @@ namespace NzbDrone.Web.Controllers //Start removing this series _jobProvider.QueueJob(typeof(DeleteSeriesJob), id); - + var series = GetSeriesModels(seriesInDb); return View(new GridModel(series)); } @@ -265,8 +265,7 @@ namespace NzbDrone.Web.Controllers public ActionResult SyncEpisodesOnDisk(int seriesId) { //Syncs the episodes on disk for the specified series - var series = _seriesProvider.GetSeries(seriesId); - _mediaFileProvider.Scan(series); + _jobProvider.QueueJob(typeof(MediaFileScanJob), seriesId); return RedirectToAction("Details", new { seriesId }); } diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 8da9302c7..a665f8c5c 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -214,7 +214,6 @@ True UploadLocalization.en-US.resx - diff --git a/NzbDrone.sln b/NzbDrone.sln index 16b90b117..5f2f23734 100644 --- a/NzbDrone.sln +++ b/NzbDrone.sln @@ -11,8 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NzbDrone.Core.Test", "NzbDr EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{57A04B72-8088-4F75-A582-1158CF8291F7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NzbDrone.PostProcessor", "NzbDrone.PostProcessor\NzbDrone.PostProcessor.csproj", "{0C679573-736D-4F77-B934-FD8931AC1AA1}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -79,17 +77,6 @@ Global {193ADD3B-792B-4173-8E4C-5A3F8F0237F0}.Release|Mixed Platforms.Build.0 = Release|Any CPU {193ADD3B-792B-4173-8E4C-5A3F8F0237F0}.Release|x64.ActiveCfg = Release|Any CPU {193ADD3B-792B-4173-8E4C-5A3F8F0237F0}.Release|x86.ActiveCfg = Release|Any CPU - {0C679573-736D-4F77-B934-FD8931AC1AA1}.Debug|Any CPU.ActiveCfg = Debug|x86 - {0C679573-736D-4F77-B934-FD8931AC1AA1}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {0C679573-736D-4F77-B934-FD8931AC1AA1}.Debug|x64.ActiveCfg = Debug|x86 - {0C679573-736D-4F77-B934-FD8931AC1AA1}.Debug|x86.ActiveCfg = Debug|x86 - {0C679573-736D-4F77-B934-FD8931AC1AA1}.Debug|x86.Build.0 = Debug|x86 - {0C679573-736D-4F77-B934-FD8931AC1AA1}.Release|Any CPU.ActiveCfg = Release|x86 - {0C679573-736D-4F77-B934-FD8931AC1AA1}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {0C679573-736D-4F77-B934-FD8931AC1AA1}.Release|Mixed Platforms.Build.0 = Release|x86 - {0C679573-736D-4F77-B934-FD8931AC1AA1}.Release|x64.ActiveCfg = Release|x86 - {0C679573-736D-4F77-B934-FD8931AC1AA1}.Release|x86.ActiveCfg = Release|x86 - {0C679573-736D-4F77-B934-FD8931AC1AA1}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE