diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs index 5b6d756cc..b36c44c5f 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs @@ -44,6 +44,21 @@ protected override string AddFromNzbFile(RemoteEpisode remoteEpisode, string fil return response; } + protected override string AddFromNzbFile(RemoteMovie remoteMovie, string filename, byte[] fileContents) + { + var category = Settings.TvCategory; //could update this to MovieCategory + var priority = Settings.RecentTvPriority; + + var response = _proxy.DownloadNzb(fileContents, filename, category, priority, Settings); + + if(response == null) + { + throw new DownloadClientException("Failed to add nzb {0}", filename); + } + + return response; + } + private IEnumerable GetQueue() { NzbgetGlobalStatus globalStatus; @@ -72,13 +87,14 @@ private IEnumerable GetQueue() var droneParameter = item.Parameters.SingleOrDefault(p => p.Name == "drone"); - var queueItem = new DownloadClientItem(); - queueItem.DownloadId = droneParameter == null ? item.NzbId.ToString() : droneParameter.Value.ToString(); - queueItem.Title = item.NzbName; - queueItem.TotalSize = totalSize; - queueItem.Category = item.Category; - queueItem.DownloadClient = Definition.Name; - + var queueItem = new DownloadClientItem() + { + DownloadId = droneParameter == null ? item.NzbId.ToString() : droneParameter.Value.ToString(), + Title = item.NzbName, + TotalSize = totalSize, + Category = item.Category, + DownloadClient = Definition.Name + }; if (globalStatus.DownloadPaused || remainingSize == pausedSize && remainingSize != 0) { queueItem.Status = DownloadItemStatus.Paused; @@ -131,17 +147,18 @@ private IEnumerable GetHistory() { var droneParameter = item.Parameters.SingleOrDefault(p => p.Name == "drone"); - var historyItem = new DownloadClientItem(); - historyItem.DownloadClient = Definition.Name; - historyItem.DownloadId = droneParameter == null ? item.Id.ToString() : droneParameter.Value.ToString(); - historyItem.Title = item.Name; - historyItem.TotalSize = MakeInt64(item.FileSizeHi, item.FileSizeLo); - historyItem.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(item.DestDir)); - historyItem.Category = item.Category; - historyItem.Message = string.Format("PAR Status: {0} - Unpack Status: {1} - Move Status: {2} - Script Status: {3} - Delete Status: {4} - Mark Status: {5}", item.ParStatus, item.UnpackStatus, item.MoveStatus, item.ScriptStatus, item.DeleteStatus, item.MarkStatus); - historyItem.Status = DownloadItemStatus.Completed; - historyItem.RemainingTime = TimeSpan.Zero; - + var historyItem = new DownloadClientItem() + { + DownloadClient = Definition.Name, + DownloadId = droneParameter == null ? item.Id.ToString() : droneParameter.Value.ToString(), + Title = item.Name, + TotalSize = MakeInt64(item.FileSizeHi, item.FileSizeLo), + OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(item.DestDir)), + Category = item.Category, + Message = string.Format("PAR Status: {0} - Unpack Status: {1} - Move Status: {2} - Script Status: {3} - Delete Status: {4} - Mark Status: {5}", item.ParStatus, item.UnpackStatus, item.MoveStatus, item.ScriptStatus, item.DeleteStatus, item.MarkStatus), + Status = DownloadItemStatus.Completed, + RemainingTime = TimeSpan.Zero + }; if (item.DeleteStatus == "MANUAL") { continue; diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs index cbd104964..5aeef86b4 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs @@ -26,7 +26,9 @@ public NzbgetSettings() { Host = "localhost"; Port = 6789; - TvCategory = "tv"; + TvCategory = "Movies"; + Username = "nzbget"; + Password = "tegbzn6789"; RecentTvPriority = (int)NzbgetPriority.Normal; OlderTvPriority = (int)NzbgetPriority.Normal; } @@ -44,7 +46,7 @@ public NzbgetSettings() public string Password { get; set; } [FieldDefinition(4, Label = "Category", Type = FieldType.Textbox, HelpText = "Adding a category specific to Sonarr avoids conflicts with unrelated downloads, but it's optional")] - public string TvCategory { get; set; } + public string TvCategory { get; set; } [FieldDefinition(5, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(NzbgetPriority), HelpText = "Priority to use when grabbing episodes that aired within the last 14 days")] public int RecentTvPriority { get; set; } diff --git a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs index 8c6b981c5..98865538e 100644 --- a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Threading.Tasks; @@ -249,15 +249,15 @@ private List SearchAnimeSeason(Series series, List ep private TSpec Get(Series series, List episodes, bool userInvokedSearch) where TSpec : SearchCriteriaBase, new() { - var spec = new TSpec(); - - spec.Series = series; - spec.SceneTitles = _sceneMapping.GetSceneNames(series.TvdbId, + var spec = new TSpec() + { + Series = series, + SceneTitles = _sceneMapping.GetSceneNames(series.TvdbId, episodes.Select(e => e.SeasonNumber).Distinct().ToList(), - episodes.Select(e => e.SceneSeasonNumber ?? e.SeasonNumber).Distinct().ToList()); - - spec.Episodes = episodes; + episodes.Select(e => e.SceneSeasonNumber ?? e.SeasonNumber).Distinct().ToList()), + Episodes = episodes + }; spec.SceneTitles.Add(series.Title); spec.UserInvokedSearch = userInvokedSearch; @@ -266,18 +266,18 @@ private List SearchAnimeSeason(Series series, List ep private TSpec Get(Movie movie, bool userInvokedSearch) where TSpec : SearchCriteriaBase, new() { - var spec = new TSpec(); + var spec = new TSpec() + { + Movie = movie, + /*spec.SceneTitles = _sceneMapping.GetSceneNames(series.TvdbId, + episodes.Select(e => e.SeasonNumber).Distinct().ToList(), + episodes.Select(e => e.SceneSeasonNumber ?? e.SeasonNumber).Distinct().ToList()); - spec.Movie = movie; - /*spec.SceneTitles = _sceneMapping.GetSceneNames(series.TvdbId, - episodes.Select(e => e.SeasonNumber).Distinct().ToList(), - episodes.Select(e => e.SceneSeasonNumber ?? e.SeasonNumber).Distinct().ToList()); - - spec.Episodes = episodes; - - spec.SceneTitles.Add(series.Title);*/ - spec.UserInvokedSearch = userInvokedSearch; + spec.Episodes = episodes; + spec.SceneTitles.Add(series.Title);*/ + UserInvokedSearch = userInvokedSearch + }; return spec; } diff --git a/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs b/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs index bd75f0382..7a26587cd 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs @@ -106,8 +106,8 @@ protected virtual ValidationFailure TestCapabilities() } if (capabilities.SupportedTvSearchParameters != null && - new[] { "q", "tvdbid", "rid" }.Any(v => capabilities.SupportedTvSearchParameters.Contains(v)) && - new[] { "season", "ep" }.All(v => capabilities.SupportedTvSearchParameters.Contains(v))) + new[] { "q", "imdb" }.Any(v => capabilities.SupportedMovieSearchParamters.Contains(v)) && + new[] { "imdbtitle", "imdbyear" }.All(v => capabilities.SupportedMovieSearchParamters.Contains(v))) { return null; } diff --git a/src/NzbDrone.Core/Indexers/Newznab/NewznabCapabilities.cs b/src/NzbDrone.Core/Indexers/Newznab/NewznabCapabilities.cs index 11e73da34..1385eaa1a 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/NewznabCapabilities.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/NewznabCapabilities.cs @@ -8,6 +8,7 @@ public class NewznabCapabilities public int MaxPageSize { get; set; } public string[] SupportedSearchParameters { get; set; } public string[] SupportedTvSearchParameters { get; set; } + public string[] SupportedMovieSearchParamters { get; set; } public bool SupportsAggregateIdSearch { get; set; } public List Categories { get; set; } @@ -16,6 +17,7 @@ public NewznabCapabilities() DefaultPageSize = 100; MaxPageSize = 100; SupportedSearchParameters = new[] { "q" }; + SupportedMovieSearchParamters = new[] { "q", "imdb", "imdbtitle", "imdbyear" }; SupportedTvSearchParameters = new[] { "q", "rid", "season", "ep" }; // This should remain 'rid' for older newznab installs. SupportsAggregateIdSearch = false; Categories = new List(); diff --git a/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs index 59fec15cc..76030a2ec 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs @@ -85,6 +85,19 @@ private bool SupportsTvMazeSearch } } + private bool SupportsMovieSearch + { + get + { + var capabilities = _capabilitiesProvider.GetCapabilities(Settings); + + return capabilities.SupportedMovieSearchParamters != null && + capabilities.SupportedMovieSearchParamters.Contains("imdb") && + capabilities.SupportedMovieSearchParamters.Contains("imdbtitle") && + capabilities.SupportedMovieSearchParamters.Contains("imdbyear"); + } + } + private bool SupportsAggregatedIdSearch { get @@ -109,6 +122,19 @@ public virtual IndexerPageableRequestChain GetRecentRequests() return pageableRequests; } + public IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria) + { + var pageableRequests = new IndexerPageableRequestChain(); + + if(SupportsMovieSearch) + { + pageableRequests.Add(GetPagedRequests(MaxPages, Settings.Categories, "movie", + string.Format("&imdbid={0}", searchCriteria.Movie.ImdbId.Substring(2)))); //strip off the "tt" - VERY HACKY + } + + return pageableRequests; + } + public virtual IndexerPageableRequestChain GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria) { var pageableRequests = new IndexerPageableRequestChain(); @@ -274,10 +300,5 @@ private static string NewsnabifyTitle(string title) { return title.Replace("+", "%20"); } - - public IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria) - { - return new IndexerPageableRequestChain(); - } } } diff --git a/src/NzbDrone.Core/Indexers/Newznab/NewznabSettings.cs b/src/NzbDrone.Core/Indexers/Newznab/NewznabSettings.cs index b33ef566d..d798ec80e 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/NewznabSettings.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/NewznabSettings.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using FluentValidation; @@ -60,7 +60,7 @@ public class NewznabSettings : IProviderConfig public NewznabSettings() { - Categories = new[] { 5030, 5040 }; + Categories = new[] { 2030, 2040, 2050 }; AnimeCategories = Enumerable.Empty(); }