From dd53e5146819247f4343b887464d95d31d492919 Mon Sep 17 00:00:00 2001 From: James White Date: Sun, 15 Oct 2017 12:37:19 +0100 Subject: [PATCH 01/11] @cosmetic Fix jshint warnings on MoviesCollection.js (#2180) --- src/UI/Movies/MoviesCollection.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/UI/Movies/MoviesCollection.js b/src/UI/Movies/MoviesCollection.js index 341d6b657..2c04a97f6 100644 --- a/src/UI/Movies/MoviesCollection.js +++ b/src/UI/Movies/MoviesCollection.js @@ -86,7 +86,7 @@ var Collection = PageableCollection.extend({ return {}; } - if (this.state.pageSize == -1) { + if (this.state.pageSize === -1) { return this.state; } @@ -98,7 +98,7 @@ var Collection = PageableCollection.extend({ }, parseRecords : function(resp) { - if (resp && this.mode !== 'client' && this.state.pageSize != 0 && this.state.pageSize != -1) { + if (resp && this.mode !== 'client' && this.state.pageSize !== 0 && this.state.pageSize !== -1) { return resp.records; } @@ -252,7 +252,7 @@ var Collection = PageableCollection.extend({ }, add : function(model, options) { - if (this.length >= this.state.pageSize && this.state.pageSize != -1) { + if (this.length >= this.state.pageSize && this.state.pageSize !== -1) { return; } this.origAdd.call(this, model, options); From 4574ff5f6db844b485ab021176a456f727775254 Mon Sep 17 00:00:00 2001 From: James White Date: Sun, 15 Oct 2017 15:11:27 +0100 Subject: [PATCH 02/11] Fixed: typo on margin-bottom (#2182) --- src/UI/Hotkeys/hotkeys.less | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/UI/Hotkeys/hotkeys.less b/src/UI/Hotkeys/hotkeys.less index 616a7276f..9c8bfd4a3 100644 --- a/src/UI/Hotkeys/hotkeys.less +++ b/src/UI/Hotkeys/hotkeys.less @@ -1,7 +1,7 @@ .hotkeys-modal { h3 { margin-top : 0; - margin-botton : 0; + margin-bottom : 0; } .hotkey-group { @@ -20,4 +20,4 @@ font-size : 22px; } } -} \ No newline at end of file +} From 8861c8d8a4af307c5163039d4f39c9aad0b0b98d Mon Sep 17 00:00:00 2001 From: fhscholl Date: Sun, 22 Oct 2017 20:49:37 -0400 Subject: [PATCH 03/11] Add IsUpgrade and related deleted file paths for CustomScript (#2205) * Add IsUpgrade flag and deleted file paths for updates * use OldMovieFiles instead of OldFiles --- .../Notifications/CustomScript/CustomScript.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs index dda6e2e6d..ffdc075d4 100644 --- a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs +++ b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs @@ -54,6 +54,7 @@ namespace NzbDrone.Core.Notifications.CustomScript var environmentVariables = new StringDictionary(); environmentVariables.Add("Radarr_EventType", "Download"); + environmentVariables.Add("Radarr_IsUpgrade", message.OldMovieFiles.Any().ToString()); environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString()); environmentVariables.Add("Radarr_Movie_Title", movie.Title); environmentVariables.Add("Radarr_Movie_Path", movie.Path); @@ -69,6 +70,11 @@ namespace NzbDrone.Core.Notifications.CustomScript environmentVariables.Add("Radarr_MovieFile_SourcePath", sourcePath); environmentVariables.Add("Radarr_MovieFile_SourceFolder", Path.GetDirectoryName(sourcePath)); + if (message.OldMovieFiles.Any()) + { + environmentVariables.Add("Radarr_DeletedRelativePaths", string.Join("|", message.OldMovieFiles.Select(e => e.RelativePath))); + environmentVariables.Add("Radarr_DeletedPaths", string.Join("|", message.OldMovieFiles.Select(e => Path.Combine(movie.Path, e.RelativePath)))); + } ExecuteScript(environmentVariables); } From 5337f792812d32699f1d1e67bc3c782e2dfdb77b Mon Sep 17 00:00:00 2001 From: James White Date: Mon, 23 Oct 2017 01:49:54 +0100 Subject: [PATCH 04/11] Change default port of qBittorrent download client config (#2187) --- .../Download/Clients/QBittorrent/QBittorrentSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentSettings.cs b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentSettings.cs index a1c2893d9..db0ab9c76 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentSettings.cs @@ -21,7 +21,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent public QBittorrentSettings() { Host = "localhost"; - Port = 9091; + Port = 8080; MovieCategory = "radarr"; } From dffa50a82f0330d51fc42c161fd93d2ecb59a9e3 Mon Sep 17 00:00:00 2001 From: James White Date: Mon, 23 Oct 2017 01:51:07 +0100 Subject: [PATCH 05/11] uTorrent initial state feature (#2192) * New: Initial state for torrents added to UTorrent Closes #409 (cherry picked from commit 19a4d3536bde8103c4e0f7414cc1819b2083ffb2) * Change default port * Rename TvCategory to MovieCategory --- .../UTorrentTests/UTorrentFixture.cs | 10 +++++----- .../Download/Clients/uTorrent/UTorrent.cs | 16 ++++++++++------ .../Download/Clients/uTorrent/UTorrentProxy.cs | 10 ++++++++++ .../Clients/uTorrent/UTorrentSettings.cs | 11 +++++++---- .../Download/Clients/uTorrent/UtorrentState.cs | 10 ++++++++++ src/NzbDrone.Core/NzbDrone.Core.csproj | 1 + 6 files changed, 43 insertions(+), 15 deletions(-) create mode 100644 src/NzbDrone.Core/Download/Clients/uTorrent/UtorrentState.cs diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs index 8b0196347..1d8d0a43c 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests Port = 2222, Username = "admin", Password = "pass", - TvCategory = "tv" + MovieCategory = "movie" }; _queued = new UTorrentTorrent @@ -41,7 +41,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests Size = 1000, Remaining = 1000, Progress = 0, - Label = "tv", + Label = "movie", DownloadUrl = _downloadUrl, RootDownloadPath = "somepath" }; @@ -54,7 +54,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests Size = 1000, Remaining = 100, Progress = 0.9, - Label = "tv", + Label = "movie", DownloadUrl = _downloadUrl, RootDownloadPath = "somepath" }; @@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests Size = 1000, Remaining = 100, Progress = 0.9, - Label = "tv", + Label = "movie", DownloadUrl = _downloadUrl, RootDownloadPath = "somepath" }; @@ -80,7 +80,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests Size = 1000, Remaining = 0, Progress = 1.0, - Label = "tv", + Label = "movie", DownloadUrl = _downloadUrl, RootDownloadPath = "somepath" }; diff --git a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs index eff3a5850..d868ed597 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Collections.Generic; using NzbDrone.Common.Disk; @@ -49,7 +49,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash, string magnetLink) { _proxy.AddTorrentFromUrl(magnetLink, Settings); - _proxy.SetTorrentLabel(hash, Settings.TvCategory, Settings); + _proxy.SetTorrentLabel(hash, Settings.MovieCategory, Settings); /*var isRecentEpisode = remoteEpisode.IsRecentEpisode(); @@ -59,13 +59,15 @@ namespace NzbDrone.Core.Download.Clients.UTorrent _proxy.MoveTorrentToTopInQueue(hash, Settings); }*/ + _proxy.SetState(hash, (UTorrentState)Settings.IntialState, Settings); + return hash; } protected override string AddFromTorrentFile(RemoteMovie remoteMovie, string hash, string filename, byte[] fileContent) { _proxy.AddTorrentFromFile(filename, fileContent, Settings); - _proxy.SetTorrentLabel(hash, Settings.TvCategory, Settings); + _proxy.SetTorrentLabel(hash, Settings.MovieCategory, Settings); /*var isRecentEpisode = remoteEpisode.IsRecentEpisode(); @@ -75,6 +77,8 @@ namespace NzbDrone.Core.Download.Clients.UTorrent _proxy.MoveTorrentToTopInQueue(hash, Settings); }*/ + _proxy.SetState(hash, (UTorrentState)Settings.IntialState, Settings); + return hash; } @@ -86,7 +90,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent try { - var cacheKey = string.Format("{0}:{1}:{2}", Settings.Host, Settings.Port, Settings.TvCategory); + var cacheKey = string.Format("{0}:{1}:{2}", Settings.Host, Settings.Port, Settings.MovieCategory); var cache = _torrentCache.Find(cacheKey); var response = _proxy.GetTorrents(cache == null ? null : cache.CacheID, Settings); @@ -123,7 +127,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent foreach (var torrent in torrents) { - if (torrent.Label != Settings.TvCategory) + if (torrent.Label != Settings.MovieCategory) { continue; } @@ -205,7 +209,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent if (config.GetValueOrDefault("dir_add_label") == "true") { - destDir = destDir + Settings.TvCategory; + destDir = destDir + Settings.MovieCategory; } } diff --git a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentProxy.cs b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentProxy.cs index 64117f328..f4bf160cb 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentProxy.cs @@ -22,6 +22,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent void RemoveTorrent(string hash, bool removeData, UTorrentSettings settings); void SetTorrentLabel(string hash, string label, UTorrentSettings settings); void MoveTorrentToTopInQueue(string hash, UTorrentSettings settings); + void SetState(string hash, UTorrentState state, UTorrentSettings settings); } public class UTorrentProxy : IUTorrentProxy @@ -157,6 +158,15 @@ namespace NzbDrone.Core.Download.Clients.UTorrent ProcessRequest(requestBuilder, settings); } + public void SetState(string hash, UTorrentState state, UTorrentSettings settings) + { + var requestBuilder = BuildRequest(settings) + .AddQueryParam("action", state.ToString().ToLowerInvariant()) + .AddQueryParam("hash", hash); + + ProcessRequest(requestBuilder, settings); + } + private HttpRequestBuilder BuildRequest(UTorrentSettings settings) { var requestBuilder = new HttpRequestBuilder(false, settings.Host, settings.Port) diff --git a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentSettings.cs b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentSettings.cs index e1754493c..ae21c4a00 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentSettings.cs @@ -11,7 +11,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent { RuleFor(c => c.Host).ValidHost(); RuleFor(c => c.Port).InclusiveBetween(1, 65535); - RuleFor(c => c.TvCategory).NotEmpty(); + RuleFor(c => c.MovieCategory).NotEmpty(); } } @@ -22,8 +22,8 @@ namespace NzbDrone.Core.Download.Clients.UTorrent public UTorrentSettings() { Host = "localhost"; - Port = 9091; - TvCategory = "radarr"; + Port = 8080; + MovieCategory = "radarr"; } [FieldDefinition(0, Label = "Host", Type = FieldType.Textbox)] @@ -39,7 +39,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent public string Password { get; set; } [FieldDefinition(4, Label = "Category", Type = FieldType.Textbox, HelpText = "Adding a category specific to Radarr avoids conflicts with unrelated downloads, but it's optional")] - public string TvCategory { get; set; } + public string MovieCategory { get; set; } [FieldDefinition(5, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(UTorrentPriority), HelpText = "Priority to use when grabbing releases that aired within the last 14 days")] public int RecentTvPriority { get; set; } @@ -47,6 +47,9 @@ namespace NzbDrone.Core.Download.Clients.UTorrent [FieldDefinition(6, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(UTorrentPriority), HelpText = "Priority to use when grabbing releases that aired over 14 days ago")] public int OlderTvPriority { get; set; } + [FieldDefinition(7, Label = "Initial State", Type = FieldType.Select, SelectOptions = typeof(UTorrentState), HelpText = "Initial state for torrents added to uTorrent")] + public int IntialState { get; set; } + public NzbDroneValidationResult Validate() { return new NzbDroneValidationResult(Validator.Validate(this)); diff --git a/src/NzbDrone.Core/Download/Clients/uTorrent/UtorrentState.cs b/src/NzbDrone.Core/Download/Clients/uTorrent/UtorrentState.cs new file mode 100644 index 000000000..17feaa485 --- /dev/null +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UtorrentState.cs @@ -0,0 +1,10 @@ +namespace NzbDrone.Core.Download.Clients.UTorrent +{ + public enum UTorrentState + { + Start = 0, + ForceStart = 1, + Pause = 2, + Stop = 3 + } +} diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 8a05a0898..e85b02d56 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -556,6 +556,7 @@ + From b313dd1845d34470b126d72f785195079eb7ebcd Mon Sep 17 00:00:00 2001 From: Oliver Rivett-Carnac Date: Mon, 23 Oct 2017 02:58:25 +0200 Subject: [PATCH 06/11] Minor error message tweak (#1778) * Added: some tips to how to build. Gave some info to Windows developers. * Fixed: Alignment of validation errors in labels * Fixed: error message mentioning 'series' --- README.md | 7 +++ .../Validation/Paths/MoviePathValidation.cs | 52 +++++++++---------- src/UI/Content/form.less | 3 +- 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index f405d7a68..b595a3d1f 100644 --- a/README.md +++ b/README.md @@ -115,10 +115,17 @@ Radarr is currently undergoing rapid development and pull requests are actively > **Notice** > Gulp must be running at all times while you are working with Radarr client source files. +### Build + +* To build run `sh build.sh` + +**Note:** Windows users must have bash available to do this. [cmder](http://cmder.net/) which is a console emulator for windows has bash as part of it's default installation. + ### Development * Open `NzbDrone.sln` in Visual Studio or run the build.sh script, if Mono is installed * Make sure `NzbDrone.Console` is set as the startup project +* Run `build.sh` before running ### License diff --git a/src/NzbDrone.Core/Validation/Paths/MoviePathValidation.cs b/src/NzbDrone.Core/Validation/Paths/MoviePathValidation.cs index 690bd59f2..cbd36af7a 100644 --- a/src/NzbDrone.Core/Validation/Paths/MoviePathValidation.cs +++ b/src/NzbDrone.Core/Validation/Paths/MoviePathValidation.cs @@ -1,27 +1,27 @@ -using FluentValidation.Validators; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Validation.Paths -{ - public class MoviePathValidator : PropertyValidator - { - private readonly IMovieService _seriesService; - - public MoviePathValidator(IMovieService seriesService) - : base("Path is already configured for another series") - { - _seriesService = seriesService; - } - - protected override bool IsValid(PropertyValidatorContext context) - { - if (context.PropertyValue == null) return true; - - dynamic instance = context.ParentContext.InstanceToValidate; - var instanceId = (int)instance.Id; - - return (!_seriesService.GetAllMovies().Exists(s => s.Path.PathEquals(context.PropertyValue.ToString()) && s.Id != instanceId)); - } - } +using FluentValidation.Validators; +using NzbDrone.Common.Extensions; +using NzbDrone.Core.Tv; + +namespace NzbDrone.Core.Validation.Paths +{ + public class MoviePathValidator : PropertyValidator + { + private readonly IMovieService _moviesService; + + public MoviePathValidator(IMovieService moviesService) + : base("Path is already configured for another movie") + { + _moviesService = moviesService; + } + + protected override bool IsValid(PropertyValidatorContext context) + { + if (context.PropertyValue == null) return true; + + dynamic instance = context.ParentContext.InstanceToValidate; + var instanceId = (int)instance.Id; + + return (!_moviesService.GetAllMovies().Exists(s => s.Path.PathEquals(context.PropertyValue.ToString()) && s.Id != instanceId)); + } + } } \ No newline at end of file diff --git a/src/UI/Content/form.less b/src/UI/Content/form.less index bad6327bd..4632e40f2 100644 --- a/src/UI/Content/form.less +++ b/src/UI/Content/form.less @@ -41,8 +41,7 @@ .help-inline { display : inline-block; - margin-top : 8px; - padding-left : 0; + padding-left : 0px; @media (max-width: @screen-xs-max) { margin-left: 0; From 5674d8ad60cb46be76ee733d87e5b90624c2332e Mon Sep 17 00:00:00 2001 From: James White Date: Mon, 23 Oct 2017 20:47:49 +0100 Subject: [PATCH 07/11] Changed: Nzbget Rename TvCategory references to MovieCategory (#2211) --- .../NzbgetTests/NzbgetFixture.cs | 12 +++++------ .../Download/Clients/Nzbget/Nzbget.cs | 20 +++++++++---------- .../Download/Clients/Nzbget/NzbgetProxy.cs | 20 +++++++++---------- .../Download/Clients/Nzbget/NzbgetResponse.cs | 2 +- .../Download/Clients/Nzbget/NzbgetSettings.cs | 10 +++++----- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs index 91e786492..995d73e64 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests Port = 2222, Username = "admin", Password = "pass", - TvCategory = "tv", + MovieCategory = "movie", RecentTvPriority = (int)NzbgetPriority.High }; @@ -38,7 +38,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests { FileSizeLo = 1000, RemainingSizeLo = 10, - Category = "tv", + Category = "movie", NzbName = "Droned.1998.1080p.WEB-DL-DRONE", Parameters = new List { new NzbgetParameter { Name = "drone", Value = "id" } } }; @@ -46,7 +46,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests _failed = new NzbgetHistoryItem { FileSizeLo = 1000, - Category = "tv", + Category = "movie", Name = "Droned.1998.1080p.WEB-DL-DRONE", DestDir = "somedirectory", Parameters = new List { new NzbgetParameter { Name = "drone", Value = "id" } }, @@ -61,7 +61,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests _completed = new NzbgetHistoryItem { FileSizeLo = 1000, - Category = "tv", + Category = "movie", Name = "Droned.1998.1080p.WEB-DL-DRONE", DestDir = "/remote/mount/tv/Droned.1998.1080p.WEB-DL-DRONE", Parameters = new List { new NzbgetParameter { Name = "drone", Value = "id" } }, @@ -81,8 +81,8 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests }); var configItems = new Dictionary(); - configItems.Add("Category1.Name", "tv"); - configItems.Add("Category1.DestDir", @"/remote/mount/tv"); + configItems.Add("Category1.Name", "movie"); + configItems.Add("Category1.DestDir", @"/remote/mount/movie"); Mocker.GetMock() .Setup(v => v.GetConfig(It.IsAny())) diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs index f039350d1..ba98e789f 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Linq; using System.Collections.Generic; @@ -38,7 +38,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget protected override string AddFromNzbFile(RemoteMovie remoteMovie, string filename, byte[] fileContents) { - var category = Settings.TvCategory; // TODO: Update this to MovieCategory? + var category = Settings.MovieCategory; var priority = Settings.RecentTvPriority; @@ -204,7 +204,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget public override IEnumerable GetItems() { - return GetQueue().Concat(GetHistory()).Where(downloadClientItem => downloadClientItem.Category == Settings.TvCategory); + return GetQueue().Concat(GetHistory()).Where(downloadClientItem => downloadClientItem.Category == Settings.MovieCategory); } public override void RemoveItem(string downloadId, bool deleteData) @@ -221,7 +221,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget { var config = _proxy.GetConfig(Settings); - var category = GetCategories(config).FirstOrDefault(v => v.Name == Settings.TvCategory); + var category = GetCategories(config).FirstOrDefault(v => v.Name == Settings.MovieCategory); var status = new DownloadClientStatus { @@ -283,7 +283,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget if (Version.Parse(version) < Version.Parse("12.0")) { - return new ValidationFailure(string.Empty, "Nzbget version too low, need 12.0 or higher"); + return new ValidationFailure(string.Empty, "NZBGet version too low, need 12.0 or higher"); } } catch (Exception ex) @@ -304,12 +304,12 @@ namespace NzbDrone.Core.Download.Clients.Nzbget var config = _proxy.GetConfig(Settings); var categories = GetCategories(config); - if (!Settings.TvCategory.IsNullOrWhiteSpace() && !categories.Any(v => v.Name == Settings.TvCategory)) + if (!Settings.MovieCategory.IsNullOrWhiteSpace() && !categories.Any(v => v.Name == Settings.MovieCategory)) { - return new NzbDroneValidationFailure("TvCategory", "Category does not exist") + return new NzbDroneValidationFailure("MovieCategory", "Category does not exist") { InfoLink = string.Format("http://{0}:{1}/", Settings.Host, Settings.Port), - DetailedDescription = "The Category your entered doesn't exist in NzbGet. Go to NzbGet to create it." + DetailedDescription = "The category you entered doesn't exist in NZBGet. Go to NZBGet to create it." }; } @@ -323,10 +323,10 @@ namespace NzbDrone.Core.Download.Clients.Nzbget var keepHistory = config.GetValueOrDefault("KeepHistory"); if (keepHistory == "0") { - return new NzbDroneValidationFailure(string.Empty, "NzbGet setting KeepHistory should be greater than 0") + return new NzbDroneValidationFailure(string.Empty, "NZBGet setting KeepHistory should be greater than 0") { InfoLink = string.Format("http://{0}:{1}/", Settings.Host, Settings.Port), - DetailedDescription = "NzbGet setting KeepHistory is set to 0. Which prevents Radarr from seeing completed downloads." + DetailedDescription = "NZBGet setting KeepHistory is set to 0. Which prevents Radarr from seeing completed downloads." }; } diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetProxy.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetProxy.cs index 7a21b45b1..aece0a615 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetProxy.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using NLog; @@ -88,7 +88,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget var editResult = EditQueue("GroupSetParameter", 0, "drone=" + droneId, item.NzbId, settings); if (editResult) { - _logger.Debug("Nzbget download drone parameter set to: {0}", droneId); + _logger.Debug("NZBGet download drone parameter set to: {0}", droneId); } return droneId; @@ -114,7 +114,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget if (editResult) { - _logger.Debug("Nzbget download drone parameter set to: {0}", droneId); + _logger.Debug("NZBGet download drone parameter set to: {0}", droneId); } return droneId; @@ -175,7 +175,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget { if (!EditQueue("GroupFinalDelete", 0, "", queueItem.NzbId, settings)) { - _logger.Warn("Failed to remove item from nzbget queue, {0} [{1}]", queueItem.NzbName, queueItem.NzbId); + _logger.Warn("Failed to remove item from NZBGet, {0} [{1}]", queueItem.NzbName, queueItem.NzbId); } } @@ -183,13 +183,13 @@ namespace NzbDrone.Core.Download.Clients.Nzbget { if (!EditQueue("HistoryDelete", 0, "", historyItem.Id, settings)) { - _logger.Warn("Failed to remove item from nzbget history, {0} [{1}]", historyItem.Name, historyItem.Id); + _logger.Warn("Failed to remove item from NZBGet history, {0} [{1}]", historyItem.Name, historyItem.Id); } } else { - _logger.Warn("Unable to remove item from nzbget, Unknown ID: {0}", id); + _logger.Warn("Unable to remove item from NZBGet, Unknown ID: {0}", id); return; } } @@ -235,21 +235,21 @@ namespace NzbDrone.Core.Download.Clients.Nzbget { if (ex.Response.StatusCode == HttpStatusCode.Unauthorized) { - throw new DownloadClientException("Authentication failed for NzbGet, please check your settings", ex); + throw new DownloadClientException("Authentication failed for NZBGet, please check your settings", ex); } - throw new DownloadClientException("Unable to connect to NzbGet. " + ex.Message, ex); + throw new DownloadClientException("Unable to connect to NZBGet. " + ex.Message, ex); } catch (WebException ex) { - throw new DownloadClientException("Unable to connect to NzbGet. " + ex.Message, ex); + throw new DownloadClientException("Unable to connect to NZBGet. " + ex.Message, ex); } var result = Json.Deserialize>(response.Content); if (result.Error != null) { - throw new DownloadClientException("Error response received from nzbget: {0}", result.Error.ToString()); + throw new DownloadClientException("Error response received from NZBGet: {0}", result.Error.ToString()); } return result.Result; diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetResponse.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetResponse.cs index f1546593e..a41667824 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetResponse.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetResponse.cs @@ -1,4 +1,4 @@ -namespace NzbDrone.Core.Download.Clients.Nzbget +namespace NzbDrone.Core.Download.Clients.Nzbget { public class NzbgetResponse { diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs index 0ddd890a9..d0a8ee0a6 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetSettings.cs @@ -1,4 +1,4 @@ -using FluentValidation; +using FluentValidation; using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.Validation; @@ -14,7 +14,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget RuleFor(c => c.Username).NotEmpty().When(c => !string.IsNullOrWhiteSpace(c.Password)); RuleFor(c => c.Password).NotEmpty().When(c => !string.IsNullOrWhiteSpace(c.Username)); - RuleFor(c => c.TvCategory).NotEmpty().WithMessage("A category is recommended").AsWarning(); + RuleFor(c => c.MovieCategory).NotEmpty().WithMessage("A category is recommended").AsWarning(); } } @@ -26,7 +26,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget { Host = "localhost"; Port = 6789; - TvCategory = "Movies"; + MovieCategory = "Movies"; Username = "nzbget"; Password = "tegbzn6789"; RecentTvPriority = (int)NzbgetPriority.Normal; @@ -46,7 +46,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget public string Password { get; set; } [FieldDefinition(4, Label = "Category", Type = FieldType.Textbox, HelpText = "Adding a category specific to Radarr avoids conflicts with unrelated downloads, but it's optional")] - public string TvCategory { get; set; } + public string MovieCategory { get; set; } [FieldDefinition(5, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(NzbgetPriority), HelpText = "Priority to use when grabbing releases that aired within the last 14 days")] public int RecentTvPriority { get; set; } @@ -57,7 +57,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget [FieldDefinition(7, Label = "Use SSL", Type = FieldType.Checkbox)] public bool UseSsl { get; set; } - [FieldDefinition(8, Label = "Add Paused", Type = FieldType.Checkbox, HelpText = "This option requires at least NzbGet version 16.0")] + [FieldDefinition(8, Label = "Add Paused", Type = FieldType.Checkbox, HelpText = "This option requires at least NZBGet version 16.0")] public bool AddPaused { get; set; } public NzbDroneValidationResult Validate() From 386a434aeb0b41c3c41bfb614e9887914a6646bc Mon Sep 17 00:00:00 2001 From: James White Date: Mon, 23 Oct 2017 20:49:02 +0100 Subject: [PATCH 08/11] Changed: Sabnzbd Update test cases and rename to MovieCategory (#2212) --- .../SabnzbdTests/SabnzbdFixture.cs | 30 ++++++------ .../Download/Clients/Sabnzbd/Sabnzbd.cs | 46 +++++++++---------- .../Clients/Sabnzbd/SabnzbdSettings.cs | 8 ++-- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs index 1656b8bde..44ddb4b4a 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs @@ -36,7 +36,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests ApiKey = "5c770e3197e4fe763423ee7c392c25d1", Username = "admin", Password = "pass", - TvCategory = "tv", + MovieCategory = "movie", RecentTvPriority = (int)SabnzbdPriority.High }; _queued = new SabnzbdQueue @@ -51,7 +51,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests Size = 1000, Sizeleft = 10, Timeleft = TimeSpan.FromSeconds(10), - Category = "tv", + Category = "movie", Id = "sabnzbd_nzb12345", Title = "Droned.1998.1080p.WEB-DL-DRONE" } @@ -66,7 +66,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests { Status = SabnzbdDownloadStatus.Failed, Size = 1000, - Category = "tv", + Category = "movie", Id = "sabnzbd_nzb12345", Title = "Droned.1998.1080p.WEB-DL-DRONE" } @@ -81,7 +81,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests { Status = SabnzbdDownloadStatus.Completed, Size = 1000, - Category = "tv", + Category = "movie", Id = "sabnzbd_nzb12345", Title = "Droned.1998.1080p.WEB-DL-DRONE", Storage = "/remote/mount/vv/Droned.1998.1080p.WEB-DL-DRONE" @@ -97,7 +97,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests }, Categories = new List { - new SabnzbdCategory { Name = "tv", Dir = "vv" } + new SabnzbdCategory { Name = "movie", Dir = "vv" } } }; @@ -111,7 +111,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests _fullStatus = new SabnzbdFullStatus { - CompleteDir = @"Y:\nzbget\root\complete".AsOsAgnostic() + CompleteDir = @"Y:\sabnzbd\root\complete".AsOsAgnostic() }; Mocker.GetMock() @@ -408,10 +408,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests result.OutputPath.Should().Be(@"C:\sorted\somewhere\asdfasdf\asdfasdf.mkv".AsOsAgnostic()); } - [TestCase(@"Y:\nzbget\root", @"completed\downloads", @"vv", @"Y:\nzbget\root\completed\downloads", @"Y:\nzbget\root\completed\downloads\vv")] - [TestCase(@"Y:\nzbget\root", @"completed", @"vv", @"Y:\nzbget\root\completed", @"Y:\nzbget\root\completed\vv")] - [TestCase(@"/nzbget/root", @"completed/downloads", @"vv", @"/nzbget/root/completed/downloads", @"/nzbget/root/completed/downloads/vv")] - [TestCase(@"/nzbget/root", @"completed", @"vv", @"/nzbget/root/completed", @"/nzbget/root/completed/vv")] + [TestCase(@"Y:\sabnzbd\root", @"completed\downloads", @"vv", @"Y:\sabnzbd\root\completed\downloads", @"Y:\sabnzbd\root\completed\downloads\vv")] + [TestCase(@"Y:\sabnzbd\root", @"completed", @"vv", @"Y:\sabnzbd\root\completed", @"Y:\sabnzbd\root\completed\vv")] + [TestCase(@"/sabnzbd/root", @"completed/downloads", @"vv", @"/sabnzbd/root/completed/downloads", @"/sabnzbd/root/completed/downloads/vv")] + [TestCase(@"/sabnzbd/root", @"completed", @"vv", @"/sabnzbd/root/completed", @"/sabnzbd/root/completed/vv")] public void should_return_status_with_outputdir_for_version_lt_2(string rootFolder, string completeDir, string categoryDir, string fullCompleteDir, string fullCategoryDir) { _fullStatus.CompleteDir = null; @@ -429,10 +429,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests result.OutputRootFolders.First().Should().Be(fullCategoryDir); } - [TestCase(@"Y:\nzbget\root", @"completed\downloads", @"vv", @"Y:\nzbget\root\completed\downloads", @"Y:\nzbget\root\completed\downloads\vv")] - [TestCase(@"Y:\nzbget\root", @"completed", @"vv", @"Y:\nzbget\root\completed", @"Y:\nzbget\root\completed\vv")] - [TestCase(@"/nzbget/root", @"completed/downloads", @"vv", @"/nzbget/root/completed/downloads", @"/nzbget/root/completed/downloads/vv")] - [TestCase(@"/nzbget/root", @"completed", @"vv", @"/nzbget/root/completed", @"/nzbget/root/completed/vv")] + [TestCase(@"Y:\sabnzbd\root", @"completed\downloads", @"vv", @"Y:\sabnzbd\root\completed\downloads", @"Y:\sabnzbd\root\completed\downloads\vv")] + [TestCase(@"Y:\sabnzbd\root", @"completed", @"vv", @"Y:\sabnzbd\root\completed", @"Y:\sabnzbd\root\completed\vv")] + [TestCase(@"/sabnzbd/root", @"completed/downloads", @"vv", @"/sabnzbd/root/completed/downloads", @"/sabnzbd/root/completed/downloads/vv")] + [TestCase(@"/sabnzbd/root", @"completed", @"vv", @"/sabnzbd/root/completed", @"/sabnzbd/root/completed/vv")] public void should_return_status_with_outputdir_for_version_gte_2(string rootFolder, string completeDir, string categoryDir, string fullCompleteDir, string fullCategoryDir) { _fullStatus.CompleteDir = fullCompleteDir; @@ -554,7 +554,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests [Test] public void should_test_failed_if_tv_sorting_default_category() { - Subject.Definition.Settings.As().TvCategory = null; + Subject.Definition.Settings.As().MovieCategory = null; _config.Misc.enable_tv_sorting = true; _config.Misc.tv_categories = new[] { "Default" }; diff --git a/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs b/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs index 67910ef08..bc0997e2e 100644 --- a/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs +++ b/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; @@ -39,7 +39,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd protected override string AddFromNzbFile(RemoteMovie remoteMovie, string filename, byte[] fileContents) { - var category = Settings.TvCategory; + var category = Settings.MovieCategory; var priority = Settings.RecentTvPriority; var response = _proxy.DownloadNzb(fileContents, filename, category, priority, Settings); @@ -119,7 +119,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd try { - sabHistory = _proxy.GetHistory(0, _configService.DownloadClientHistoryLimit, Settings.TvCategory, Settings); + sabHistory = _proxy.GetHistory(0, _configService.DownloadClientHistoryLimit, Settings.MovieCategory, Settings); } catch (DownloadClientException ex) { @@ -200,7 +200,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd { foreach (var downloadClientItem in GetQueue().Concat(GetHistory())) { - if (downloadClientItem.Category == Settings.TvCategory || downloadClientItem.Category == "*" && Settings.TvCategory.IsNullOrWhiteSpace()) + if (downloadClientItem.Category == Settings.MovieCategory || downloadClientItem.Category == "*" && Settings.MovieCategory.IsNullOrWhiteSpace()) { yield return downloadClientItem; } @@ -254,7 +254,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd var config = _proxy.GetConfig(Settings); var categories = GetCategories(config).ToArray(); - var category = categories.FirstOrDefault(v => v.Name == Settings.TvCategory); + var category = categories.FirstOrDefault(v => v.Name == Settings.MovieCategory); if (category == null) { @@ -366,7 +366,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd if (rawVersion.Equals("develop", StringComparison.InvariantCultureIgnoreCase)) { - return new NzbDroneValidationFailure("Version", "Sabnzbd develop version, assuming version 1.1.0 or higher.") + return new NzbDroneValidationFailure("Version", "SABnzbd develop version, assuming version 1.1.0 or higher.") { IsWarning = true, DetailedDescription = "Radarr may not be able to support new features added to SABnzbd when running develop versions." @@ -419,10 +419,10 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd var config = _proxy.GetConfig(Settings); if (config.Misc.pre_check && !HasVersion(1, 1)) { - return new NzbDroneValidationFailure("", "Disable 'Check before download' option in Sabnbzd") + return new NzbDroneValidationFailure("", "Disable 'Check before download' option in SABnzbd") { InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/switches/", Settings.Host, Settings.Port), - DetailedDescription = "Using Check before download affects Radarr ability to track new downloads. Also Sabnzbd recommends 'Abort jobs that cannot be completed' instead since it's more effective." + DetailedDescription = "Using Check before download affects Radarr ability to track new downloads. Also SABnzbd recommends 'Abort jobs that cannot be completed' instead since it's more effective." }; } @@ -432,52 +432,52 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd private ValidationFailure TestCategory() { var config = _proxy.GetConfig(Settings); - var category = GetCategories(config).FirstOrDefault((SabnzbdCategory v) => v.Name == Settings.TvCategory); + var category = GetCategories(config).FirstOrDefault((SabnzbdCategory v) => v.Name == Settings.MovieCategory); if (category != null) { if (category.Dir.EndsWith("*")) { - return new NzbDroneValidationFailure("TvCategory", "Enable Job folders") + return new NzbDroneValidationFailure("MovieCategory", "Enable Job folders") { InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/categories/", Settings.Host, Settings.Port), - DetailedDescription = "Radarr prefers each download to have a separate folder. With * appended to the Folder/Path Sabnzbd will not create these job folders. Go to Sabnzbd to fix it." + DetailedDescription = "Radarr prefers each download to have a separate folder. With * appended to the Folder/Path SABnzbd will not create these job folders. Go to SABnzbd to fix it." }; } } else { - if (!Settings.TvCategory.IsNullOrWhiteSpace()) + if (!Settings.MovieCategory.IsNullOrWhiteSpace()) { - return new NzbDroneValidationFailure("TvCategory", "Category does not exist") + return new NzbDroneValidationFailure("MovieCategory", "Category does not exist") { InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/categories/", Settings.Host, Settings.Port), - DetailedDescription = "The Category your entered doesn't exist in Sabnzbd. Go to Sabnzbd to create it." + DetailedDescription = "The category you entered doesn't exist in SABnzbd. Go to SABnzbd to create it." }; } } - if (config.Misc.enable_tv_sorting && ContainsCategory(config.Misc.tv_categories, Settings.TvCategory)) + if (config.Misc.enable_tv_sorting && ContainsCategory(config.Misc.tv_categories, Settings.MovieCategory)) { - return new NzbDroneValidationFailure("TvCategory", "Disable TV Sorting") + return new NzbDroneValidationFailure("MovieCategory", "Disable TV Sorting") { InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/sorting/", Settings.Host, Settings.Port), - DetailedDescription = "You must disable Sabnzbd TV Sorting for the category Radarr uses to prevent import issues. Go to Sabnzbd to fix it." + DetailedDescription = "You must disable SABnzbd TV Sorting for the category Radarr uses to prevent import issues. Go to SABnzbd to fix it." }; } - if (config.Misc.enable_movie_sorting && ContainsCategory(config.Misc.movie_categories, Settings.TvCategory)) + if (config.Misc.enable_movie_sorting && ContainsCategory(config.Misc.movie_categories, Settings.MovieCategory)) { - return new NzbDroneValidationFailure("TvCategory", "Disable Movie Sorting") + return new NzbDroneValidationFailure("MovieCategory", "Disable Movie Sorting") { InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/sorting/", Settings.Host, Settings.Port), - DetailedDescription = "You must disable Sabnzbd Movie Sorting for the category Radarr uses to prevent import issues. Go to Sabnzbd to fix it." + DetailedDescription = "You must disable SABnzbd Movie Sorting for the category Radarr uses to prevent import issues. Go to SABnzbd to fix it." }; } - if (config.Misc.enable_date_sorting && ContainsCategory(config.Misc.date_categories, Settings.TvCategory)) + if (config.Misc.enable_date_sorting && ContainsCategory(config.Misc.date_categories, Settings.MovieCategory)) { - return new NzbDroneValidationFailure("TvCategory", "Disable Date Sorting") + return new NzbDroneValidationFailure("MovieCategory", "Disable Date Sorting") { InfoLink = string.Format("http://{0}:{1}/sabnzbd/config/sorting/", Settings.Host, Settings.Port), - DetailedDescription = "You must disable Sabnzbd Date Sorting for the category Radarr uses to prevent import issues. Go to Sabnzbd to fix it." + DetailedDescription = "You must disable SABnzbd Date Sorting for the category Radarr uses to prevent import issues. Go to SABnzbd to fix it." }; } diff --git a/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdSettings.cs b/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdSettings.cs index 183c1c899..6c47b6e73 100644 --- a/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdSettings.cs @@ -1,4 +1,4 @@ -using FluentValidation; +using FluentValidation; using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.Validation; @@ -24,7 +24,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd .WithMessage("Password is required when API key is not configured") .When(c => string.IsNullOrWhiteSpace(c.ApiKey)); - RuleFor(c => c.TvCategory).NotEmpty() + RuleFor(c => c.MovieCategory).NotEmpty() .WithMessage("A category is recommended") .AsWarning(); } @@ -38,7 +38,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd { Host = "localhost"; Port = 8080; - TvCategory = "movies"; + MovieCategory = "movies"; RecentTvPriority = (int)SabnzbdPriority.Default; OlderTvPriority = (int)SabnzbdPriority.Default; } @@ -59,7 +59,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd public string Password { get; set; } [FieldDefinition(5, Label = "Category", Type = FieldType.Textbox, HelpText = "Adding a category specific to Radarr avoids conflicts with unrelated downloads, but it's optional")] - public string TvCategory { get; set; } + public string MovieCategory { get; set; } [FieldDefinition(6, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(SabnzbdPriority), HelpText = "Priority to use when grabbing releases that aired within the last 14 days")] public int RecentTvPriority { get; set; } From b521ffb588a79452d0cc6c897dbe8be319913714 Mon Sep 17 00:00:00 2001 From: James White Date: Mon, 23 Oct 2017 20:50:03 +0100 Subject: [PATCH 09/11] Added: Message about adblockers preventing the log table from loading (#2213) (Fixes #2209) --- src/UI/System/Logs/Table/LogsTableLayoutTemplate.hbs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/UI/System/Logs/Table/LogsTableLayoutTemplate.hbs b/src/UI/System/Logs/Table/LogsTableLayoutTemplate.hbs index 1d579ffcd..18a09d595 100644 --- a/src/UI/System/Logs/Table/LogsTableLayoutTemplate.hbs +++ b/src/UI/System/Logs/Table/LogsTableLayoutTemplate.hbs @@ -1,4 +1,8 @@
+
+ × + If the log viewer table does not load, please disable your adblocker and refresh the page. +
From 5e121c78e11d420468bc777c97e877f206c8f42c Mon Sep 17 00:00:00 2001 From: fhscholl Date: Sat, 28 Oct 2017 11:18:52 -0400 Subject: [PATCH 10/11] Updated: Webhook Improvements (#2220) (Fixes #1751) --- .../Notifications/Webhook/Webhook.cs | 87 +++++++++++++-- .../Notifications/Webhook/WebhookEpisode.cs | 32 ------ .../Webhook/WebhookGrabPayload.cs | 8 ++ .../Webhook/WebhookImportPayload.cs | 9 ++ .../Notifications/Webhook/WebhookMethod.cs | 10 +- .../Notifications/Webhook/WebhookMovie.cs | 6 +- .../Notifications/Webhook/WebhookMovieFile.cs | 28 +++++ .../Notifications/Webhook/WebhookPayload.cs | 3 - .../Notifications/Webhook/WebhookProxy.cs | 41 +++++++ .../Notifications/Webhook/WebhookRelease.cs | 27 +++++ .../Notifications/Webhook/WebhookSeries.cs | 22 ---- .../Notifications/Webhook/WebhookService.cs | 103 ------------------ src/NzbDrone.Core/NzbDrone.Core.csproj | 10 +- 13 files changed, 207 insertions(+), 179 deletions(-) mode change 100644 => 100755 src/NzbDrone.Core/Notifications/Webhook/Webhook.cs delete mode 100644 src/NzbDrone.Core/Notifications/Webhook/WebhookEpisode.cs create mode 100755 src/NzbDrone.Core/Notifications/Webhook/WebhookGrabPayload.cs create mode 100755 src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs mode change 100644 => 100755 src/NzbDrone.Core/Notifications/Webhook/WebhookMethod.cs mode change 100644 => 100755 src/NzbDrone.Core/Notifications/Webhook/WebhookMovie.cs create mode 100755 src/NzbDrone.Core/Notifications/Webhook/WebhookMovieFile.cs mode change 100644 => 100755 src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs create mode 100755 src/NzbDrone.Core/Notifications/Webhook/WebhookProxy.cs create mode 100755 src/NzbDrone.Core/Notifications/Webhook/WebhookRelease.cs delete mode 100644 src/NzbDrone.Core/Notifications/Webhook/WebhookSeries.cs delete mode 100644 src/NzbDrone.Core/Notifications/Webhook/WebhookService.cs diff --git a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs old mode 100644 new mode 100755 index 153f86af4..ed9a6d582 --- a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs @@ -1,35 +1,64 @@ - using System.Collections.Generic; +using System.Linq; using FluentValidation.Results; using NzbDrone.Core.Tv; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Validation; namespace NzbDrone.Core.Notifications.Webhook { public class Webhook : NotificationBase { - private readonly IWebhookService _service; + private readonly IWebhookProxy _proxy; - public Webhook(IWebhookService service) + public Webhook(IWebhookProxy proxy) { - _service = service; + _proxy = proxy; } public override string Link => "https://github.com/Radarr/Radarr/wiki/Webhook"; public override void OnGrab(GrabMessage message) { - _service.OnGrab(message.Movie, message.RemoteMovie, message.Quality, Settings); + var remoteMovie = message.RemoteMovie; + var quality = message.Quality; + + var payload = new WebhookGrabPayload + { + EventType = "Grab", + Movie = new WebhookMovie(message.Movie), + RemoteMovie = new WebhookRemoteMovie(remoteMovie), + Release = new WebhookRelease(quality, remoteMovie) + }; + + _proxy.SendWebhook(payload, Settings); } public override void OnDownload(DownloadMessage message) { - _service.OnDownload(message.Movie, message.MovieFile, Settings); + var movieFile = message.MovieFile; + + var payload = new WebhookImportPayload + { + EventType = "Download", + Movie = new WebhookMovie(message.Movie), + RemoteMovie = new WebhookRemoteMovie(message.Movie), + MovieFile = new WebhookMovieFile(movieFile), + IsUpgrade = message.OldMovieFiles.Any() + }; + + _proxy.SendWebhook(payload, Settings); } public override void OnMovieRename(Movie movie) { - _service.OnRename(movie, Settings); + var payload = new WebhookPayload + { + EventType = "Rename", + Movie = new WebhookMovie(movie) + }; + + _proxy.SendWebhook(payload, Settings); } public override void OnRename(Series series) @@ -42,9 +71,51 @@ namespace NzbDrone.Core.Notifications.Webhook { var failures = new List(); - failures.AddIfNotNull(_service.Test(Settings)); + failures.AddIfNotNull(SendWebhookTest()); return new ValidationResult(failures); } + + private ValidationFailure SendWebhookTest() + { + try + { + var payload = new WebhookGrabPayload + { + EventType = "Test", + Movie = new WebhookMovie + { + Id = 1, + Title = "Test Title", + FilePath = "C:\\testpath", + ReleaseDate = "1970-01-01" + }, + RemoteMovie = new WebhookRemoteMovie + { + TmdbId = 1234, + ImdbId = "5678", + Title = "Test title", + Year = 1970 + }, + Release = new WebhookRelease + { + Indexer = "Test Indexer", + Quality = "Test Quality", + QualityVersion = 1, + ReleaseGroup = "Test Group", + ReleaseTitle = "Test Title", + Size = 9999999 + } + }; + + _proxy.SendWebhook(payload, Settings); + } + catch (WebhookException ex) + { + return new NzbDroneValidationFailure("Url", ex.Message); + } + + return null; + } } } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookEpisode.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookEpisode.cs deleted file mode 100644 index a7979b726..000000000 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookEpisode.cs +++ /dev/null @@ -1,32 +0,0 @@ -using NzbDrone.Core.Tv; -using System; - -namespace NzbDrone.Core.Notifications.Webhook -{ - public class WebhookEpisode - { - public WebhookEpisode() { } - - public WebhookEpisode(Episode episode) - { - Id = episode.Id; - SeasonNumber = episode.SeasonNumber; - EpisodeNumber = episode.EpisodeNumber; - Title = episode.Title; - AirDate = episode.AirDate; - AirDateUtc = episode.AirDateUtc; - } - - public int Id { get; set; } - public int EpisodeNumber { get; set; } - public int SeasonNumber { get; set; } - public string Title { get; set; } - public string AirDate { get; set; } - public DateTime? AirDateUtc { get; set; } - - public string Quality { get; set; } - public int QualityVersion { get; set; } - public string ReleaseGroup { get; set; } - public string SceneName { get; set; } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookGrabPayload.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookGrabPayload.cs new file mode 100755 index 000000000..57d8f040a --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookGrabPayload.cs @@ -0,0 +1,8 @@ +namespace NzbDrone.Core.Notifications.Webhook +{ + class WebhookGrabPayload : WebhookPayload + { + public WebhookRemoteMovie RemoteMovie { get; set; } + public WebhookRelease Release { get; set; } + } +} diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs new file mode 100755 index 000000000..7043137c7 --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs @@ -0,0 +1,9 @@ +namespace NzbDrone.Core.Notifications.Webhook +{ + class WebhookImportPayload : WebhookPayload + { + public WebhookRemoteMovie RemoteMovie { get; set; } + public WebhookMovieFile MovieFile { get; set; } + public bool IsUpgrade { get; set; } + } +} diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookMethod.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookMethod.cs old mode 100644 new mode 100755 index 42c080e00..5d6e859a6 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookMethod.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookMethod.cs @@ -1,8 +1,10 @@ -namespace NzbDrone.Core.Notifications.Webhook +using NzbDrone.Common.Http; + +namespace NzbDrone.Core.Notifications.Webhook { public enum WebhookMethod { - POST = RestSharp.Method.POST, - PUT = RestSharp.Method.PUT + POST = HttpMethod.POST, + PUT = HttpMethod.PUT } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookMovie.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookMovie.cs old mode 100644 new mode 100755 index 0d38862e8..0699ae44a --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookMovie.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookMovie.cs @@ -9,6 +9,7 @@ namespace NzbDrone.Core.Notifications.Webhook public int Id { get; set; } public string Title { get; set; } public string FilePath { get; set; } + public string ReleaseDate { get; set; } public WebhookMovie() { } @@ -16,12 +17,11 @@ namespace NzbDrone.Core.Notifications.Webhook { Id = movie.Id; Title = movie.Title; + ReleaseDate = movie.PhysicalReleaseDate().ToString("yyyy-MM-dd"); } - public WebhookMovie(Movie movie, MovieFile movieFile) + public WebhookMovie(Movie movie, MovieFile movieFile) : this(movie) { - Id = movie.Id; - Title = movie.Title; FilePath = Path.Combine(movie.Path, movieFile.RelativePath); } } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookMovieFile.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookMovieFile.cs new file mode 100755 index 000000000..cd19f2923 --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookMovieFile.cs @@ -0,0 +1,28 @@ +using NzbDrone.Core.MediaFiles; + +namespace NzbDrone.Core.Notifications.Webhook +{ + class WebhookMovieFile + { + public WebhookMovieFile() { } + + public WebhookMovieFile(MovieFile movieFile) + { + Id = movieFile.Id; + RelativePath = movieFile.RelativePath; + Path = movieFile.Path; + Quality = movieFile.Quality.Quality.Name; + QualityVersion = movieFile.Quality.Revision.Version; + ReleaseGroup = movieFile.ReleaseGroup; + SceneName = movieFile.SceneName; + } + + public int Id { get; set; } + public string RelativePath { get; set; } + public string Path { get; set; } + public string Quality { get; set; } + public int QualityVersion { get; set; } + public string ReleaseGroup { get; set; } + public string SceneName { get; set; } + } +} diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs old mode 100644 new mode 100755 index 8be45eb18..91a936272 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs @@ -1,11 +1,8 @@ -using System.Collections.Generic; - namespace NzbDrone.Core.Notifications.Webhook { public class WebhookPayload { public string EventType { get; set; } public WebhookMovie Movie { get; set; } - public WebhookRemoteMovie RemoteMovie { get; set; } } } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookProxy.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookProxy.cs new file mode 100755 index 000000000..328c838b8 --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookProxy.cs @@ -0,0 +1,41 @@ +using NzbDrone.Common.Http; +using NzbDrone.Common.Serializer; +using NzbDrone.Core.Rest; + +namespace NzbDrone.Core.Notifications.Webhook +{ + public interface IWebhookProxy + { + void SendWebhook(WebhookPayload payload, WebhookSettings settings); + } + + class WebhookProxy : IWebhookProxy + { + private readonly IHttpClient _httpClient; + + public WebhookProxy(IHttpClient httpClient) + { + _httpClient = httpClient; + } + + public void SendWebhook(WebhookPayload body, WebhookSettings settings) + { + try + { + var request = new HttpRequestBuilder(settings.Url) + .Accept(HttpAccept.Json) + .Build(); + + request.Method = (HttpMethod)settings.Method; + request.Headers.ContentType = "application/json"; + request.SetContent(body.ToJson()); + + _httpClient.Execute(request); + } + catch (RestException ex) + { + throw new WebhookException("Unable to post to webhook: {0}", ex, ex.Message); + } + } + } +} diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookRelease.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookRelease.cs new file mode 100755 index 000000000..05d24ad99 --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookRelease.cs @@ -0,0 +1,27 @@ +using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Qualities; + +namespace NzbDrone.Core.Notifications.Webhook +{ + public class WebhookRelease + { + public WebhookRelease() { } + + public WebhookRelease(QualityModel quality, RemoteMovie remoteMovie) + { + Quality = quality.Quality.Name; + QualityVersion = quality.Revision.Version; + ReleaseGroup = remoteMovie.ParsedMovieInfo.ReleaseGroup; + ReleaseTitle = remoteMovie.Release.Title; + Indexer = remoteMovie.Release.Indexer; + Size = remoteMovie.Release.Size; + } + + public string Quality { get; set; } + public int QualityVersion { get; set; } + public string ReleaseGroup { get; set; } + public string ReleaseTitle { get; set; } + public string Indexer { get; set; } + public long Size { get; set; } + } +} diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookSeries.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookSeries.cs deleted file mode 100644 index 222f9eebb..000000000 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookSeries.cs +++ /dev/null @@ -1,22 +0,0 @@ -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.Notifications.Webhook -{ - public class WebhookSeries - { - public int Id { get; set; } - public string Title { get; set; } - public string Path { get; set; } - public int TvdbId { get; set; } - - public WebhookSeries() { } - - public WebhookSeries(Series series) - { - Id = series.Id; - Title = series.Title; - Path = series.Path; - TvdbId = series.TvdbId; - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookService.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookService.cs deleted file mode 100644 index f3677fbd3..000000000 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookService.cs +++ /dev/null @@ -1,103 +0,0 @@ -using FluentValidation.Results; -using NzbDrone.Core.MediaFiles; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Validation; -using NzbDrone.Core.Rest; -using RestSharp; -using NzbDrone.Core.Qualities; -using NzbDrone.Core.Parser.Model; -using System.Collections.Generic; - -namespace NzbDrone.Core.Notifications.Webhook -{ - public interface IWebhookService - { - void OnDownload(Movie movie, MovieFile movieFile, WebhookSettings settings); - void OnRename(Movie movie, WebhookSettings settings); - void OnGrab(Movie movie, RemoteMovie remoteMovie, QualityModel quality, WebhookSettings settings); - ValidationFailure Test(WebhookSettings settings); - } - - public class WebhookService : IWebhookService - { - public void OnDownload(Movie movie, MovieFile movieFile, WebhookSettings settings) - { - var payload = new WebhookPayload - { - EventType = "Download", - Movie = new WebhookMovie(movie, movieFile), - RemoteMovie = new WebhookRemoteMovie(movie) - }; - - NotifyWebhook(payload, settings); - } - - public void OnRename(Movie movie, WebhookSettings settings) - { - var payload = new WebhookPayload - { - EventType = "Rename", - Movie = new WebhookMovie(movie) - }; - - NotifyWebhook(payload, settings); - } - - public void OnGrab(Movie movie, RemoteMovie remoteMovie, QualityModel quality, WebhookSettings settings) - { - var payload = new WebhookPayload - { - EventType = "Grab", - Movie = new WebhookMovie(movie), - RemoteMovie = new WebhookRemoteMovie(remoteMovie) - }; - NotifyWebhook(payload, settings); - } - - public void NotifyWebhook(WebhookPayload body, WebhookSettings settings) - { - try { - var client = RestClientFactory.BuildClient(settings.Url); - var request = new RestRequest((Method) settings.Method); - request.RequestFormat = DataFormat.Json; - request.AddBody(body); - client.ExecuteAndValidate(request); - } - catch (RestException ex) - { - throw new WebhookException("Unable to post to webhook: {0}", ex, ex.Message); - } - } - - public ValidationFailure Test(WebhookSettings settings) - { - try - { - NotifyWebhook( - new WebhookPayload - { - EventType = "Test", - Movie = new WebhookMovie() - { - Id = 1, - Title = "Test Title", - FilePath = "C:\\testpath", - }, - RemoteMovie = new WebhookRemoteMovie(){ - ImdbId = "tt012345", - Title = "My Awesome Movie!" - } - }, - - settings - ); - } - catch (WebhookException ex) - { - return new NzbDroneValidationFailure("Url", ex.Message); - } - - return null; - } - } -} diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index e85b02d56..4c4ac5cf1 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -986,14 +986,16 @@ - + + + - + + - @@ -1391,4 +1393,4 @@ --> - \ No newline at end of file + From 0a030386f2604f6a31b176727e335c9c088bbf3e Mon Sep 17 00:00:00 2001 From: fhscholl Date: Sat, 28 Oct 2017 11:19:49 -0400 Subject: [PATCH 11/11] Added: Movie_Quality to onGrab (#2221) (Fixes #1833) --- src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) mode change 100644 => 100755 src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs diff --git a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs old mode 100644 new mode 100755 index ffdc075d4..d49414197 --- a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs +++ b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.Specialized; using System.IO; @@ -31,6 +31,7 @@ namespace NzbDrone.Core.Notifications.CustomScript { var movie = message.Movie; var remoteMovie = message.RemoteMovie; + var quality = message.Quality; var environmentVariables = new StringDictionary(); environmentVariables.Add("Radarr_EventType", "Grab"); @@ -42,6 +43,8 @@ namespace NzbDrone.Core.Notifications.CustomScript environmentVariables.Add("Radarr_Release_Indexer", remoteMovie.Release.Indexer); environmentVariables.Add("Radarr_Release_Size", remoteMovie.Release.Size.ToString()); environmentVariables.Add("Radarr_Release_ReleaseGroup", remoteMovie.ParsedMovieInfo.ReleaseGroup ?? string.Empty); + environmentVariables.Add("Radarr_Release_Quality", quality.Quality.Name); + environmentVariables.Add("Radarr_Release_QualityVersion", quality.Revision.Version.ToString()); ExecuteScript(environmentVariables); }