diff --git a/src/NzbDrone.Core/ImportLists/Radarr/RadarrAPIResource.cs b/src/NzbDrone.Core/ImportLists/Radarr/RadarrAPIResource.cs index 1a6b43725..880c30778 100644 --- a/src/NzbDrone.Core/ImportLists/Radarr/RadarrAPIResource.cs +++ b/src/NzbDrone.Core/ImportLists/Radarr/RadarrAPIResource.cs @@ -16,6 +16,7 @@ public class RadarrMovie public int Year { get; set; } public string TitleSlug { get; set; } public int QualityProfileId { get; set; } + public string RootFolderPath { get; set; } public HashSet Tags { get; set; } } @@ -30,4 +31,10 @@ public class RadarrTag public string Label { get; set; } public int Id { get; set; } } + + public class RadarrRootFolder + { + public string Path { get; set; } + public int Id { get; set; } + } } diff --git a/src/NzbDrone.Core/ImportLists/Radarr/RadarrImport.cs b/src/NzbDrone.Core/ImportLists/Radarr/RadarrImport.cs index eb0da5c9e..83e583a18 100644 --- a/src/NzbDrone.Core/ImportLists/Radarr/RadarrImport.cs +++ b/src/NzbDrone.Core/ImportLists/Radarr/RadarrImport.cs @@ -41,16 +41,27 @@ public override ImportListFetchResult Fetch() foreach (var remoteMovie in remoteMovies) { - if ((!Settings.ProfileIds.Any() || Settings.ProfileIds.Contains(remoteMovie.QualityProfileId)) && - (!Settings.TagIds.Any() || Settings.TagIds.Any(x => remoteMovie.Tags.Any(y => y == x)))) + if (Settings.ProfileIds.Any() && !Settings.ProfileIds.Contains(remoteMovie.QualityProfileId)) { - movies.Add(new ImportListMovie - { - TmdbId = remoteMovie.TmdbId, - Title = remoteMovie.Title, - Year = remoteMovie.Year - }); + continue; } + + if (Settings.TagIds.Any() && !Settings.TagIds.Any(x => remoteMovie.Tags.Any(y => y == x))) + { + continue; + } + + if (Settings.RootFolderPaths.Any() && !Settings.RootFolderPaths.Any(rootFolderPath => remoteMovie.RootFolderPath.ContainsIgnoreCase(rootFolderPath))) + { + continue; + } + + movies.Add(new ImportListMovie + { + TmdbId = remoteMovie.TmdbId, + Title = remoteMovie.Title, + Year = remoteMovie.Year + }); } _importListStatusService.RecordSuccess(Definition.Id); @@ -107,6 +118,23 @@ public override object RequestAction(string action, IDictionary }; } + if (action == "getRootFolders") + { + Settings.Validate().Filter("ApiKey").ThrowOnError(); + + var remoteRootfolders = _radarrV3Proxy.GetRootFolders(Settings); + + return new + { + options = remoteRootfolders.OrderBy(d => d.Path, StringComparer.InvariantCultureIgnoreCase) + .Select(d => new + { + value = d.Path, + name = d.Path + }) + }; + } + return new { }; } diff --git a/src/NzbDrone.Core/ImportLists/Radarr/RadarrSettings.cs b/src/NzbDrone.Core/ImportLists/Radarr/RadarrSettings.cs index 36fa755b7..f3cc3c173 100644 --- a/src/NzbDrone.Core/ImportLists/Radarr/RadarrSettings.cs +++ b/src/NzbDrone.Core/ImportLists/Radarr/RadarrSettings.cs @@ -26,6 +26,7 @@ public RadarrSettings() ApiKey = ""; ProfileIds = Array.Empty(); TagIds = Array.Empty(); + RootFolderPaths = Array.Empty(); } [FieldDefinition(0, Label = "Full URL", HelpText = "URL, including port, of the Radarr instance to import from (Radarr 3.0 or higher)")] @@ -40,6 +41,9 @@ public RadarrSettings() [FieldDefinition(3, Type = FieldType.Select, SelectOptionsProviderAction = "getTags", Label = "Tags", HelpText = "Tags from the source instance to import from")] public IEnumerable TagIds { get; set; } + [FieldDefinition(4, Type = FieldType.Select, SelectOptionsProviderAction = "getRootFolders", Label = "Root Folders", HelpText = "Root Folders from the source instance to import from")] + public IEnumerable RootFolderPaths { get; set; } + public NzbDroneValidationResult Validate() { return new NzbDroneValidationResult(Validator.Validate(this)); diff --git a/src/NzbDrone.Core/ImportLists/Radarr/RadarrV3Proxy.cs b/src/NzbDrone.Core/ImportLists/Radarr/RadarrV3Proxy.cs index 70867853d..888297a31 100644 --- a/src/NzbDrone.Core/ImportLists/Radarr/RadarrV3Proxy.cs +++ b/src/NzbDrone.Core/ImportLists/Radarr/RadarrV3Proxy.cs @@ -13,6 +13,7 @@ public interface IRadarrV3Proxy { List GetMovies(RadarrSettings settings); List GetProfiles(RadarrSettings settings); + List GetRootFolders(RadarrSettings settings); List GetTags(RadarrSettings settings); ValidationFailure Test(RadarrSettings settings); } @@ -38,6 +39,11 @@ public List GetProfiles(RadarrSettings settings) return Execute("/api/v3/qualityprofile", settings); } + public List GetRootFolders(RadarrSettings settings) + { + return Execute("api/v3/rootfolder", settings); + } + public List GetTags(RadarrSettings settings) { return Execute("/api/v3/tag", settings);