diff --git a/src/NzbDrone.Api.Test/ClientSchemaTests/SchemaBuilderFixture.cs b/src/NzbDrone.Api.Test/ClientSchemaTests/SchemaBuilderFixture.cs
index 385a9b989..24aee8f5e 100644
--- a/src/NzbDrone.Api.Test/ClientSchemaTests/SchemaBuilderFixture.cs
+++ b/src/NzbDrone.Api.Test/ClientSchemaTests/SchemaBuilderFixture.cs
@@ -1,6 +1,6 @@
-using FluentAssertions;
+using FluentAssertions;
using NUnit.Framework;
-using NzbDrone.Api.ClientSchema;
+using Radarr.Http.ClientSchema;
using NzbDrone.Core.Annotations;
using NzbDrone.Test.Common;
@@ -28,8 +28,8 @@ namespace NzbDrone.Api.Test.ClientSchemaTests
var schema = SchemaBuilder.ToSchema(model);
- schema.Should().Contain(c => c.Order == 1 && c.Name == "LastName" && c.Label == "Last Name" && c.HelpText == "Your Last Name" && (string) c.Value == "Poop");
- schema.Should().Contain(c => c.Order == 0 && c.Name == "FirstName" && c.Label == "First Name" && c.HelpText == "Your First Name" && (string) c.Value == "Bob");
+ schema.Should().Contain(c => c.Order == 1 && c.Name == "lastName" && c.Label == "Last Name" && c.HelpText == "Your Last Name" && (string) c.Value == "Poop");
+ schema.Should().Contain(c => c.Order == 0 && c.Name == "firstName" && c.Label == "First Name" && c.HelpText == "Your First Name" && (string) c.Value == "Bob");
}
}
@@ -45,4 +45,4 @@ namespace NzbDrone.Api.Test.ClientSchemaTests
public string Other { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Api.Test/NzbDrone.Api.Test.csproj b/src/NzbDrone.Api.Test/NzbDrone.Api.Test.csproj
index 34c33d628..df6a64f8e 100644
--- a/src/NzbDrone.Api.Test/NzbDrone.Api.Test.csproj
+++ b/src/NzbDrone.Api.Test/NzbDrone.Api.Test.csproj
@@ -8,7 +8,7 @@
Library
Properties
NzbDrone.Api.Test
- NzbDrone.Api.Test
+ Radarr.Api.Test
v4.6.1
512
..\
@@ -92,6 +92,10 @@
{CADDFCE0-7509-4430-8364-2074E1EEFCA2}
NzbDrone.Test.Common
+
+ {c5953dab-89db-46d9-a401-d620f54b776e}
+ Radarr.Http
+
diff --git a/src/NzbDrone.Api.Test/Properties/AssemblyInfo.cs b/src/NzbDrone.Api.Test/Properties/AssemblyInfo.cs
index b45cbd098..db27f2a96 100644
--- a/src/NzbDrone.Api.Test/Properties/AssemblyInfo.cs
+++ b/src/NzbDrone.Api.Test/Properties/AssemblyInfo.cs
@@ -4,11 +4,11 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
-[assembly: AssemblyTitle("NzbDrone.Api.Test")]
+[assembly: AssemblyTitle("Radarr.Api.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("NzbDrone.Api.Test")]
+[assembly: AssemblyProduct("Radarr.Api.Test")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
diff --git a/src/NzbDrone.Api/Blacklist/BlacklistModule.cs b/src/NzbDrone.Api/Blacklist/BlacklistModule.cs
index 1687b31e3..36ab46b36 100644
--- a/src/NzbDrone.Api/Blacklist/BlacklistModule.cs
+++ b/src/NzbDrone.Api/Blacklist/BlacklistModule.cs
@@ -1,9 +1,10 @@
-using NzbDrone.Core.Blacklisting;
+using NzbDrone.Core.Blacklisting;
using NzbDrone.Core.Datastore;
+using Radarr.Http;
namespace NzbDrone.Api.Blacklist
{
- public class BlacklistModule : NzbDroneRestModule
+ public class BlacklistModule : RadarrRestModule
{
private readonly IBlacklistService _blacklistService;
diff --git a/src/NzbDrone.Api/Blacklist/BlacklistResource.cs b/src/NzbDrone.Api/Blacklist/BlacklistResource.cs
index f3259fd3c..acb6484e6 100644
--- a/src/NzbDrone.Api/Blacklist/BlacklistResource.cs
+++ b/src/NzbDrone.Api/Blacklist/BlacklistResource.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using NzbDrone.Api.Movies;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Indexers;
diff --git a/src/NzbDrone.Api/ClientSchema/FieldDefinitionAttribute.cs b/src/NzbDrone.Api/ClientSchema/FieldDefinitionAttribute.cs
deleted file mode 100644
index 4e796bd8c..000000000
--- a/src/NzbDrone.Api/ClientSchema/FieldDefinitionAttribute.cs
+++ /dev/null
@@ -1,4 +0,0 @@
-namespace NzbDrone.Api.ClientSchema
-{
-
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Api/ClientSchema/SchemaBuilder.cs b/src/NzbDrone.Api/ClientSchema/SchemaBuilder.cs
deleted file mode 100644
index 496a1ed18..000000000
--- a/src/NzbDrone.Api/ClientSchema/SchemaBuilder.cs
+++ /dev/null
@@ -1,193 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using Newtonsoft.Json.Linq;
-using NzbDrone.Common.EnsureThat;
-using NzbDrone.Common.Extensions;
-using NzbDrone.Common.Reflection;
-using NzbDrone.Core.Annotations;
-using NzbDrone.Core.Download.Clients.Nzbget;
-using NzbDrone.Core.Qualities;
-using NzbDrone.Core.Profiles;
-
-namespace NzbDrone.Api.ClientSchema
-{
- public static class SchemaBuilder
- {
- public static List ToSchema(object model)
- {
- Ensure.That(model, () => model).IsNotNull();
-
- var properties = model.GetType().GetSimpleProperties();
-
- var result = new List(properties.Count);
-
- foreach (var propertyInfo in properties)
- {
- var fieldAttribute = propertyInfo.GetAttribute(false);
-
- if (fieldAttribute != null)
- {
-
- var field = new Field
- {
- Name = propertyInfo.Name,
- Label = fieldAttribute.Label,
- HelpText = fieldAttribute.HelpText,
- HelpLink = fieldAttribute.HelpLink,
- Order = fieldAttribute.Order,
- Advanced = fieldAttribute.Advanced,
- Type = fieldAttribute.Type.ToString().ToLowerInvariant()
- };
-
- var value = propertyInfo.GetValue(model, null);
-
- if (propertyInfo.PropertyType.HasAttribute())
- {
- int intVal = (int)value;
- value = Enum.GetValues(propertyInfo.PropertyType)
- .Cast()
- .Where(f=> (f & intVal) == f)
- .ToList();
- }
-
- if (value != null)
- {
- field.Value = value;
- }
-
- if (fieldAttribute.Type == FieldType.Select || fieldAttribute.Type == FieldType.Tag)
- {
- field.SelectOptions = GetSelectOptions(fieldAttribute.SelectOptions);
- }
-
- result.Add(field);
- }
- }
-
- return result.OrderBy(r => r.Order).ToList();
- }
-
- public static object ReadFromSchema(List fields, Type targetType)
- {
- Ensure.That(targetType, () => targetType).IsNotNull();
-
- var properties = targetType.GetSimpleProperties();
-
- var target = Activator.CreateInstance(targetType);
-
- foreach (var propertyInfo in properties)
- {
- var fieldAttribute = propertyInfo.GetAttribute(false);
-
- if (fieldAttribute != null)
- {
- var field = fields.Find(f => f.Name == propertyInfo.Name);
-
- if (propertyInfo.PropertyType == typeof(int))
- {
- var value = field.Value.ToString().ParseInt32();
- propertyInfo.SetValue(target, value ?? 0, null);
- }
-
- else if (propertyInfo.PropertyType == typeof(long))
- {
- var value = field.Value.ToString().ParseInt64();
- propertyInfo.SetValue(target, value ?? 0, null);
- }
-
- else if (propertyInfo.PropertyType == typeof(int?))
- {
- var value = field.Value.ToString().ParseInt32();
- propertyInfo.SetValue(target, value, null);
- }
-
- else if (propertyInfo.PropertyType == typeof(Nullable))
- {
- var value = field.Value.ToString().ParseInt64();
- propertyInfo.SetValue(target, value, null);
- }
-
- else if (propertyInfo.PropertyType == typeof(IEnumerable))
- {
- IEnumerable value;
-
- if (field.Value?.GetType() == typeof(JArray))
- {
- value = ((JArray)field.Value).Select(s => s.Value());
- }
-
- else
- {
- value = field.Value?.ToString().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(s => Convert.ToInt32(s));
- }
-
- propertyInfo.SetValue(target, value, null);
- }
-
- else if (propertyInfo.PropertyType == typeof(IEnumerable))
- {
- IEnumerable value;
-
- if (field.Value.GetType() == typeof(JArray))
- {
- value = ((JArray)field.Value).Select(s => s.Value());
- }
-
- else
- {
- value = field.Value.ToString().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- }
-
- propertyInfo.SetValue(target, value, null);
- }
-
- else if (propertyInfo.PropertyType.HasAttribute())
- {
- int value = field.Value.ToString().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(s => Convert.ToInt32(s)).Sum();
- propertyInfo.SetValue(target, value, null);
- }
-
- else
- {
- propertyInfo.SetValue(target, field.Value, null);
- }
- }
- }
-
- return target;
-
- }
-
- public static T ReadFromSchema(List fields)
- {
- return (T)ReadFromSchema(fields, typeof(T));
- }
-
- private static List GetSelectOptions(Type selectOptions)
- {
- if (selectOptions == null || selectOptions == typeof(Profile))
- {
- return new List();
- }
-
- if (selectOptions == typeof(Quality))
- {
- var qOptions = from Quality q in selectOptions.GetProperties(BindingFlags.Static | BindingFlags.Public)
- select new SelectOption {Name = q.Name, Value = q.Id};
- return qOptions.OrderBy(o => o.Value).ToList();
- }
-
- var options = from Enum e in Enum.GetValues(selectOptions)
- select new SelectOption { Value = Convert.ToInt32(e), Name = e.ToString() };
-
- if (selectOptions == typeof(NzbgetPriority))
- {
- return options.OrderBy(o => o.Value).ToList();
- }
-
- return options.OrderBy(o => o.Name).ToList();
- }
- }
-}
diff --git a/src/NzbDrone.Api/ClientSchema/SchemaDeserializer.cs b/src/NzbDrone.Api/ClientSchema/SchemaDeserializer.cs
deleted file mode 100644
index 6af07257f..000000000
--- a/src/NzbDrone.Api/ClientSchema/SchemaDeserializer.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace NzbDrone.Api.ClientSchema
-{
- public static class SchemaDeserializer
- {
-
- }
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Api/Commands/CommandModule.cs b/src/NzbDrone.Api/Commands/CommandModule.cs
index 1395d68ec..f828845ed 100644
--- a/src/NzbDrone.Api/Commands/CommandModule.cs
+++ b/src/NzbDrone.Api/Commands/CommandModule.cs
@@ -1,20 +1,22 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using NLog;
-using NzbDrone.Api.Extensions;
-using NzbDrone.Api.Validation;
+using Radarr.Http.Extensions;
+using Radarr.Http.Validation;
using NzbDrone.Common;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.ProgressMessaging;
using NzbDrone.SignalR;
+using Radarr.Http;
+using Radarr.Http.Mapping;
namespace NzbDrone.Api.Commands
{
- public class CommandModule : NzbDroneRestModuleWithSignalR, IHandle
+ public class CommandModule : RadarrRestModuleWithSignalR, IHandle
{
private readonly IManageCommandQueue _commandQueueManager;
private readonly IServiceFactory _serviceFactory;
@@ -73,4 +75,4 @@ namespace NzbDrone.Api.Commands
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Api/Commands/CommandResource.cs b/src/NzbDrone.Api/Commands/CommandResource.cs
index cf09f12ac..29a72ebe4 100644
--- a/src/NzbDrone.Api/Commands/CommandResource.cs
+++ b/src/NzbDrone.Api/Commands/CommandResource.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Messaging.Commands;
namespace NzbDrone.Api.Commands
diff --git a/src/NzbDrone.Api/Config/DownloadClientConfigModule.cs b/src/NzbDrone.Api/Config/DownloadClientConfigModule.cs
index e4fdef50f..3e19e7564 100644
--- a/src/NzbDrone.Api/Config/DownloadClientConfigModule.cs
+++ b/src/NzbDrone.Api/Config/DownloadClientConfigModule.cs
@@ -1,4 +1,4 @@
-using FluentValidation;
+using FluentValidation;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Validation.Paths;
@@ -6,19 +6,10 @@ namespace NzbDrone.Api.Config
{
public class DownloadClientConfigModule : NzbDroneConfigModule
{
- public DownloadClientConfigModule(IConfigService configService,
- RootFolderValidator rootFolderValidator,
- PathExistsValidator pathExistsValidator,
- MappedNetworkDriveValidator mappedNetworkDriveValidator)
+ public DownloadClientConfigModule(IConfigService configService)
: base(configService)
{
- SharedValidator.RuleFor(c => c.DownloadedMoviesFolder)
- .Cascade(CascadeMode.StopOnFirstFailure)
- .IsValidPath()
- .SetValidator(rootFolderValidator)
- .SetValidator(mappedNetworkDriveValidator)
- .SetValidator(pathExistsValidator)
- .When(c => !string.IsNullOrWhiteSpace(c.DownloadedMoviesFolder));
+
}
protected override DownloadClientConfigResource ToResource(IConfigService model)
@@ -26,4 +17,4 @@ namespace NzbDrone.Api.Config
return DownloadClientConfigResourceMapper.ToResource(model);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Api/Config/DownloadClientConfigResource.cs b/src/NzbDrone.Api/Config/DownloadClientConfigResource.cs
index 4d3a08add..cd7430817 100644
--- a/src/NzbDrone.Api/Config/DownloadClientConfigResource.cs
+++ b/src/NzbDrone.Api/Config/DownloadClientConfigResource.cs
@@ -1,13 +1,11 @@
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Configuration;
namespace NzbDrone.Api.Config
{
public class DownloadClientConfigResource : RestResource
{
- public string DownloadedMoviesFolder { get; set; }
public string DownloadClientWorkingFolders { get; set; }
- public int DownloadedMoviesScanInterval { get; set; }
public bool EnableCompletedDownloadHandling { get; set; }
public bool RemoveCompletedDownloads { get; set; }
@@ -23,9 +21,7 @@ namespace NzbDrone.Api.Config
{
return new DownloadClientConfigResource
{
- DownloadedMoviesFolder = model.DownloadedMoviesFolder,
DownloadClientWorkingFolders = model.DownloadClientWorkingFolders,
- DownloadedMoviesScanInterval = model.DownloadedMoviesScanInterval,
EnableCompletedDownloadHandling = model.EnableCompletedDownloadHandling,
RemoveCompletedDownloads = model.RemoveCompletedDownloads,
diff --git a/src/NzbDrone.Api/Config/HostConfigModule.cs b/src/NzbDrone.Api/Config/HostConfigModule.cs
index 367bf770d..23a59b676 100644
--- a/src/NzbDrone.Api/Config/HostConfigModule.cs
+++ b/src/NzbDrone.Api/Config/HostConfigModule.cs
@@ -1,4 +1,5 @@
-using System.Linq;
+using System.IO;
+using System.Linq;
using System.Reflection;
using FluentValidation;
using NzbDrone.Common.EnvironmentInfo;
@@ -8,10 +9,11 @@ using NzbDrone.Core.Configuration;
using NzbDrone.Core.Update;
using NzbDrone.Core.Validation;
using NzbDrone.Core.Validation.Paths;
+using Radarr.Http;
namespace NzbDrone.Api.Config
{
- public class HostConfigModule : NzbDroneRestModule
+ public class HostConfigModule : RadarrRestModule
{
private readonly IConfigFileProvider _configFileProvider;
private readonly IConfigService _configService;
@@ -45,6 +47,10 @@ namespace NzbDrone.Api.Config
SharedValidator.RuleFor(c => c.Branch).NotEmpty().WithMessage("Branch name is required, 'master' is the default");
SharedValidator.RuleFor(c => c.UpdateScriptPath).IsValidPath().When(c => c.UpdateMechanism == UpdateMechanism.Script);
+
+ SharedValidator.RuleFor(c => c.BackupFolder).IsValidPath().When(c => Path.IsPathRooted(c.BackupFolder));
+ SharedValidator.RuleFor(c => c.BackupInterval).InclusiveBetween(1, 7);
+ SharedValidator.RuleFor(c => c.BackupRetention).InclusiveBetween(1, 90);
}
private HostConfigResource GetHostConfig()
diff --git a/src/NzbDrone.Api/Config/HostConfigResource.cs b/src/NzbDrone.Api/Config/HostConfigResource.cs
index 930e0301c..a7e042db1 100644
--- a/src/NzbDrone.Api/Config/HostConfigResource.cs
+++ b/src/NzbDrone.Api/Config/HostConfigResource.cs
@@ -1,4 +1,4 @@
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Authentication;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Update;
@@ -33,6 +33,9 @@ namespace NzbDrone.Api.Config
public string ProxyPassword { get; set; }
public string ProxyBypassFilter { get; set; }
public bool ProxyBypassLocalAddresses { get; set; }
+ public string BackupFolder { get; set; }
+ public int BackupInterval { get; set; }
+ public int BackupRetention { get; set; }
}
public static class HostConfigResourceMapper
@@ -66,7 +69,10 @@ namespace NzbDrone.Api.Config
ProxyUsername = configService.ProxyUsername,
ProxyPassword = configService.ProxyPassword,
ProxyBypassFilter = configService.ProxyBypassFilter,
- ProxyBypassLocalAddresses = configService.ProxyBypassLocalAddresses
+ ProxyBypassLocalAddresses = configService.ProxyBypassLocalAddresses,
+ BackupFolder = configService.BackupFolder,
+ BackupInterval = configService.BackupInterval,
+ BackupRetention = configService.BackupRetention
};
}
}
diff --git a/src/NzbDrone.Api/Config/IndexerConfigModule.cs b/src/NzbDrone.Api/Config/IndexerConfigModule.cs
index db5299944..7c80ef1a9 100644
--- a/src/NzbDrone.Api/Config/IndexerConfigModule.cs
+++ b/src/NzbDrone.Api/Config/IndexerConfigModule.cs
@@ -1,5 +1,5 @@
using FluentValidation;
-using NzbDrone.Api.Validation;
+using Radarr.Http.Validation;
using NzbDrone.Core.Configuration;
namespace NzbDrone.Api.Config
diff --git a/src/NzbDrone.Api/Config/IndexerConfigResource.cs b/src/NzbDrone.Api/Config/IndexerConfigResource.cs
index bdcfbfd9c..854ea6b51 100644
--- a/src/NzbDrone.Api/Config/IndexerConfigResource.cs
+++ b/src/NzbDrone.Api/Config/IndexerConfigResource.cs
@@ -1,4 +1,4 @@
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Parser;
diff --git a/src/NzbDrone.Api/Config/MediaManagementConfigResource.cs b/src/NzbDrone.Api/Config/MediaManagementConfigResource.cs
index e5147e601..53e03e87e 100644
--- a/src/NzbDrone.Api/Config/MediaManagementConfigResource.cs
+++ b/src/NzbDrone.Api/Config/MediaManagementConfigResource.cs
@@ -1,4 +1,4 @@
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles;
@@ -33,10 +33,10 @@ namespace NzbDrone.Api.Config
{
return new MediaManagementConfigResource
{
- AutoUnmonitorPreviouslyDownloadedEpisodes = model.AutoUnmonitorPreviouslyDownloadedEpisodes,
+ AutoUnmonitorPreviouslyDownloadedEpisodes = model.AutoUnmonitorPreviouslyDownloadedMovies,
RecycleBin = model.RecycleBin,
AutoDownloadPropers = model.AutoDownloadPropers,
- CreateEmptySeriesFolders = model.CreateEmptySeriesFolders,
+ CreateEmptySeriesFolders = model.CreateEmptyMovieFolders,
FileDate = model.FileDate,
AutoRenameFolders = model.AutoRenameFolders,
PathsDefaultStatic = model.PathsDefaultStatic,
diff --git a/src/NzbDrone.Api/Config/NamingConfigModule.cs b/src/NzbDrone.Api/Config/NamingConfigModule.cs
index 42efaa49a..77422568c 100644
--- a/src/NzbDrone.Api/Config/NamingConfigModule.cs
+++ b/src/NzbDrone.Api/Config/NamingConfigModule.cs
@@ -6,11 +6,13 @@ using Nancy.Responses;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Organizer;
using Nancy.ModelBinding;
-using NzbDrone.Api.Extensions;
+using Radarr.Http.Extensions;
+using Radarr.Http;
+using Radarr.Http.Mapping;
namespace NzbDrone.Api.Config
{
- public class NamingConfigModule : NzbDroneRestModule
+ public class NamingConfigModule : RadarrRestModule
{
private readonly INamingConfigService _namingConfigService;
private readonly IFilenameSampleService _filenameSampleService;
diff --git a/src/NzbDrone.Api/Config/NamingConfigResource.cs b/src/NzbDrone.Api/Config/NamingConfigResource.cs
index 9e657e36e..131f6459c 100644
--- a/src/NzbDrone.Api/Config/NamingConfigResource.cs
+++ b/src/NzbDrone.Api/Config/NamingConfigResource.cs
@@ -1,4 +1,4 @@
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Organizer;
namespace NzbDrone.Api.Config
diff --git a/src/NzbDrone.Api/Config/NetImportConfigModule.cs b/src/NzbDrone.Api/Config/NetImportConfigModule.cs
index f805e8c2d..d93f3b18b 100644
--- a/src/NzbDrone.Api/Config/NetImportConfigModule.cs
+++ b/src/NzbDrone.Api/Config/NetImportConfigModule.cs
@@ -1,5 +1,5 @@
-using FluentValidation;
-using NzbDrone.Api.Validation;
+using FluentValidation;
+using Radarr.Http.Validation;
using NzbDrone.Core.Configuration;
namespace NzbDrone.Api.Config
@@ -19,4 +19,4 @@ namespace NzbDrone.Api.Config
return NetImportConfigResourceMapper.ToResource(model);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Api/Config/NetImportConfigResource.cs b/src/NzbDrone.Api/Config/NetImportConfigResource.cs
index 942a2177d..c70b25ed2 100644
--- a/src/NzbDrone.Api/Config/NetImportConfigResource.cs
+++ b/src/NzbDrone.Api/Config/NetImportConfigResource.cs
@@ -1,4 +1,4 @@
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Configuration;
namespace NzbDrone.Api.Config
diff --git a/src/NzbDrone.Api/Config/NzbDroneConfigModule.cs b/src/NzbDrone.Api/Config/NzbDroneConfigModule.cs
index e5d324950..acc29f8bf 100644
--- a/src/NzbDrone.Api/Config/NzbDroneConfigModule.cs
+++ b/src/NzbDrone.Api/Config/NzbDroneConfigModule.cs
@@ -1,11 +1,12 @@
-using System.Linq;
+using System.Linq;
using System.Reflection;
-using NzbDrone.Api.REST;
+using Radarr.Http;
+using Radarr.Http.REST;
using NzbDrone.Core.Configuration;
namespace NzbDrone.Api.Config
{
- public abstract class NzbDroneConfigModule : NzbDroneRestModule where TResource : RestResource, new()
+ public abstract class NzbDroneConfigModule : RadarrRestModule where TResource : RestResource, new()
{
private readonly IConfigService _configService;
diff --git a/src/NzbDrone.Api/Config/UiConfigResource.cs b/src/NzbDrone.Api/Config/UiConfigResource.cs
index 7c7d27b67..988b976b6 100644
--- a/src/NzbDrone.Api/Config/UiConfigResource.cs
+++ b/src/NzbDrone.Api/Config/UiConfigResource.cs
@@ -1,4 +1,4 @@
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Configuration;
namespace NzbDrone.Api.Config
diff --git a/src/NzbDrone.Api/DiskSpace/DiskSpaceModule.cs b/src/NzbDrone.Api/DiskSpace/DiskSpaceModule.cs
index f6d8354b4..0a43fad9b 100644
--- a/src/NzbDrone.Api/DiskSpace/DiskSpaceModule.cs
+++ b/src/NzbDrone.Api/DiskSpace/DiskSpaceModule.cs
@@ -1,9 +1,10 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using NzbDrone.Core.DiskSpace;
+using Radarr.Http;
namespace NzbDrone.Api.DiskSpace
{
- public class DiskSpaceModule :NzbDroneRestModule
+ public class DiskSpaceModule :RadarrRestModule
{
private readonly IDiskSpaceService _diskSpaceService;
diff --git a/src/NzbDrone.Api/DiskSpace/DiskSpaceResource.cs b/src/NzbDrone.Api/DiskSpace/DiskSpaceResource.cs
index fc36f9d5c..f95c2d2a4 100644
--- a/src/NzbDrone.Api/DiskSpace/DiskSpaceResource.cs
+++ b/src/NzbDrone.Api/DiskSpace/DiskSpaceResource.cs
@@ -1,4 +1,4 @@
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
namespace NzbDrone.Api.DiskSpace
{
diff --git a/src/NzbDrone.Api/ExtraFiles/ExtraFileModule.cs b/src/NzbDrone.Api/ExtraFiles/ExtraFileModule.cs
index ed48df23b..040aae79a 100644
--- a/src/NzbDrone.Api/ExtraFiles/ExtraFileModule.cs
+++ b/src/NzbDrone.Api/ExtraFiles/ExtraFileModule.cs
@@ -1,13 +1,14 @@
using System.Collections.Generic;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Extras.Files;
using NzbDrone.Core.Extras.Metadata.Files;
using NzbDrone.Core.Extras.Others;
using NzbDrone.Core.Extras.Subtitles;
+using Radarr.Http;
namespace NzbDrone.Api.ExtraFiles
{
- public class ExtraFileModule : NzbDroneRestModule
+ public class ExtraFileModule : RadarrRestModule
{
private readonly IExtraFileService _subtitleFileService;
private readonly IExtraFileService _metadataFileService;
diff --git a/src/NzbDrone.Api/ExtraFiles/ExtraFileResource.cs b/src/NzbDrone.Api/ExtraFiles/ExtraFileResource.cs
index e4f19475b..667f7ca47 100644
--- a/src/NzbDrone.Api/ExtraFiles/ExtraFileResource.cs
+++ b/src/NzbDrone.Api/ExtraFiles/ExtraFileResource.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Extras.Files;
using NzbDrone.Core.Extras.Metadata.Files;
using NzbDrone.Core.Extras.Others;
diff --git a/src/NzbDrone.Api/FileSystem/FileSystemModule.cs b/src/NzbDrone.Api/FileSystem/FileSystemModule.cs
index 67c2be7bd..47c2773e2 100644
--- a/src/NzbDrone.Api/FileSystem/FileSystemModule.cs
+++ b/src/NzbDrone.Api/FileSystem/FileSystemModule.cs
@@ -1,8 +1,8 @@
-using System;
+using System;
using System.IO;
using System.Linq;
using Nancy;
-using NzbDrone.Api.Extensions;
+using Radarr.Http.Extensions;
using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.MediaFiles;
@@ -31,15 +31,10 @@ namespace NzbDrone.Api.FileSystem
private Response GetContents()
{
var pathQuery = Request.Query.path;
- var includeFilesQuery = Request.Query.includeFiles;
- bool includeFiles = false;
+ var includeFiles = Request.GetBooleanQueryParameter("includeFiles");
+ var allowFoldersWithoutTrailingSlashes = Request.GetBooleanQueryParameter("allowFoldersWithoutTrailingSlashes");
- if (includeFilesQuery.HasValue)
- {
- includeFiles = Convert.ToBoolean(includeFilesQuery.Value);
- }
-
- return _fileSystemLookupService.LookupContents((string)pathQuery.Value, includeFiles).AsResponse();
+ return _fileSystemLookupService.LookupContents((string)pathQuery.Value, includeFiles, allowFoldersWithoutTrailingSlashes).AsResponse();
}
private Response GetEntityType()
@@ -73,4 +68,4 @@ namespace NzbDrone.Api.FileSystem
}).AsResponse();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Api/Frontend/Mappers/IndexHtmlMapper.cs b/src/NzbDrone.Api/Frontend/Mappers/IndexHtmlMapper.cs
deleted file mode 100644
index 46b5d9c37..000000000
--- a/src/NzbDrone.Api/Frontend/Mappers/IndexHtmlMapper.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-using System;
-using System.IO;
-using System.Text.RegularExpressions;
-using Nancy;
-using NLog;
-using NzbDrone.Common.Disk;
-using NzbDrone.Common.EnvironmentInfo;
-using NzbDrone.Core.Analytics;
-using NzbDrone.Core.Configuration;
-
-namespace NzbDrone.Api.Frontend.Mappers
-{
- public class IndexHtmlMapper : StaticResourceMapperBase
- {
- private readonly IDiskProvider _diskProvider;
- private readonly IConfigFileProvider _configFileProvider;
- private readonly IAnalyticsService _analyticsService;
- private readonly Func _cacheBreakProviderFactory;
- private readonly string _indexPath;
- private static readonly Regex ReplaceRegex = new Regex(@"(?:(?href|src|content)=\"")(?.*?(?css|js|png|ico|ics|svg|json|xml))(?:\"")(?:\s(?data-no-hash))?", RegexOptions.Compiled | RegexOptions.IgnoreCase);
-
- private static string API_KEY;
- private static string URL_BASE;
- private string _generatedContent
- ;
-
- public IndexHtmlMapper(IAppFolderInfo appFolderInfo,
- IDiskProvider diskProvider,
- IConfigFileProvider configFileProvider,
- IAnalyticsService analyticsService,
- Func cacheBreakProviderFactory,
- Logger logger)
- : base(diskProvider, logger)
- {
- _diskProvider = diskProvider;
- _configFileProvider = configFileProvider;
- _analyticsService = analyticsService;
- _cacheBreakProviderFactory = cacheBreakProviderFactory;
- _indexPath = Path.Combine(appFolderInfo.StartUpFolder, _configFileProvider.UiFolder, "index.html");
-
- API_KEY = configFileProvider.ApiKey;
- URL_BASE = configFileProvider.UrlBase;
- }
-
- public override string Map(string resourceUrl)
- {
- return _indexPath;
- }
-
- public override bool CanHandle(string resourceUrl)
- {
- resourceUrl = resourceUrl.ToLowerInvariant();
-
- return !resourceUrl.StartsWith("/content") &&
- !resourceUrl.StartsWith("/mediacover") &&
- !resourceUrl.Contains(".") &&
- !resourceUrl.StartsWith("/login");
- }
-
- public override Response GetResponse(string resourceUrl)
- {
- var response = base.GetResponse(resourceUrl);
- response.Headers["X-UA-Compatible"] = "IE=edge";
-
- return response;
- }
-
- protected override Stream GetContentStream(string filePath)
- {
- var text = GetIndexText();
-
- var stream = new MemoryStream();
- var writer = new StreamWriter(stream);
- writer.Write(text);
- writer.Flush();
- stream.Position = 0;
- return stream;
- }
-
- private string GetIndexText()
- {
- if (RuntimeInfo.IsProduction && _generatedContent != null)
- {
- return _generatedContent;
- }
-
- var text = _diskProvider.ReadAllText(_indexPath);
-
- var cacheBreakProvider = _cacheBreakProviderFactory();
-
- text = ReplaceRegex.Replace(text, match =>
- {
- string url;
-
- if (match.Groups["nohash"].Success)
- {
- url = match.Groups["path"].Value;
- }
-
- else
- {
- url = cacheBreakProvider.AddCacheBreakerToPath(match.Groups["path"].Value);
- }
-
- return string.Format("{0}=\"{1}{2}\"", match.Groups["attribute"].Value, URL_BASE, url);
- });
-
- text = text.Replace("API_ROOT", URL_BASE + "/api");
- text = text.Replace("API_KEY", API_KEY);
- text = text.Replace("APP_VERSION", BuildInfo.Version.ToString());
- text = text.Replace("APP_BRANCH", _configFileProvider.Branch.ToLower());
- text = text.Replace("APP_ANALYTICS", _analyticsService.IsEnabled.ToString().ToLowerInvariant());
- text = text.Replace("URL_BASE", URL_BASE);
- text = text.Replace("PRODUCTION", RuntimeInfo.IsProduction.ToString().ToLowerInvariant());
-
- _generatedContent = text;
-
- return _generatedContent;
- }
- }
-}
diff --git a/src/NzbDrone.Api/Frontend/Mappers/LoginHtmlMapper.cs b/src/NzbDrone.Api/Frontend/Mappers/LoginHtmlMapper.cs
deleted file mode 100644
index 974e117f9..000000000
--- a/src/NzbDrone.Api/Frontend/Mappers/LoginHtmlMapper.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-using System;
-using System.IO;
-using System.Text.RegularExpressions;
-using Nancy;
-using NLog;
-using NzbDrone.Common.Disk;
-using NzbDrone.Common.EnvironmentInfo;
-using NzbDrone.Core.Configuration;
-
-namespace NzbDrone.Api.Frontend.Mappers
-{
- public class LoginHtmlMapper : StaticResourceMapperBase
- {
- private readonly IDiskProvider _diskProvider;
- private readonly IConfigFileProvider _configFileProvider;
- private readonly Func _cacheBreakProviderFactory;
- private readonly string _indexPath;
- private static readonly Regex ReplaceRegex = new Regex("(?<=(?:href|src|data-main)=\").*?(?=\")", RegexOptions.Compiled | RegexOptions.IgnoreCase);
-
- private static string URL_BASE;
- private string _generatedContent;
-
- public LoginHtmlMapper(IAppFolderInfo appFolderInfo,
- IDiskProvider diskProvider,
- IConfigFileProvider configFileProvider,
- Func cacheBreakProviderFactory,
- Logger logger)
- : base(diskProvider, logger)
- {
- _diskProvider = diskProvider;
- _configFileProvider = configFileProvider;
- _cacheBreakProviderFactory = cacheBreakProviderFactory;
- _indexPath = Path.Combine(appFolderInfo.StartUpFolder, _configFileProvider.UiFolder, "login.html");
-
- URL_BASE = configFileProvider.UrlBase;
- }
-
- public override string Map(string resourceUrl)
- {
- return _indexPath;
- }
-
- public override bool CanHandle(string resourceUrl)
- {
- return resourceUrl.StartsWith("/login");
- }
-
- public override Response GetResponse(string resourceUrl)
- {
- var response = base.GetResponse(resourceUrl);
- response.Headers["X-UA-Compatible"] = "IE=edge";
-
- return response;
- }
-
- protected override Stream GetContentStream(string filePath)
- {
- var text = GetLoginText();
-
- var stream = new MemoryStream();
- var writer = new StreamWriter(stream);
- writer.Write(text);
- writer.Flush();
- stream.Position = 0;
- return stream;
- }
-
- private string GetLoginText()
- {
- if (RuntimeInfo.IsProduction && _generatedContent != null)
- {
- return _generatedContent;
- }
-
- var text = _diskProvider.ReadAllText(_indexPath);
-
- var cacheBreakProvider = _cacheBreakProviderFactory();
-
- text = ReplaceRegex.Replace(text, match =>
- {
- var url = cacheBreakProvider.AddCacheBreakerToPath(match.Value);
- return URL_BASE + url;
- });
-
- _generatedContent = text;
-
- return _generatedContent;
- }
- }
-}
diff --git a/src/NzbDrone.Api/Health/HealthModule.cs b/src/NzbDrone.Api/Health/HealthModule.cs
index 2699fa7d6..b7e96fac6 100644
--- a/src/NzbDrone.Api/Health/HealthModule.cs
+++ b/src/NzbDrone.Api/Health/HealthModule.cs
@@ -1,12 +1,13 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.HealthCheck;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.SignalR;
+using Radarr.Http;
namespace NzbDrone.Api.Health
{
- public class HealthModule : NzbDroneRestModuleWithSignalR,
+ public class HealthModule : RadarrRestModuleWithSignalR,
IHandle
{
private readonly IHealthCheckService _healthCheckService;
@@ -28,4 +29,4 @@ namespace NzbDrone.Api.Health
BroadcastResourceChange(ModelAction.Sync);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Api/Health/HealthResource.cs b/src/NzbDrone.Api/Health/HealthResource.cs
index e860cb778..8be8a5899 100644
--- a/src/NzbDrone.Api/Health/HealthResource.cs
+++ b/src/NzbDrone.Api/Health/HealthResource.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Common.Http;
using NzbDrone.Core.HealthCheck;
diff --git a/src/NzbDrone.Api/History/HistoryModule.cs b/src/NzbDrone.Api/History/HistoryModule.cs
index 2e2c8d004..a5797c14a 100644
--- a/src/NzbDrone.Api/History/HistoryModule.cs
+++ b/src/NzbDrone.Api/History/HistoryModule.cs
@@ -1,15 +1,18 @@
using System;
+using System.Linq;
using Nancy;
-using NzbDrone.Api.Extensions;
+using Radarr.Http.Extensions;
using NzbDrone.Api.Movies;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.History;
+using Radarr.Http;
+using Radarr.Http.REST;
namespace NzbDrone.Api.History
{
- public class HistoryModule : NzbDroneRestModule
+ public class HistoryModule : RadarrRestModule
{
private readonly IHistoryService _historyService;
private readonly IQualityUpgradableSpecification _qualityUpgradableSpecification;
@@ -43,19 +46,19 @@ namespace NzbDrone.Api.History
private PagingResource GetHistory(PagingResource pagingResource)
{
var movieId = Request.Query.MovieId;
-
var pagingSpec = pagingResource.MapToPagingSpec("date", SortDirection.Descending);
+ var filter = pagingResource.Filters.FirstOrDefault();
- if (pagingResource.FilterKey == "eventType")
+ if (filter != null && filter.Key == "eventType")
{
- var filterValue = (HistoryEventType)Convert.ToInt32(pagingResource.FilterValue);
- pagingSpec.FilterExpression = v => v.EventType == filterValue;
+ var filterValue = (HistoryEventType)Convert.ToInt32(filter.Value);
+ pagingSpec.FilterExpressions.Add(v => v.EventType == filterValue);
}
if (movieId.HasValue)
{
int i = (int)movieId;
- pagingSpec.FilterExpression = h => h.MovieId == i;
+ pagingSpec.FilterExpressions.Add(h => h.MovieId == i);
}
return ApplyToPage(_historyService.Paged, pagingSpec, MapToResource);
diff --git a/src/NzbDrone.Api/History/HistoryResource.cs b/src/NzbDrone.Api/History/HistoryResource.cs
index c4415d079..c976a9d2d 100644
--- a/src/NzbDrone.Api/History/HistoryResource.cs
+++ b/src/NzbDrone.Api/History/HistoryResource.cs
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Api.Movies;
using NzbDrone.Core.History;
using NzbDrone.Core.Qualities;
diff --git a/src/NzbDrone.Api/Indexers/ReleaseModule.cs b/src/NzbDrone.Api/Indexers/ReleaseModule.cs
index 510ceac86..ba449cc57 100644
--- a/src/NzbDrone.Api/Indexers/ReleaseModule.cs
+++ b/src/NzbDrone.Api/Indexers/ReleaseModule.cs
@@ -10,7 +10,7 @@ using NzbDrone.Core.IndexerSearch;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Parser.Model;
using Nancy.ModelBinding;
-using NzbDrone.Api.Extensions;
+using Radarr.Http.Extensions;
using NzbDrone.Common.Cache;
using HttpStatusCode = System.Net.HttpStatusCode;
diff --git a/src/NzbDrone.Api/Indexers/ReleaseModuleBase.cs b/src/NzbDrone.Api/Indexers/ReleaseModuleBase.cs
index c615f947d..3dca0acce 100644
--- a/src/NzbDrone.Api/Indexers/ReleaseModuleBase.cs
+++ b/src/NzbDrone.Api/Indexers/ReleaseModuleBase.cs
@@ -1,9 +1,10 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using NzbDrone.Core.DecisionEngine;
+using Radarr.Http;
namespace NzbDrone.Api.Indexers
{
- public abstract class ReleaseModuleBase : NzbDroneRestModule
+ public abstract class ReleaseModuleBase : RadarrRestModule
{
protected virtual List MapDecisions(IEnumerable decisions)
{
diff --git a/src/NzbDrone.Api/Indexers/ReleasePushModule.cs b/src/NzbDrone.Api/Indexers/ReleasePushModule.cs
index c25e45726..63b7278b6 100644
--- a/src/NzbDrone.Api/Indexers/ReleasePushModule.cs
+++ b/src/NzbDrone.Api/Indexers/ReleasePushModule.cs
@@ -1,4 +1,4 @@
-using Nancy;
+using Nancy;
using Nancy.ModelBinding;
using FluentValidation;
using NzbDrone.Core.DecisionEngine;
@@ -6,7 +6,8 @@ using NzbDrone.Core.Download;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Parser.Model;
-using NzbDrone.Api.Extensions;
+using Radarr.Http.Extensions;
+using Radarr.Http.Mapping;
using NLog;
namespace NzbDrone.Api.Indexers
diff --git a/src/NzbDrone.Api/Indexers/ReleaseResource.cs b/src/NzbDrone.Api/Indexers/ReleaseResource.cs
index 4b6410956..eaa2779bc 100644
--- a/src/NzbDrone.Api/Indexers/ReleaseResource.cs
+++ b/src/NzbDrone.Api/Indexers/ReleaseResource.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Indexers;
diff --git a/src/NzbDrone.Api/Logs/LogFileModuleBase.cs b/src/NzbDrone.Api/Logs/LogFileModuleBase.cs
index d8a12d1bf..e719bafdd 100644
--- a/src/NzbDrone.Api/Logs/LogFileModuleBase.cs
+++ b/src/NzbDrone.Api/Logs/LogFileModuleBase.cs
@@ -1,14 +1,15 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using NzbDrone.Common.Disk;
using Nancy;
using Nancy.Responses;
using NzbDrone.Core.Configuration;
+using Radarr.Http;
namespace NzbDrone.Api.Logs
{
- public abstract class LogFileModuleBase : NzbDroneRestModule
+ public abstract class LogFileModuleBase : RadarrRestModule
{
protected const string LOGFILE_ROUTE = @"/(?[-.a-zA-Z0-9]+?\.txt)";
@@ -68,4 +69,4 @@ namespace NzbDrone.Api.Logs
protected abstract string DownloadUrlRoot { get; }
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Api/Logs/LogFileResource.cs b/src/NzbDrone.Api/Logs/LogFileResource.cs
index 9f67c8af7..8dec96418 100644
--- a/src/NzbDrone.Api/Logs/LogFileResource.cs
+++ b/src/NzbDrone.Api/Logs/LogFileResource.cs
@@ -1,5 +1,5 @@
using System;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
namespace NzbDrone.Api.Logs
{
diff --git a/src/NzbDrone.Api/Logs/LogModule.cs b/src/NzbDrone.Api/Logs/LogModule.cs
index 88ead3ec0..d671198db 100644
--- a/src/NzbDrone.Api/Logs/LogModule.cs
+++ b/src/NzbDrone.Api/Logs/LogModule.cs
@@ -1,8 +1,10 @@
-using NzbDrone.Core.Instrumentation;
+using System.Linq;
+using NzbDrone.Core.Instrumentation;
+using Radarr.Http;
namespace NzbDrone.Api.Logs
{
- public class LogModule : NzbDroneRestModule
+ public class LogModule : RadarrRestModule
{
private readonly ILogService _logService;
@@ -21,27 +23,29 @@ namespace NzbDrone.Api.Logs
pageSpec.SortKey = "id";
}
- if (pagingResource.FilterKey == "level")
+ var filter = pagingResource.Filters.FirstOrDefault();
+
+ if (filter != null && filter.Key == "level")
{
- switch (pagingResource.FilterValue)
+ switch (filter.Value)
{
case "Fatal":
- pageSpec.FilterExpression = h => h.Level == "Fatal";
+ pageSpec.FilterExpressions.Add(h => h.Level == "Fatal");
break;
case "Error":
- pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error";
+ pageSpec.FilterExpressions.Add(h => h.Level == "Fatal" || h.Level == "Error");
break;
case "Warn":
- pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn";
+ pageSpec.FilterExpressions.Add(h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn");
break;
case "Info":
- pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info";
+ pageSpec.FilterExpressions.Add(h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info");
break;
case "Debug":
- pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info" || h.Level == "Debug";
+ pageSpec.FilterExpressions.Add(h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info" || h.Level == "Debug");
break;
case "Trace":
- pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info" || h.Level == "Debug" || h.Level == "Trace";
+ pageSpec.FilterExpressions.Add(h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info" || h.Level == "Debug" || h.Level == "Trace");
break;
}
}
@@ -49,4 +53,4 @@ namespace NzbDrone.Api.Logs
return ApplyToPage(_logService.Paged, pageSpec, LogResourceMapper.ToResource);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Api/Logs/LogResource.cs b/src/NzbDrone.Api/Logs/LogResource.cs
index 504a45839..53d9a947a 100644
--- a/src/NzbDrone.Api/Logs/LogResource.cs
+++ b/src/NzbDrone.Api/Logs/LogResource.cs
@@ -1,5 +1,5 @@
using System;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
namespace NzbDrone.Api.Logs
{
diff --git a/src/NzbDrone.Api/ManualImport/ManualImportModule.cs b/src/NzbDrone.Api/ManualImport/ManualImportModule.cs
index 769f1434c..5b46a1604 100644
--- a/src/NzbDrone.Api/ManualImport/ManualImportModule.cs
+++ b/src/NzbDrone.Api/ManualImport/ManualImportModule.cs
@@ -1,11 +1,13 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.MediaFiles.MovieImport.Manual;
using NzbDrone.Core.Qualities;
+using Radarr.Http;
+using Radarr.Http.Extensions;
namespace NzbDrone.Api.ManualImport
{
- public class ManualImportModule : NzbDroneRestModule
+ public class ManualImportModule : RadarrRestModule
{
private readonly IManualImportService _manualImportService;
@@ -24,8 +26,9 @@ namespace NzbDrone.Api.ManualImport
var downloadIdQuery = Request.Query.downloadId;
var downloadId = (string)downloadIdQuery.Value;
+ var filterExistingFiles = Request.GetBooleanQueryParameter("filterExistingFiles", true);
- return _manualImportService.GetMediaFiles(folder, downloadId).ToResource().Select(AddQualityWeight).ToList();
+ return _manualImportService.GetMediaFiles(folder, downloadId, filterExistingFiles).ToResource().Select(AddQualityWeight).ToList();
}
private ManualImportResource AddQualityWeight(ManualImportResource item)
diff --git a/src/NzbDrone.Api/ManualImport/ManualImportResource.cs b/src/NzbDrone.Api/ManualImport/ManualImportResource.cs
index eee878cdf..fea7987b8 100644
--- a/src/NzbDrone.Api/ManualImport/ManualImportResource.cs
+++ b/src/NzbDrone.Api/ManualImport/ManualImportResource.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Api.Movies;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Common.Crypto;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Qualities;
diff --git a/src/NzbDrone.Api/MovieFiles/MovieFileModule.cs b/src/NzbDrone.Api/MovieFiles/MovieFileModule.cs
index 049f61104..8d1a28754 100644
--- a/src/NzbDrone.Api/MovieFiles/MovieFileModule.cs
+++ b/src/NzbDrone.Api/MovieFiles/MovieFileModule.cs
@@ -1,7 +1,8 @@
using System.Collections.Generic;
using System.IO;
using NLog;
-using NzbDrone.Api.REST;
+using Radarr.Http;
+using Radarr.Http.REST;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.Events;
@@ -12,7 +13,7 @@ using NzbDrone.SignalR;
namespace NzbDrone.Api.MovieFiles
{
- public class MovieFileModule : NzbDroneRestModuleWithSignalR, IHandle
+ public class MovieFileModule : RadarrRestModuleWithSignalR, IHandle
{
private readonly IMediaFileService _mediaFileService;
private readonly IRecycleBinProvider _recycleBinProvider;
diff --git a/src/NzbDrone.Api/MovieFiles/MovieFileResource.cs b/src/NzbDrone.Api/MovieFiles/MovieFileResource.cs
index 209323966..711013e7d 100644
--- a/src/NzbDrone.Api/MovieFiles/MovieFileResource.cs
+++ b/src/NzbDrone.Api/MovieFiles/MovieFileResource.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Api.Movies;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.MediaFiles;
diff --git a/src/NzbDrone.Api/Movies/AlternativeTitleModule.cs b/src/NzbDrone.Api/Movies/AlternativeTitleModule.cs
index d5192e2d6..8847346c0 100644
--- a/src/NzbDrone.Api/Movies/AlternativeTitleModule.cs
+++ b/src/NzbDrone.Api/Movies/AlternativeTitleModule.cs
@@ -16,10 +16,11 @@ using NzbDrone.Core.Movies.AlternativeTitles;
using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Movies.Events;
+using Radarr.Http;
namespace NzbDrone.Api.Movies
{
- public class AlternativeTitleModule : NzbDroneRestModule
+ public class AlternativeTitleModule : RadarrRestModule
{
private readonly IAlternativeTitleService _altTitleService;
private readonly IMovieService _movieService;
diff --git a/src/NzbDrone.Api/Movies/AlternativeTitleResource.cs b/src/NzbDrone.Api/Movies/AlternativeTitleResource.cs
index b3bc26930..c5aeed2ca 100644
--- a/src/NzbDrone.Api/Movies/AlternativeTitleResource.cs
+++ b/src/NzbDrone.Api/Movies/AlternativeTitleResource.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Qualities;
diff --git a/src/NzbDrone.Api/Movies/AlternativeYearModule.cs b/src/NzbDrone.Api/Movies/AlternativeYearModule.cs
index 598d0e14b..eb40041b4 100644
--- a/src/NzbDrone.Api/Movies/AlternativeYearModule.cs
+++ b/src/NzbDrone.Api/Movies/AlternativeYearModule.cs
@@ -17,10 +17,11 @@ using NzbDrone.Core.Movies.AlternativeTitles;
using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Movies.Events;
+using Radarr.Http;
namespace NzbDrone.Api.Movies
{
- public class AlternativeYearModule : NzbDroneRestModule
+ public class AlternativeYearModule : RadarrRestModule
{
private readonly IMovieService _movieService;
private readonly IRadarrAPIClient _radarrApi;
diff --git a/src/NzbDrone.Api/Movies/AlternativeYearResource.cs b/src/NzbDrone.Api/Movies/AlternativeYearResource.cs
index 6e3ebf787..cef2d7dea 100644
--- a/src/NzbDrone.Api/Movies/AlternativeYearResource.cs
+++ b/src/NzbDrone.Api/Movies/AlternativeYearResource.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Qualities;
diff --git a/src/NzbDrone.Api/Movies/FetchMovieListModule.cs b/src/NzbDrone.Api/Movies/FetchMovieListModule.cs
index a1580460d..953a9bd27 100644
--- a/src/NzbDrone.Api/Movies/FetchMovieListModule.cs
+++ b/src/NzbDrone.Api/Movies/FetchMovieListModule.cs
@@ -1,14 +1,15 @@
using System.Collections.Generic;
using Nancy;
-using NzbDrone.Api.Extensions;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource;
using System.Linq;
using NzbDrone.Core.NetImport;
+using Radarr.Http;
+using Radarr.Http.Extensions;
namespace NzbDrone.Api.Movies
{
- public class FetchMovieListModule : NzbDroneRestModule
+ public class FetchMovieListModule : RadarrRestModule
{
private readonly IFetchNetImport _fetchNetImport;
private readonly ISearchForNewMovie _movieSearch;
diff --git a/src/NzbDrone.Api/Movies/MovieBulkImportModule.cs b/src/NzbDrone.Api/Movies/MovieBulkImportModule.cs
index 6e958f1f6..977cdeba8 100644
--- a/src/NzbDrone.Api/Movies/MovieBulkImportModule.cs
+++ b/src/NzbDrone.Api/Movies/MovieBulkImportModule.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using Nancy;
-using NzbDrone.Api.Extensions;
+using Radarr.Http.Extensions;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource;
using NzbDrone.Core.Parser;
@@ -15,6 +15,7 @@ using NzbDrone.Core.RootFolders;
using NzbDrone.Common.Cache;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Profiles;
+using Radarr.Http;
namespace NzbDrone.Api.Movies
{
@@ -27,7 +28,7 @@ namespace NzbDrone.Api.Movies
}
}
- public class MovieBulkImportModule : NzbDroneRestModule
+ public class MovieBulkImportModule : RadarrRestModule
{
private readonly ISearchForNewMovie _searchProxy;
private readonly IRootFolderService _rootFolderService;
diff --git a/src/NzbDrone.Api/Movies/MovieDiscoverModule.cs b/src/NzbDrone.Api/Movies/MovieDiscoverModule.cs
index 7decab287..40db69bda 100644
--- a/src/NzbDrone.Api/Movies/MovieDiscoverModule.cs
+++ b/src/NzbDrone.Api/Movies/MovieDiscoverModule.cs
@@ -1,17 +1,17 @@
using System.Collections.Generic;
using Nancy;
-using NzbDrone.Api.Extensions;
+using Radarr.Http.Extensions;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource;
using System.Linq;
using System;
-using NzbDrone.Api.REST;
+using Radarr.Http;
using NzbDrone.Core.NetImport;
using NzbDrone.Api.NetImport;
namespace NzbDrone.Api.Movies
{
- public class MovieDiscoverModule : NzbDroneRestModule
+ public class MovieDiscoverModule : RadarrRestModule
{
private readonly IDiscoverNewMovies _searchProxy;
private readonly INetImportFactory _netImportFactory;
diff --git a/src/NzbDrone.Api/Movies/MovieEditorModule.cs b/src/NzbDrone.Api/Movies/MovieEditorModule.cs
index db90a3f95..db7721fcf 100644
--- a/src/NzbDrone.Api/Movies/MovieEditorModule.cs
+++ b/src/NzbDrone.Api/Movies/MovieEditorModule.cs
@@ -3,9 +3,10 @@ using System.Collections.Generic;
using System.Linq;
using Nancy;
using Nancy.Responses;
-using NzbDrone.Api.Extensions;
-using NzbDrone.Api.REST;
+using Radarr.Http.Extensions;
+using Radarr.Http.REST;
using NzbDrone.Core.Movies;
+using Radarr.Http.Mapping;
namespace NzbDrone.Api.Movies
{
diff --git a/src/NzbDrone.Api/Movies/MovieLookupModule.cs b/src/NzbDrone.Api/Movies/MovieLookupModule.cs
index 1801f90dc..a2f02c545 100644
--- a/src/NzbDrone.Api/Movies/MovieLookupModule.cs
+++ b/src/NzbDrone.Api/Movies/MovieLookupModule.cs
@@ -1,15 +1,16 @@
using System.Collections.Generic;
using Nancy;
-using NzbDrone.Api.Extensions;
+using Radarr.Http.Extensions;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource;
using System.Linq;
using System;
-using NzbDrone.Api.REST;
+using Radarr.Http;
+using Radarr.Http.REST;
namespace NzbDrone.Api.Movies
{
- public class MovieLookupModule : NzbDroneRestModule
+ public class MovieLookupModule : RadarrRestModule
{
private readonly ISearchForNewMovie _searchProxy;
private readonly IProvideMovieInfo _movieInfo;
diff --git a/src/NzbDrone.Api/Movies/MovieModule.cs b/src/NzbDrone.Api/Movies/MovieModule.cs
index fb7538f20..db9f6910d 100644
--- a/src/NzbDrone.Api/Movies/MovieModule.cs
+++ b/src/NzbDrone.Api/Movies/MovieModule.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using FluentValidation;
using NzbDrone.Common.Extensions;
-using NzbDrone.Api.Extensions;
+using Radarr.Http.Extensions;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MediaFiles;
@@ -17,10 +17,11 @@ using NzbDrone.SignalR;
using NzbDrone.Core.Datastore;
using Microsoft.CSharp.RuntimeBinder;
using Nancy;
+using Radarr.Http;
namespace NzbDrone.Api.Movies
{
- public class MovieModule : NzbDroneRestModuleWithSignalR,
+ public class MovieModule : RadarrRestModuleWithSignalR,
IHandle,
IHandle,
IHandle,
@@ -41,8 +42,8 @@ namespace NzbDrone.Api.Movies
RootFolderValidator rootFolderValidator,
MoviePathValidator moviesPathValidator,
MovieExistsValidator moviesExistsValidator,
- DroneFactoryValidator droneFactoryValidator,
MovieAncestorValidator moviesAncestorValidator,
+ SystemFolderValidator systemFolderValidator,
ProfileExistsValidator profileExistsValidator
)
: base(signalRBroadcaster)
@@ -64,15 +65,15 @@ namespace NzbDrone.Api.Movies
UpdateResource = UpdateMovie;
DeleteResource = DeleteMovie;
- Validation.RuleBuilderExtensions.ValidId(SharedValidator.RuleFor(s => s.ProfileId));
+ SharedValidator.RuleFor(s => s.ProfileId).ValidId();
SharedValidator.RuleFor(s => s.Path)
.Cascade(CascadeMode.StopOnFirstFailure)
.IsValidPath()
.SetValidator(rootFolderValidator)
.SetValidator(moviesPathValidator)
- .SetValidator(droneFactoryValidator)
.SetValidator(moviesAncestorValidator)
+ .SetValidator(systemFolderValidator)
.When(s => !s.Path.IsNullOrWhiteSpace());
SharedValidator.RuleFor(s => s.ProfileId).SetValidator(profileExistsValidator);
@@ -110,14 +111,14 @@ namespace NzbDrone.Api.Movies
private PagingResource GetMoviePaged(PagingResource pagingResource)
{
- var pagingSpec = pagingResource.MapToPagingSpec();
+ var pagingSpec = pagingResource.MapToPagingSpec();
- pagingSpec.FilterExpression = _moviesService.ConstructFilterExpression(pagingResource.FilterKey, pagingResource.FilterValue, pagingResource.FilterType);
+ pagingSpec.FilterExpressions.Add(_moviesService.ConstructFilterExpression(pagingResource.Filters.FirstOrDefault().Key, pagingResource.Filters.FirstOrDefault().Value));
return ApplyToPage(_moviesService.Paged, pagingSpec, MapToResource);
}
- protected MovieResource MapToResource(Core.Movies.Movie movies)
+ protected MovieResource MapToResource(Movie movies)
{
if (movies == null) return null;
diff --git a/src/NzbDrone.Api/Movies/MovieModuleWithSignalR.cs b/src/NzbDrone.Api/Movies/MovieModuleWithSignalR.cs
index 2a59157c9..30c693b5d 100644
--- a/src/NzbDrone.Api/Movies/MovieModuleWithSignalR.cs
+++ b/src/NzbDrone.Api/Movies/MovieModuleWithSignalR.cs
@@ -6,10 +6,11 @@ using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Movies;
using NzbDrone.SignalR;
+using Radarr.Http;
namespace NzbDrone.Api.Movies
{
- public abstract class MovieModuleWithSignalR : NzbDroneRestModuleWithSignalR,
+ public abstract class MovieModuleWithSignalR : RadarrRestModuleWithSignalR,
IHandle,
IHandle
{
diff --git a/src/NzbDrone.Api/Movies/MovieResource.cs b/src/NzbDrone.Api/Movies/MovieResource.cs
index 3024b4c00..c89b08e26 100644
--- a/src/NzbDrone.Api/Movies/MovieResource.cs
+++ b/src/NzbDrone.Api/Movies/MovieResource.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.Movies;
using NzbDrone.Api.MovieFiles;
diff --git a/src/NzbDrone.Api/Movies/RenameMovieModule.cs b/src/NzbDrone.Api/Movies/RenameMovieModule.cs
index e965545c5..cdbb07e83 100644
--- a/src/NzbDrone.Api/Movies/RenameMovieModule.cs
+++ b/src/NzbDrone.Api/Movies/RenameMovieModule.cs
@@ -1,13 +1,14 @@
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.MediaFiles;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using Radarr.Http;
namespace NzbDrone.Api.Movies
{
- public class RenameMovieModule : NzbDroneRestModule
+ public class RenameMovieModule : RadarrRestModule
{
private readonly IRenameMovieFileService _renameMovieFileService;
diff --git a/src/NzbDrone.Api/Movies/RenameMovieResource.cs b/src/NzbDrone.Api/Movies/RenameMovieResource.cs
index 04eeef97c..a95b58fa4 100644
--- a/src/NzbDrone.Api/Movies/RenameMovieResource.cs
+++ b/src/NzbDrone.Api/Movies/RenameMovieResource.cs
@@ -1,4 +1,4 @@
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using System.Collections.Generic;
using System.Linq;
diff --git a/src/NzbDrone.Api/NetImport/ImportExclusionsModule.cs b/src/NzbDrone.Api/NetImport/ImportExclusionsModule.cs
index 4615c65f7..33a396998 100644
--- a/src/NzbDrone.Api/NetImport/ImportExclusionsModule.cs
+++ b/src/NzbDrone.Api/NetImport/ImportExclusionsModule.cs
@@ -1,13 +1,14 @@
using System.Collections.Generic;
using FluentValidation;
-using NzbDrone.Api.ClientSchema;
+using Radarr.Http.ClientSchema;
using NzbDrone.Core.NetImport;
using NzbDrone.Core.NetImport.ImportExclusions;
using NzbDrone.Core.Validation.Paths;
+using Radarr.Http;
namespace NzbDrone.Api.NetImport
{
- public class ImportExclusionsModule : NzbDroneRestModule
+ public class ImportExclusionsModule : RadarrRestModule
{
private readonly IImportExclusionsService _exclusionService;
diff --git a/src/NzbDrone.Api/NetImport/ListImportModule.cs b/src/NzbDrone.Api/NetImport/ListImportModule.cs
index ccbe48119..78c0fc538 100644
--- a/src/NzbDrone.Api/NetImport/ListImportModule.cs
+++ b/src/NzbDrone.Api/NetImport/ListImportModule.cs
@@ -2,7 +2,7 @@ using System.Collections.Generic;
using System.Linq;
using Nancy;
using Nancy.Extensions;
-using NzbDrone.Api.Extensions;
+using Radarr.Http.Extensions;
using NzbDrone.Api.Movies;
using NzbDrone.Core.MetadataSource;
using NzbDrone.Core.Movies;
diff --git a/src/NzbDrone.Api/NetImport/NetImportModule.cs b/src/NzbDrone.Api/NetImport/NetImportModule.cs
index a382e5183..55132adda 100644
--- a/src/NzbDrone.Api/NetImport/NetImportModule.cs
+++ b/src/NzbDrone.Api/NetImport/NetImportModule.cs
@@ -1,5 +1,5 @@
-using FluentValidation;
-using NzbDrone.Api.ClientSchema;
+using FluentValidation;
+using Radarr.Http.ClientSchema;
using NzbDrone.Core.NetImport;
using NzbDrone.Core.Validation.Paths;
diff --git a/src/NzbDrone.Api/NzbDrone.Api.csproj b/src/NzbDrone.Api/NzbDrone.Api.csproj
index 7d6ccef8d..4e98d5e31 100644
--- a/src/NzbDrone.Api/NzbDrone.Api.csproj
+++ b/src/NzbDrone.Api/NzbDrone.Api.csproj
@@ -8,7 +8,7 @@
Library
Properties
NzbDrone.Api
- NzbDrone.Api
+ Radarr.Api
v4.6.1
512
..\
@@ -91,31 +91,15 @@
Properties\SharedAssemblyInfo.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -164,31 +148,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -206,14 +165,10 @@
-
-
-
-
@@ -228,24 +183,15 @@
-
-
-
-
-
-
-
-
-
@@ -253,13 +199,8 @@
-
-
-
-
-
@@ -290,6 +231,10 @@
{7C2CC69F-5CA0-4E5C-85CB-983F9F6C3B36}
NzbDrone.SignalR
+
+ {c5953dab-89db-46d9-a401-d620f54b776e}
+ Radarr.Http
+
diff --git a/src/NzbDrone.Api/NzbDroneRestModuleWithSignalR.cs b/src/NzbDrone.Api/NzbDroneRestModuleWithSignalR.cs
deleted file mode 100644
index a2061a770..000000000
--- a/src/NzbDrone.Api/NzbDroneRestModuleWithSignalR.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-using NzbDrone.Api.REST;
-using NzbDrone.Core.Datastore;
-using NzbDrone.Core.Datastore.Events;
-using NzbDrone.Core.Messaging.Events;
-using NzbDrone.SignalR;
-
-namespace NzbDrone.Api
-{
- public abstract class NzbDroneRestModuleWithSignalR : NzbDroneRestModule, IHandle>
- where TResource : RestResource, new()
- where TModel : ModelBase, new()
- {
- private readonly IBroadcastSignalRMessage _signalRBroadcaster;
-
- protected NzbDroneRestModuleWithSignalR(IBroadcastSignalRMessage signalRBroadcaster)
- {
- _signalRBroadcaster = signalRBroadcaster;
- }
-
- protected NzbDroneRestModuleWithSignalR(IBroadcastSignalRMessage signalRBroadcaster, string resource)
- : base(resource)
- {
- _signalRBroadcaster = signalRBroadcaster;
- }
-
- public void Handle(ModelEvent message)
- {
- if (message.Action == ModelAction.Deleted || message.Action == ModelAction.Sync)
- {
- BroadcastResourceChange(message.Action);
- }
-
- BroadcastResourceChange(message.Action, message.Model.Id);
- }
-
- protected void BroadcastResourceChange(ModelAction action, int id)
- {
- var resource = GetResourceById(id);
- BroadcastResourceChange(action, resource);
- }
-
-
- protected void BroadcastResourceChange(ModelAction action, TResource resource)
- {
- var signalRMessage = new SignalRMessage
- {
- Name = Resource,
- Body = new ResourceChangeMessage(resource, action)
- };
-
- _signalRBroadcaster.BroadcastMessage(signalRMessage);
- }
-
-
- protected void BroadcastResourceChange(ModelAction action)
- {
- var signalRMessage = new SignalRMessage
- {
- Name = Resource,
- Body = new ResourceChangeMessage(action)
- };
-
- _signalRBroadcaster.BroadcastMessage(signalRMessage);
- }
- }
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Api/Parse/ParseModule.cs b/src/NzbDrone.Api/Parse/ParseModule.cs
index 20bdd8cfd..6b96c9f75 100644
--- a/src/NzbDrone.Api/Parse/ParseModule.cs
+++ b/src/NzbDrone.Api/Parse/ParseModule.cs
@@ -1,10 +1,11 @@
using System.Collections.Generic;
using NzbDrone.Api.Movies;
using NzbDrone.Core.Parser;
+using Radarr.Http;
namespace NzbDrone.Api.Parse
{
- public class ParseModule : NzbDroneRestModule
+ public class ParseModule : RadarrRestModule
{
private readonly IParsingService _parsingService;
diff --git a/src/NzbDrone.Api/Parse/ParseResource.cs b/src/NzbDrone.Api/Parse/ParseResource.cs
index de0dbcc2c..3bc3481f8 100644
--- a/src/NzbDrone.Api/Parse/ParseResource.cs
+++ b/src/NzbDrone.Api/Parse/ParseResource.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using NzbDrone.Api.Movies;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Api.Parse
diff --git a/src/NzbDrone.Api/Profiles/Delay/DelayProfileModule.cs b/src/NzbDrone.Api/Profiles/Delay/DelayProfileModule.cs
index e7975b661..8ccc3fd84 100644
--- a/src/NzbDrone.Api/Profiles/Delay/DelayProfileModule.cs
+++ b/src/NzbDrone.Api/Profiles/Delay/DelayProfileModule.cs
@@ -1,13 +1,14 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using FluentValidation;
using FluentValidation.Results;
-using NzbDrone.Api.REST;
-using NzbDrone.Api.Validation;
+using Radarr.Http.REST;
+using Radarr.Http.Validation;
using NzbDrone.Core.Profiles.Delay;
+using Radarr.Http;
namespace NzbDrone.Api.Profiles.Delay
{
- public class DelayProfileModule : NzbDroneRestModule
+ public class DelayProfileModule : RadarrRestModule
{
private readonly IDelayProfileService _delayProfileService;
@@ -72,4 +73,4 @@ namespace NzbDrone.Api.Profiles.Delay
return _delayProfileService.All().ToResource();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Api/Profiles/Delay/DelayProfileResource.cs b/src/NzbDrone.Api/Profiles/Delay/DelayProfileResource.cs
index e35df9043..a626c220a 100644
--- a/src/NzbDrone.Api/Profiles/Delay/DelayProfileResource.cs
+++ b/src/NzbDrone.Api/Profiles/Delay/DelayProfileResource.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Profiles.Delay;
diff --git a/src/NzbDrone.Api/Profiles/Languages/LanguageModule.cs b/src/NzbDrone.Api/Profiles/Languages/LanguageModule.cs
index 147bc69aa..9bbeada21 100644
--- a/src/NzbDrone.Api/Profiles/Languages/LanguageModule.cs
+++ b/src/NzbDrone.Api/Profiles/Languages/LanguageModule.cs
@@ -1,11 +1,12 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Parser;
+using Radarr.Http;
namespace NzbDrone.Api.Profiles.Languages
{
- public class LanguageModule : NzbDroneRestModule
+ public class LanguageModule : RadarrRestModule
{
public LanguageModule()
{
@@ -36,4 +37,4 @@ namespace NzbDrone.Api.Profiles.Languages
.ToList();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Api/Profiles/Languages/LanguageResource.cs b/src/NzbDrone.Api/Profiles/Languages/LanguageResource.cs
index 09e5ba28c..ae68f2742 100644
--- a/src/NzbDrone.Api/Profiles/Languages/LanguageResource.cs
+++ b/src/NzbDrone.Api/Profiles/Languages/LanguageResource.cs
@@ -1,5 +1,5 @@
using Newtonsoft.Json;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
namespace NzbDrone.Api.Profiles.Languages
{
diff --git a/src/NzbDrone.Api/Profiles/ProfileModule.cs b/src/NzbDrone.Api/Profiles/ProfileModule.cs
index ed8c5c9bf..554bcf991 100644
--- a/src/NzbDrone.Api/Profiles/ProfileModule.cs
+++ b/src/NzbDrone.Api/Profiles/ProfileModule.cs
@@ -1,14 +1,16 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using FluentValidation;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.CustomFormats;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Validation;
+using Radarr.Http;
+using Radarr.Http.Mapping;
namespace NzbDrone.Api.Profiles
{
- public class ProfileModule : NzbDroneRestModule
+ public class ProfileModule : RadarrRestModule
{
private readonly IProfileService _profileService;
private readonly ICustomFormatService _formatService;
diff --git a/src/NzbDrone.Api/Profiles/ProfileResource.cs b/src/NzbDrone.Api/Profiles/ProfileResource.cs
index 114131238..8bd0b1902 100644
--- a/src/NzbDrone.Api/Profiles/ProfileResource.cs
+++ b/src/NzbDrone.Api/Profiles/ProfileResource.cs
@@ -1,7 +1,7 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
- using NzbDrone.Api.Qualities;
- using NzbDrone.Api.REST;
+using NzbDrone.Api.Qualities;
+using Radarr.Http.REST;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Qualities;
diff --git a/src/NzbDrone.Api/Profiles/ProfileSchemaModule.cs b/src/NzbDrone.Api/Profiles/ProfileSchemaModule.cs
index b61431798..cfa9dbdb1 100644
--- a/src/NzbDrone.Api/Profiles/ProfileSchemaModule.cs
+++ b/src/NzbDrone.Api/Profiles/ProfileSchemaModule.cs
@@ -1,13 +1,15 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
- using NzbDrone.Core.CustomFormats;
- using NzbDrone.Core.Parser;
+using NzbDrone.Core.CustomFormats;
+using NzbDrone.Core.Parser;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Qualities;
+using Radarr.Http;
+using Radarr.Http.Mapping;
namespace NzbDrone.Api.Profiles
{
- public class ProfileSchemaModule : NzbDroneRestModule
+ public class ProfileSchemaModule : RadarrRestModule
{
private readonly IQualityDefinitionService _qualityDefinitionService;
private readonly ICustomFormatService _formatService;
diff --git a/src/NzbDrone.Api/Properties/AssemblyInfo.cs b/src/NzbDrone.Api/Properties/AssemblyInfo.cs
index 300ee6fc1..aad3f0395 100644
--- a/src/NzbDrone.Api/Properties/AssemblyInfo.cs
+++ b/src/NzbDrone.Api/Properties/AssemblyInfo.cs
@@ -2,9 +2,9 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-[assembly: AssemblyTitle("NzbDrone.Api")]
+[assembly: AssemblyTitle("Radarr.Api")]
[assembly: Guid("4c0922d7-979e-4ff7-b44b-b8ac2100eeb5")]
-[assembly: InternalsVisibleTo("NzbDrone.Core")]
+[assembly: InternalsVisibleTo("Radarr.Core")]
diff --git a/src/NzbDrone.Api/ProviderModuleBase.cs b/src/NzbDrone.Api/ProviderModuleBase.cs
index c62e55d21..c7a09ea05 100644
--- a/src/NzbDrone.Api/ProviderModuleBase.cs
+++ b/src/NzbDrone.Api/ProviderModuleBase.cs
@@ -1,18 +1,20 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using FluentValidation;
using FluentValidation.Results;
using Nancy;
-using NzbDrone.Api.ClientSchema;
-using NzbDrone.Api.Extensions;
+using Radarr.Http.Extensions;
using NzbDrone.Common.Reflection;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
using Newtonsoft.Json;
+using Radarr.Http;
+using Radarr.Http.ClientSchema;
+using Radarr.Http.Mapping;
namespace NzbDrone.Api
{
- public abstract class ProviderModuleBase : NzbDroneRestModule
+ public abstract class ProviderModuleBase : RadarrRestModule
where TProviderDefinition : ProviderDefinition, new()
where TProvider : IProvider
where TProviderResource : ProviderResource, new()
diff --git a/src/NzbDrone.Api/ProviderResource.cs b/src/NzbDrone.Api/ProviderResource.cs
index 9927a09cc..cfa016b55 100644
--- a/src/NzbDrone.Api/ProviderResource.cs
+++ b/src/NzbDrone.Api/ProviderResource.cs
@@ -1,6 +1,6 @@
-using System.Collections.Generic;
-using NzbDrone.Api.ClientSchema;
-using NzbDrone.Api.REST;
+using System.Collections.Generic;
+using Radarr.Http.ClientSchema;
+using Radarr.Http.REST;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Api
@@ -17,4 +17,4 @@ namespace NzbDrone.Api
public List Presets { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Api/Qualities/CustomFormatModule.cs b/src/NzbDrone.Api/Qualities/CustomFormatModule.cs
index 8a4cb7c24..a128c626b 100644
--- a/src/NzbDrone.Api/Qualities/CustomFormatModule.cs
+++ b/src/NzbDrone.Api/Qualities/CustomFormatModule.cs
@@ -1,15 +1,16 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using FluentValidation;
using Nancy;
-using NzbDrone.Api.Extensions;
-using NzbDrone.Api.Validation;
+using Radarr.Http.Extensions;
+using Radarr.Http.Validation;
using NzbDrone.Core.CustomFormats;
using NzbDrone.Core.Parser;
+using Radarr.Http;
namespace NzbDrone.Api.Qualities
{
- public class CustomFormatModule : NzbDroneRestModule
+ public class CustomFormatModule : RadarrRestModule
{
private readonly ICustomFormatService _formatService;
private readonly IParsingService _parsingService;
@@ -22,7 +23,7 @@ namespace NzbDrone.Api.Qualities
SharedValidator.RuleFor(c => c.Name).NotEmpty();
SharedValidator.RuleFor(c => c.Name)
.Must((v, c) => !_formatService.All().Any(f => f.Name == c && f.Id != v.Id)).WithMessage("Must be unique.");
- SharedValidator.RuleFor(c => c.FormatTags).AreValidFormatTags();
+ SharedValidator.RuleFor(c => c.FormatTags).SetValidator(new FormatTagValidator());
SharedValidator.RuleFor(c => c.FormatTags).Must((v, c) =>
{
var allFormats = _formatService.All();
diff --git a/src/NzbDrone.Api/Qualities/CustomFormatResource.cs b/src/NzbDrone.Api/Qualities/CustomFormatResource.cs
index bfb501090..1d0511d47 100644
--- a/src/NzbDrone.Api/Qualities/CustomFormatResource.cs
+++ b/src/NzbDrone.Api/Qualities/CustomFormatResource.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.CustomFormats;
namespace NzbDrone.Api.Qualities
diff --git a/src/NzbDrone.Api/Qualities/FormatTagMatchResultResource.cs b/src/NzbDrone.Api/Qualities/FormatTagMatchResultResource.cs
index 96ee5f8f6..cad3c78d1 100644
--- a/src/NzbDrone.Api/Qualities/FormatTagMatchResultResource.cs
+++ b/src/NzbDrone.Api/Qualities/FormatTagMatchResultResource.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.CustomFormats;
using NzbDrone.Core.Qualities;
diff --git a/src/NzbDrone.Api/Qualities/QualityDefinitionModule.cs b/src/NzbDrone.Api/Qualities/QualityDefinitionModule.cs
index acb469218..cda3676ae 100644
--- a/src/NzbDrone.Api/Qualities/QualityDefinitionModule.cs
+++ b/src/NzbDrone.Api/Qualities/QualityDefinitionModule.cs
@@ -1,13 +1,14 @@
-using System;
+using System;
using System.Collections.Generic;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities;
+using Radarr.Http;
namespace NzbDrone.Api.Qualities
{
- public class QualityDefinitionModule : NzbDroneRestModule
+ public class QualityDefinitionModule : RadarrRestModule
{
private readonly IQualityDefinitionService _qualityDefinitionService;
private readonly IParsingService _parsingService;
diff --git a/src/NzbDrone.Api/Qualities/QualityDefinitionResource.cs b/src/NzbDrone.Api/Qualities/QualityDefinitionResource.cs
index f98f56ef6..a795e7697 100644
--- a/src/NzbDrone.Api/Qualities/QualityDefinitionResource.cs
+++ b/src/NzbDrone.Api/Qualities/QualityDefinitionResource.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Qualities;
namespace NzbDrone.Api.Qualities
diff --git a/src/NzbDrone.Api/Queue/QueueActionModule.cs b/src/NzbDrone.Api/Queue/QueueActionModule.cs
index 5971d9b97..ac7531a9e 100644
--- a/src/NzbDrone.Api/Queue/QueueActionModule.cs
+++ b/src/NzbDrone.Api/Queue/QueueActionModule.cs
@@ -1,16 +1,17 @@
-using System;
+using System;
using Nancy;
using Nancy.Responses;
-using NzbDrone.Api.Extensions;
-using NzbDrone.Api.REST;
+using Radarr.Http.Extensions;
+using Radarr.Http.REST;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Pending;
using NzbDrone.Core.Download.TrackedDownloads;
using NzbDrone.Core.Queue;
+using Radarr.Http;
namespace NzbDrone.Api.Queue
{
- public class QueueActionModule : NzbDroneRestModule
+ public class QueueActionModule : RadarrRestModule
{
private readonly IQueueService _queueService;
private readonly ITrackedDownloadService _trackedDownloadService;
diff --git a/src/NzbDrone.Api/Queue/QueueModule.cs b/src/NzbDrone.Api/Queue/QueueModule.cs
index 00e614132..95ad3194d 100644
--- a/src/NzbDrone.Api/Queue/QueueModule.cs
+++ b/src/NzbDrone.Api/Queue/QueueModule.cs
@@ -1,14 +1,15 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.Download.Pending;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Queue;
using NzbDrone.SignalR;
+using Radarr.Http;
namespace NzbDrone.Api.Queue
{
- public class QueueModule : NzbDroneRestModuleWithSignalR,
+ public class QueueModule : RadarrRestModuleWithSignalR,
IHandle, IHandle
{
private readonly IQueueService _queueService;
@@ -45,4 +46,4 @@ namespace NzbDrone.Api.Queue
BroadcastResourceChange(ModelAction.Sync);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Api/Queue/QueueResource.cs b/src/NzbDrone.Api/Queue/QueueResource.cs
index ea82956ad..eafe50794 100644
--- a/src/NzbDrone.Api/Queue/QueueResource.cs
+++ b/src/NzbDrone.Api/Queue/QueueResource.cs
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Qualities;
using NzbDrone.Api.Movies;
using NzbDrone.Core.Download.TrackedDownloads;
diff --git a/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingModule.cs b/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingModule.cs
index a61b5f7b3..23bdcc66a 100644
--- a/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingModule.cs
+++ b/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingModule.cs
@@ -1,11 +1,12 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using FluentValidation;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.Validation.Paths;
+using Radarr.Http;
namespace NzbDrone.Api.RemotePathMappings
{
- public class RemotePathMappingModule : NzbDroneRestModule
+ public class RemotePathMappingModule : RadarrRestModule
{
private readonly IRemotePathMappingService _remotePathMappingService;
@@ -64,4 +65,4 @@ namespace NzbDrone.Api.RemotePathMappings
_remotePathMappingService.Update(mapping);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingResource.cs b/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingResource.cs
index 60c01b682..c52774bae 100644
--- a/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingResource.cs
+++ b/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingResource.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.RemotePathMappings;
namespace NzbDrone.Api.RemotePathMappings
diff --git a/src/NzbDrone.Api/Restrictions/RestrictionModule.cs b/src/NzbDrone.Api/Restrictions/RestrictionModule.cs
index 918b3a50b..ab00cca13 100644
--- a/src/NzbDrone.Api/Restrictions/RestrictionModule.cs
+++ b/src/NzbDrone.Api/Restrictions/RestrictionModule.cs
@@ -1,11 +1,12 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using FluentValidation.Results;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Restrictions;
+using Radarr.Http;
-namespace NzbDrone.Api.Restrictions
+namespace Radarr.Http.RESTrictions
{
- public class RestrictionModule : NzbDroneRestModule
+ public class RestrictionModule : RadarrRestModule
{
private readonly IRestrictionService _restrictionService;
diff --git a/src/NzbDrone.Api/Restrictions/RestrictionResource.cs b/src/NzbDrone.Api/Restrictions/RestrictionResource.cs
index 14085e820..a2d9d9424 100644
--- a/src/NzbDrone.Api/Restrictions/RestrictionResource.cs
+++ b/src/NzbDrone.Api/Restrictions/RestrictionResource.cs
@@ -1,9 +1,9 @@
using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Restrictions;
-namespace NzbDrone.Api.Restrictions
+namespace Radarr.Http.RESTrictions
{
public class RestrictionResource : RestResource
{
diff --git a/src/NzbDrone.Api/RootFolders/RootFolderModule.cs b/src/NzbDrone.Api/RootFolders/RootFolderModule.cs
index 30bfcc635..5492bc533 100644
--- a/src/NzbDrone.Api/RootFolders/RootFolderModule.cs
+++ b/src/NzbDrone.Api/RootFolders/RootFolderModule.cs
@@ -1,12 +1,14 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using FluentValidation;
using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Validation.Paths;
using NzbDrone.SignalR;
+using Radarr.Http;
+using Radarr.Http.Mapping;
namespace NzbDrone.Api.RootFolders
{
- public class RootFolderModule : NzbDroneRestModuleWithSignalR
+ public class RootFolderModule : RadarrRestModuleWithSignalR
{
private readonly IRootFolderService _rootFolderService;
@@ -14,9 +16,9 @@ namespace NzbDrone.Api.RootFolders
IBroadcastSignalRMessage signalRBroadcaster,
RootFolderValidator rootFolderValidator,
PathExistsValidator pathExistsValidator,
- DroneFactoryValidator droneFactoryValidator,
MappedNetworkDriveValidator mappedNetworkDriveValidator,
StartupFolderValidator startupFolderValidator,
+ SystemFolderValidator systemFolderValidator,
FolderWritableValidator folderWritableValidator)
: base(signalRBroadcaster)
{
@@ -31,10 +33,10 @@ namespace NzbDrone.Api.RootFolders
.Cascade(CascadeMode.StopOnFirstFailure)
.IsValidPath()
.SetValidator(rootFolderValidator)
- .SetValidator(droneFactoryValidator)
.SetValidator(mappedNetworkDriveValidator)
.SetValidator(startupFolderValidator)
.SetValidator(pathExistsValidator)
+ .SetValidator(systemFolderValidator)
.SetValidator(folderWritableValidator);
}
@@ -60,4 +62,4 @@ namespace NzbDrone.Api.RootFolders
_rootFolderService.Remove(id);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Api/RootFolders/RootFolderResource.cs b/src/NzbDrone.Api/RootFolders/RootFolderResource.cs
index dd13e8495..4c19a23fa 100644
--- a/src/NzbDrone.Api/RootFolders/RootFolderResource.cs
+++ b/src/NzbDrone.Api/RootFolders/RootFolderResource.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.RootFolders;
namespace NzbDrone.Api.RootFolders
diff --git a/src/NzbDrone.Api/Series/SeriesModule.cs b/src/NzbDrone.Api/Series/SeriesModule.cs
deleted file mode 100644
index f4fe44135..000000000
--- a/src/NzbDrone.Api/Series/SeriesModule.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System;
-using System.Collections.Generic;
-using NzbDrone.SignalR;
-
-namespace NzbDrone.Api.Series
-{
- [Obsolete("SeriesModule is Obsolete, Remove with new UI")]
- public class SeriesModule : NzbDroneRestModuleWithSignalR
-
- {
- public SeriesModule(IBroadcastSignalRMessage signalRBroadcaster
- )
- : base(signalRBroadcaster)
- {
- GetResourceAll = AllSeries;
- GetResourceById = GetSeries;
- CreateResource = AddSeries;
- UpdateResource = UpdateSeries;
- DeleteResource = DeleteSeries;
- }
-
- private SeriesResource GetSeries(int id)
- {
- return new SeriesResource();
- }
-
- private List AllSeries()
- {
- return new List();
- }
-
- private int AddSeries(SeriesResource seriesResource)
- {
- return 0;
- }
-
- private void UpdateSeries(SeriesResource seriesResource)
- {
- throw new NotImplementedException();
- }
-
- private void DeleteSeries(int id)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/NzbDrone.Api/Series/SeriesResource.cs b/src/NzbDrone.Api/Series/SeriesResource.cs
deleted file mode 100644
index 068da9dc6..000000000
--- a/src/NzbDrone.Api/Series/SeriesResource.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using NzbDrone.Api.REST;
-
-namespace NzbDrone.Api.Series
-{
- [Obsolete("SeriesResource is Obsolete, Remove with new UI")]
- public class SeriesResource : RestResource
- {
- public SeriesResource()
- {
- Title = "Series Endpoint Obsolete";
- }
-
- //View Only
- public string Title { get; set; }
- }
-
-}
diff --git a/src/NzbDrone.Api/System/Backup/BackupModule.cs b/src/NzbDrone.Api/System/Backup/BackupModule.cs
index 8874ad420..9501da870 100644
--- a/src/NzbDrone.Api/System/Backup/BackupModule.cs
+++ b/src/NzbDrone.Api/System/Backup/BackupModule.cs
@@ -1,11 +1,12 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using NzbDrone.Core.Backup;
+using Radarr.Http;
namespace NzbDrone.Api.System.Backup
{
- public class BackupModule : NzbDroneRestModule
+ public class BackupModule : RadarrRestModule
{
private readonly IBackupService _backupService;
diff --git a/src/NzbDrone.Api/System/Backup/BackupResource.cs b/src/NzbDrone.Api/System/Backup/BackupResource.cs
index 7eac82838..f94ca56e8 100644
--- a/src/NzbDrone.Api/System/Backup/BackupResource.cs
+++ b/src/NzbDrone.Api/System/Backup/BackupResource.cs
@@ -1,5 +1,5 @@
-using System;
-using NzbDrone.Api.REST;
+using System;
+using Radarr.Http.REST;
using NzbDrone.Core.Backup;
namespace NzbDrone.Api.System.Backup
diff --git a/src/NzbDrone.Api/System/SystemModule.cs b/src/NzbDrone.Api/System/SystemModule.cs
index fc1f27238..cb364abb0 100644
--- a/src/NzbDrone.Api/System/SystemModule.cs
+++ b/src/NzbDrone.Api/System/SystemModule.cs
@@ -1,6 +1,6 @@
using Nancy;
using Nancy.Routing;
-using NzbDrone.Api.Extensions;
+using Radarr.Http.Extensions;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
diff --git a/src/NzbDrone.Api/System/Tasks/TaskModule.cs b/src/NzbDrone.Api/System/Tasks/TaskModule.cs
index a535b8a2b..4b9667e89 100644
--- a/src/NzbDrone.Api/System/Tasks/TaskModule.cs
+++ b/src/NzbDrone.Api/System/Tasks/TaskModule.cs
@@ -5,10 +5,11 @@ using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.Jobs;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.SignalR;
+using Radarr.Http;
namespace NzbDrone.Api.System.Tasks
{
- public class TaskModule : NzbDroneRestModuleWithSignalR, IHandle
+ public class TaskModule : RadarrRestModuleWithSignalR, IHandle
{
private readonly ITaskManager _taskManager;
diff --git a/src/NzbDrone.Api/System/Tasks/TaskResource.cs b/src/NzbDrone.Api/System/Tasks/TaskResource.cs
index d4b583aa5..0b47b6cf3 100644
--- a/src/NzbDrone.Api/System/Tasks/TaskResource.cs
+++ b/src/NzbDrone.Api/System/Tasks/TaskResource.cs
@@ -1,5 +1,5 @@
-using System;
-using NzbDrone.Api.REST;
+using System;
+using Radarr.Http.REST;
namespace NzbDrone.Api.System.Tasks
{
diff --git a/src/NzbDrone.Api/Tags/TagModule.cs b/src/NzbDrone.Api/Tags/TagModule.cs
index d2a01667c..741e583a9 100644
--- a/src/NzbDrone.Api/Tags/TagModule.cs
+++ b/src/NzbDrone.Api/Tags/TagModule.cs
@@ -1,12 +1,13 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Tags;
using NzbDrone.SignalR;
+using Radarr.Http;
namespace NzbDrone.Api.Tags
{
- public class TagModule : NzbDroneRestModuleWithSignalR, IHandle
+ public class TagModule : RadarrRestModuleWithSignalR, IHandle
{
private readonly ITagService _tagService;
diff --git a/src/NzbDrone.Api/Tags/TagResource.cs b/src/NzbDrone.Api/Tags/TagResource.cs
index 678107bf5..c22b0e38a 100644
--- a/src/NzbDrone.Api/Tags/TagResource.cs
+++ b/src/NzbDrone.Api/Tags/TagResource.cs
@@ -1,6 +1,6 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Tags;
namespace NzbDrone.Api.Tags
diff --git a/src/NzbDrone.Api/Update/UpdateModule.cs b/src/NzbDrone.Api/Update/UpdateModule.cs
index 2104f23ea..77ab20af8 100644
--- a/src/NzbDrone.Api/Update/UpdateModule.cs
+++ b/src/NzbDrone.Api/Update/UpdateModule.cs
@@ -1,11 +1,12 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Core.Update;
+using Radarr.Http;
namespace NzbDrone.Api.Update
{
- public class UpdateModule : NzbDroneRestModule
+ public class UpdateModule : RadarrRestModule
{
private readonly IRecentUpdateProvider _recentUpdateProvider;
@@ -42,4 +43,4 @@ namespace NzbDrone.Api.Update
return resources;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Api/Update/UpdateResource.cs b/src/NzbDrone.Api/Update/UpdateResource.cs
index dca6f6725..f07dd1853 100644
--- a/src/NzbDrone.Api/Update/UpdateResource.cs
+++ b/src/NzbDrone.Api/Update/UpdateResource.cs
@@ -1,8 +1,8 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
using NzbDrone.Core.Update;
namespace NzbDrone.Api.Update
diff --git a/src/NzbDrone.Api/Wanted/MovieCutoffModule.cs b/src/NzbDrone.Api/Wanted/MovieCutoffModule.cs
index f032f0b12..1fc401ed7 100644
--- a/src/NzbDrone.Api/Wanted/MovieCutoffModule.cs
+++ b/src/NzbDrone.Api/Wanted/MovieCutoffModule.cs
@@ -1,8 +1,10 @@
+using System.Linq;
using NzbDrone.Api.Movies;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Datastore;
using NzbDrone.SignalR;
+using Radarr.Http;
namespace NzbDrone.Api.Wanted
{
@@ -22,9 +24,18 @@ namespace NzbDrone.Api.Wanted
private PagingResource GetCutoffUnmetMovies(PagingResource pagingResource)
{
- var pagingSpec = pagingResource.MapToPagingSpec("title", SortDirection.Ascending);
+ var pagingSpec = pagingResource.MapToPagingSpec("title", SortDirection.Ascending);
- pagingSpec.FilterExpression = _movieService.ConstructFilterExpression(pagingResource.FilterKey, pagingResource.FilterValue);
+ var filter = pagingResource.Filters.FirstOrDefault(f => f.Key == "monitored");
+
+ if (filter != null && filter.Value == "false")
+ {
+ pagingSpec.FilterExpressions.Add(v => v.Monitored == false);
+ }
+ else
+ {
+ pagingSpec.FilterExpressions.Add(v => v.Monitored == true);
+ }
var resource = ApplyToPage(_movieCutoffService.MoviesWhereCutoffUnmet, pagingSpec, v => MapToResource(v, true));
diff --git a/src/NzbDrone.Api/Wanted/MovieMissingModule.cs b/src/NzbDrone.Api/Wanted/MovieMissingModule.cs
index e4b1868b2..3b3662253 100644
--- a/src/NzbDrone.Api/Wanted/MovieMissingModule.cs
+++ b/src/NzbDrone.Api/Wanted/MovieMissingModule.cs
@@ -1,35 +1,36 @@
+using System.Linq;
using NzbDrone.Api.Movies;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Datastore;
using NzbDrone.SignalR;
-using NzbDrone.Core.Download;
-using NzbDrone.Core.MediaFiles.Events;
-using NzbDrone.Core.Messaging.Events;
-using System;
-using NzbDrone.Core.Datastore.Events;
+using Radarr.Http;
namespace NzbDrone.Api.Wanted
{
class MovieMissingModule : MovieModuleWithSignalR
{
- protected readonly IMovieService _movieService;
-
public MovieMissingModule(IMovieService movieService,
IQualityUpgradableSpecification qualityUpgradableSpecification,
IBroadcastSignalRMessage signalRBroadcaster)
: base(movieService, qualityUpgradableSpecification, signalRBroadcaster, "wanted/missing")
{
-
- _movieService = movieService;
GetResourcePaged = GetMissingMovies;
}
private PagingResource GetMissingMovies(PagingResource pagingResource)
{
- var pagingSpec = pagingResource.MapToPagingSpec("title", SortDirection.Descending);
+ var pagingSpec = pagingResource.MapToPagingSpec("title", SortDirection.Descending);
+ var monitoredFilter = pagingResource.Filters.FirstOrDefault(f => f.Key == "monitored");
- pagingSpec.FilterExpression = _movieService.ConstructFilterExpression(pagingResource.FilterKey, pagingResource.FilterValue);
+ if (monitoredFilter != null && monitoredFilter.Value == "false")
+ {
+ pagingSpec.FilterExpressions.Add(v => v.Monitored == false);
+ }
+ else
+ {
+ pagingSpec.FilterExpressions.Add(v => v.Monitored == true);
+ }
var resource = ApplyToPage(_movieService.MoviesWithoutFiles, pagingSpec, v => MapToResource(v, true));
diff --git a/src/NzbDrone.App.Test/NzbDrone.Host.Test.csproj b/src/NzbDrone.App.Test/NzbDrone.Host.Test.csproj
index 6a3fa50e5..ecb4465f6 100644
--- a/src/NzbDrone.App.Test/NzbDrone.Host.Test.csproj
+++ b/src/NzbDrone.App.Test/NzbDrone.Host.Test.csproj
@@ -9,7 +9,7 @@
Library
Properties
NzbDrone.App.Test
- NzbDrone.App.Test
+ Radarr.App.Test
v4.6.1
512
..\
@@ -116,12 +116,12 @@
- xcopy /s /y "$(SolutionDir)\..\_output\NzbDrone.Mono.*" "$(TargetDir)"
- xcopy /s /y "$(SolutionDir)\..\_output\NzbDrone.Windows.*" "$(TargetDir)"
+ xcopy /s /y "$(SolutionDir)\..\_output\Radarr.Mono.*" "$(TargetDir)"
+ xcopy /s /y "$(SolutionDir)\..\_output\Radarr.Windows.*" "$(TargetDir)"
- cp -rv $(SolutionDir)\..\_output\NzbDrone.Mono.* $(TargetDir)
- cp -rv $(SolutionDir)\..\_output\NzbDrone.Windows.* $(TargetDir)
+ cp -rv $(SolutionDir)\..\_output\Radarr.Mono.* $(TargetDir)
+ cp -rv $(SolutionDir)\..\_output\Radarr.Windows.* $(TargetDir)
-
+
\ No newline at end of file
diff --git a/src/NzbDrone.Core/Profiles/Delay/DelayProfileService.cs b/src/NzbDrone.Core/Profiles/Delay/DelayProfileService.cs
index a367ce4eb..7f9a1159d 100644
--- a/src/NzbDrone.Core/Profiles/Delay/DelayProfileService.cs
+++ b/src/NzbDrone.Core/Profiles/Delay/DelayProfileService.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common.Extensions;
@@ -11,6 +11,7 @@ namespace NzbDrone.Core.Profiles.Delay
void Delete(int id);
List All();
DelayProfile Get(int id);
+ List AllForTag(int tagId);
List AllForTags(HashSet tagIds);
DelayProfile BestForTags(HashSet tagIds);
}
@@ -60,6 +61,12 @@ namespace NzbDrone.Core.Profiles.Delay
return _repo.Get(id);
}
+ public List AllForTag(int tagId)
+ {
+ return All().Where(r => r.Tags.Contains(tagId))
+ .ToList();
+ }
+
public List AllForTags(HashSet tagIds)
{
return _repo.All().Where(r => r.Tags.Intersect(tagIds).Any() || r.Tags.Empty()).ToList();
diff --git a/src/NzbDrone.Core/Properties/AssemblyInfo.cs b/src/NzbDrone.Core/Properties/AssemblyInfo.cs
index 7ddb4d5ec..dfe681ea4 100644
--- a/src/NzbDrone.Core/Properties/AssemblyInfo.cs
+++ b/src/NzbDrone.Core/Properties/AssemblyInfo.cs
@@ -6,9 +6,9 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
-[assembly: AssemblyTitle("NzbDrone.Core")]
+[assembly: AssemblyTitle("Radarr.Core")]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3C29FEF7-4B07-49ED-822E-1C29DC49BFAB")]
-[assembly: InternalsVisibleTo("NzbDrone.Core.Test")]
+[assembly: InternalsVisibleTo("Radarr.Core.Test")]
diff --git a/src/NzbDrone.Core/Queue/EstimatedCompletionTimeComparer.cs b/src/NzbDrone.Core/Queue/EstimatedCompletionTimeComparer.cs
new file mode 100644
index 000000000..e8c52e1ab
--- /dev/null
+++ b/src/NzbDrone.Core/Queue/EstimatedCompletionTimeComparer.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+
+namespace NzbDrone.Core.Queue
+{
+ public class EstimatedCompletionTimeComparer : IComparer
+ {
+ public int Compare(DateTime? x, DateTime? y)
+ {
+ if (!x.HasValue && !y.HasValue)
+ {
+ return 0;
+ }
+
+ if (!x.HasValue && y.HasValue)
+ {
+ return 1;
+ }
+
+ if (x.HasValue && !y.HasValue)
+ {
+ return -1;
+ }
+
+ if (x.Value > y.Value)
+ {
+ return 1;
+ }
+
+ if (x.Value < y.Value)
+ {
+ return -1;
+ }
+
+ return 0;
+ }
+ }
+}
diff --git a/src/NzbDrone.Core/Queue/Queue.cs b/src/NzbDrone.Core/Queue/Queue.cs
index 6a2b2b0bd..3f033d9e2 100644
--- a/src/NzbDrone.Core/Queue/Queue.cs
+++ b/src/NzbDrone.Core/Queue/Queue.cs
@@ -24,5 +24,8 @@ namespace NzbDrone.Core.Queue
public string DownloadId { get; set; }
public RemoteMovie RemoteMovie { get; set; }
public DownloadProtocol Protocol { get; set; }
+ public string DownloadClient { get; set; }
+ public string Indexer { get; set; }
+ public string ErrorMessage { get; set; }
}
}
diff --git a/src/NzbDrone.Core/Queue/QueueService.cs b/src/NzbDrone.Core/Queue/QueueService.cs
index 76bfbab07..71b363697 100644
--- a/src/NzbDrone.Core/Queue/QueueService.cs
+++ b/src/NzbDrone.Core/Queue/QueueService.cs
@@ -66,7 +66,10 @@ namespace NzbDrone.Core.Queue
RemoteMovie = trackedDownload.RemoteMovie,
DownloadId = trackedDownload.DownloadItem.DownloadId,
Protocol = trackedDownload.Protocol,
- Movie = movie
+ Movie = movie,
+ DownloadClient = trackedDownload.DownloadItem.DownloadClient,
+ Indexer = trackedDownload.Indexer
+
};
if (queue.Timeleft.HasValue)
diff --git a/src/NzbDrone.Core/Queue/TimeleftComparer.cs b/src/NzbDrone.Core/Queue/TimeleftComparer.cs
new file mode 100644
index 000000000..2c051deeb
--- /dev/null
+++ b/src/NzbDrone.Core/Queue/TimeleftComparer.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+
+namespace NzbDrone.Core.Queue
+{
+ public class TimeleftComparer : IComparer
+ {
+ public int Compare(TimeSpan? x, TimeSpan? y)
+ {
+ if (!x.HasValue && !y.HasValue)
+ {
+ return 0;
+ }
+
+ if (!x.HasValue && y.HasValue)
+ {
+ return 1;
+ }
+
+ if (x.HasValue && !y.HasValue)
+ {
+ return -1;
+ }
+
+ if (x.Value > y.Value)
+ {
+ return 1;
+ }
+
+ if (x.Value < y.Value)
+ {
+ return -1;
+ }
+
+ return 0;
+ }
+ }
+}
diff --git a/src/NzbDrone.Core/NzbDrone.Core.dll.config b/src/NzbDrone.Core/Radarr.Core.dll.config
similarity index 100%
rename from src/NzbDrone.Core/NzbDrone.Core.dll.config
rename to src/NzbDrone.Core/Radarr.Core.dll.config
diff --git a/src/NzbDrone.Core/Restrictions/RestrictionService.cs b/src/NzbDrone.Core/Restrictions/RestrictionService.cs
index 5d7cfba8d..561add650 100644
--- a/src/NzbDrone.Core/Restrictions/RestrictionService.cs
+++ b/src/NzbDrone.Core/Restrictions/RestrictionService.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Common.Extensions;
@@ -34,7 +34,7 @@ namespace NzbDrone.Core.Restrictions
public List AllForTag(int tagId)
{
- return _repo.All().Where(r => r.Tags.Contains(tagId) || r.Tags.Empty()).ToList();
+ return _repo.All().Where(r => r.Tags.Contains(tagId)).ToList();
}
public List AllForTags(HashSet tagIds)
diff --git a/src/NzbDrone.Core/RootFolders/RootFolderService.cs b/src/NzbDrone.Core/RootFolders/RootFolderService.cs
index 437e102a7..b72cb472b 100644
--- a/src/NzbDrone.Core/RootFolders/RootFolderService.cs
+++ b/src/NzbDrone.Core/RootFolders/RootFolderService.cs
@@ -134,11 +134,6 @@ namespace NzbDrone.Core.RootFolders
throw new InvalidOperationException("Recent directory already exists.");
}
- if (_configService.DownloadedMoviesFolder.IsNotNullOrWhiteSpace() && _configService.DownloadedMoviesFolder.PathEquals(rootFolder.Path))
- {
- throw new InvalidOperationException("Drone Factory folder cannot be used.");
- }
-
if (!_diskProvider.FolderWritable(rootFolder.Path))
{
throw new UnauthorizedAccessException(string.Format("Root folder path '{0}' is not writable by user '{1}'", rootFolder.Path, Environment.UserName));
diff --git a/src/NzbDrone.Core/Tags/TagDetails.cs b/src/NzbDrone.Core/Tags/TagDetails.cs
new file mode 100644
index 000000000..8d134622a
--- /dev/null
+++ b/src/NzbDrone.Core/Tags/TagDetails.cs
@@ -0,0 +1,14 @@
+using System.Collections.Generic;
+using NzbDrone.Core.Datastore;
+
+namespace NzbDrone.Core.Tags
+{
+ public class TagDetails : ModelBase
+ {
+ public string Label { get; set; }
+ public List MovieIds { get; set; }
+ public List NotificationIds { get; set; }
+ public List RestrictionIds { get; set; }
+ public List DelayProfileIds { get; set; }
+ }
+}
diff --git a/src/NzbDrone.Core/Tags/TagService.cs b/src/NzbDrone.Core/Tags/TagService.cs
index b7637a6f8..651a17ad6 100644
--- a/src/NzbDrone.Core/Tags/TagService.cs
+++ b/src/NzbDrone.Core/Tags/TagService.cs
@@ -1,6 +1,10 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Messaging.Events;
+using NzbDrone.Core.Notifications;
+using NzbDrone.Core.Profiles.Delay;
+using NzbDrone.Core.Restrictions;
+using NzbDrone.Core.Movies;
namespace NzbDrone.Core.Tags
{
@@ -8,6 +12,9 @@ namespace NzbDrone.Core.Tags
{
Tag GetTag(int tagId);
Tag GetTag(string tag);
+ List GetTags(IEnumerable ids);
+ TagDetails Details(int tagId);
+ List Details();
List All();
Tag Add(Tag tag);
Tag Update(Tag tag);
@@ -18,11 +25,24 @@ namespace NzbDrone.Core.Tags
{
private readonly ITagRepository _repo;
private readonly IEventAggregator _eventAggregator;
+ private readonly IDelayProfileService _delayProfileService;
+ private readonly INotificationFactory _notificationFactory;
+ private readonly IRestrictionService _restrictionService;
+ private readonly IMovieService _movieService;
- public TagService(ITagRepository repo, IEventAggregator eventAggregator)
+ public TagService(ITagRepository repo,
+ IEventAggregator eventAggregator,
+ IDelayProfileService delayProfileService,
+ INotificationFactory notificationFactory,
+ IRestrictionService restrictionService,
+ IMovieService movieService)
{
_repo = repo;
_eventAggregator = eventAggregator;
+ _delayProfileService = delayProfileService;
+ _notificationFactory = notificationFactory;
+ _restrictionService = restrictionService;
+ _movieService = movieService;
}
public Tag GetTag(int tagId)
@@ -42,6 +62,57 @@ namespace NzbDrone.Core.Tags
}
}
+ public List GetTags(IEnumerable ids)
+ {
+ return _repo.Get(ids).ToList();
+ }
+
+ public TagDetails Details(int tagId)
+ {
+ var tag = GetTag(tagId);
+ var delayProfiles = _delayProfileService.AllForTag(tagId);
+ var notifications = _notificationFactory.AllForTag(tagId);
+ var restrictions = _restrictionService.AllForTag(tagId);
+ var movies = _movieService.AllForTag(tagId);
+
+ return new TagDetails
+ {
+ Id = tagId,
+ Label = tag.Label,
+ DelayProfileIds = delayProfiles.Select(c => c.Id).ToList(),
+ NotificationIds = notifications.Select(c => c.Id).ToList(),
+ RestrictionIds = restrictions.Select(c => c.Id).ToList(),
+ MovieIds = movies.Select(c => c.Id).ToList()
+ };
+ }
+
+ public List Details()
+ {
+ var tags = All();
+ var delayProfiles = _delayProfileService.All();
+ var notifications = _notificationFactory.All();
+ var restrictions = _restrictionService.All();
+ var movies = _movieService.GetAllMovies();
+
+ var details = new List();
+
+ foreach (var tag in tags)
+ {
+ details.Add(new TagDetails
+ {
+ Id = tag.Id,
+ Label = tag.Label,
+ DelayProfileIds = delayProfiles.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(),
+ NotificationIds = notifications.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(),
+ RestrictionIds = restrictions.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(),
+ MovieIds = movies.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList()
+ }
+ );
+ }
+
+ return details;
+ }
+
public List All()
{
return _repo.All().OrderBy(t => t.Label).ToList();
diff --git a/src/NzbDrone.Core/ThingiProvider/IProviderFactory.cs b/src/NzbDrone.Core/ThingiProvider/IProviderFactory.cs
index ce6519e1b..bc52f9e16 100644
--- a/src/NzbDrone.Core/ThingiProvider/IProviderFactory.cs
+++ b/src/NzbDrone.Core/ThingiProvider/IProviderFactory.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using FluentValidation.Results;
namespace NzbDrone.Core.ThingiProvider
@@ -20,5 +20,6 @@ namespace NzbDrone.Core.ThingiProvider
TProvider GetInstance(TProviderDefinition definition);
ValidationResult Test(TProviderDefinition definition);
object RequestAction(TProviderDefinition definition, string action, IDictionary query);
+ List AllForTag(int tagId);
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Core/ThingiProvider/ProviderDefinition.cs b/src/NzbDrone.Core/ThingiProvider/ProviderDefinition.cs
index 45bd5a25a..388bf362f 100644
--- a/src/NzbDrone.Core/ThingiProvider/ProviderDefinition.cs
+++ b/src/NzbDrone.Core/ThingiProvider/ProviderDefinition.cs
@@ -1,9 +1,15 @@
-using NzbDrone.Core.Datastore;
+using System.Collections.Generic;
+using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.ThingiProvider
{
public abstract class ProviderDefinition : ModelBase
{
+ protected ProviderDefinition()
+ {
+ Tags = new HashSet();
+ }
+
private IProviderConfig _settings;
public string Name { get; set; }
@@ -12,6 +18,7 @@ namespace NzbDrone.Core.ThingiProvider
public string ConfigContract { get; set; }
public virtual bool Enable { get; set; }
public ProviderMessage Message { get; set; }
+ public HashSet Tags { get; set; }
public IProviderConfig Settings
{
diff --git a/src/NzbDrone.Core/ThingiProvider/ProviderFactory.cs b/src/NzbDrone.Core/ThingiProvider/ProviderFactory.cs
index 70929efe4..d948ec9eb 100644
--- a/src/NzbDrone.Core/ThingiProvider/ProviderFactory.cs
+++ b/src/NzbDrone.Core/ThingiProvider/ProviderFactory.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using FluentValidation.Results;
@@ -167,5 +167,11 @@ namespace NzbDrone.Core.ThingiProvider
_providerRepository.Delete(invalidDefinition);
}
}
+
+ public List AllForTag(int tagId)
+ {
+ return All().Where(p => p.Tags.Contains(tagId))
+ .ToList();
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Core/Update/Commands/ApplicationUpdateCommand.cs b/src/NzbDrone.Core/Update/Commands/ApplicationUpdateCommand.cs
index 8656ffef8..710d8d6d4 100644
--- a/src/NzbDrone.Core/Update/Commands/ApplicationUpdateCommand.cs
+++ b/src/NzbDrone.Core/Update/Commands/ApplicationUpdateCommand.cs
@@ -1,10 +1,11 @@
-using NzbDrone.Core.Messaging.Commands;
+using NzbDrone.Core.Messaging.Commands;
namespace NzbDrone.Core.Update.Commands
{
public class ApplicationUpdateCommand : Command
{
public override bool SendUpdatesToClient => true;
+ public override bool RequiresDiskAccess => true;
public override string CompletionMessage => "Restarting Radarr to apply updates";
}
diff --git a/src/NzbDrone.Core/Update/InstallUpdateService.cs b/src/NzbDrone.Core/Update/InstallUpdateService.cs
index e42a075cd..42970ba19 100644
--- a/src/NzbDrone.Core/Update/InstallUpdateService.cs
+++ b/src/NzbDrone.Core/Update/InstallUpdateService.cs
@@ -167,7 +167,7 @@ namespace NzbDrone.Core.Update
throw new UpdateFailedException("Update Script: '{0}' does not exist", scriptPath);
}
- _logger.Info("Removing NzbDrone.Update");
+ _logger.Info("Removing Radarr.Update");
_diskProvider.DeleteFolder(_appFolderInfo.GetUpdateClientFolder(), true);
_logger.ProgressInfo("Starting update script: {0}", _configFileProvider.UpdateScriptPath);
diff --git a/src/NzbDrone.Core/Validation/Paths/DroneFactoryValidator.cs b/src/NzbDrone.Core/Validation/Paths/DroneFactoryValidator.cs
deleted file mode 100644
index 63ed8db77..000000000
--- a/src/NzbDrone.Core/Validation/Paths/DroneFactoryValidator.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using FluentValidation.Validators;
-using NzbDrone.Common.Extensions;
-using NzbDrone.Core.Configuration;
-
-namespace NzbDrone.Core.Validation.Paths
-{
- public class DroneFactoryValidator : PropertyValidator
- {
- private readonly IConfigService _configService;
-
- public DroneFactoryValidator(IConfigService configService)
- : base("Path is already used for drone factory")
- {
- _configService = configService;
- }
-
- protected override bool IsValid(PropertyValidatorContext context)
- {
- if (context.PropertyValue == null) return false;
-
- var droneFactory = _configService.DownloadedMoviesFolder;
-
- if (string.IsNullOrWhiteSpace(droneFactory)) return true;
-
- return !droneFactory.PathEquals(context.PropertyValue.ToString());
- }
- }
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Core/Validation/Paths/MovieAncestorValidator.cs b/src/NzbDrone.Core/Validation/Paths/MovieAncestorValidator.cs
index e72af6221..91df0ffa3 100644
--- a/src/NzbDrone.Core/Validation/Paths/MovieAncestorValidator.cs
+++ b/src/NzbDrone.Core/Validation/Paths/MovieAncestorValidator.cs
@@ -10,7 +10,7 @@ namespace NzbDrone.Core.Validation.Paths
private readonly IMovieService _movieService;
public MovieAncestorValidator(IMovieService movieService)
- : base("Path is an ancestor of an existing path")
+ : base("Path is an ancestor of an existing movie")
{
_movieService = movieService;
}
diff --git a/src/NzbDrone.Core/Validation/Paths/SystemFolderValidator.cs b/src/NzbDrone.Core/Validation/Paths/SystemFolderValidator.cs
new file mode 100644
index 000000000..ad321f87a
--- /dev/null
+++ b/src/NzbDrone.Core/Validation/Paths/SystemFolderValidator.cs
@@ -0,0 +1,91 @@
+using System;
+using FluentValidation.Validators;
+using NzbDrone.Common.EnvironmentInfo;
+using NzbDrone.Common.Extensions;
+
+namespace NzbDrone.Core.Validation.Paths
+{
+ public class SystemFolderValidator : PropertyValidator
+ {
+ public SystemFolderValidator()
+ : base("Is {relationship} system folder {systemFolder}")
+ {
+ }
+
+ protected override bool IsValid(PropertyValidatorContext context)
+ {
+ var folder = context.PropertyValue.ToString();
+
+ if (OsInfo.IsWindows)
+ {
+ var windowsFolder = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
+ context.MessageFormatter.AppendArgument("systemFolder", windowsFolder);
+
+ if (windowsFolder.PathEquals(folder))
+ {
+ context.MessageFormatter.AppendArgument("relationship", "set to");
+
+ return false;
+ }
+
+ if (windowsFolder.IsParentPath(folder))
+ {
+ context.MessageFormatter.AppendArgument("relationship", "child of");
+
+ return false;
+ }
+ }
+ else if (OsInfo.IsOsx)
+ {
+ var systemFolder = "/System";
+ context.MessageFormatter.AppendArgument("systemFolder", systemFolder);
+
+ if (systemFolder.PathEquals(folder))
+ {
+ context.MessageFormatter.AppendArgument("relationship", "child of");
+
+ return false;
+ }
+
+ if (systemFolder.IsParentPath(folder))
+ {
+ context.MessageFormatter.AppendArgument("relationship", "child of");
+
+ return false;
+ }
+ }
+ else
+ {
+ var folders = new[]
+ {
+ "/bin",
+ "/boot",
+ "/lib",
+ "/sbin",
+ "/proc"
+ };
+
+ foreach (var f in folders)
+ {
+ context.MessageFormatter.AppendArgument("systemFolder", f);
+
+ if (f.PathEquals(folder))
+ {
+ context.MessageFormatter.AppendArgument("relationship", "child of");
+
+ return false;
+ }
+
+ if (f.IsParentPath(folder))
+ {
+ context.MessageFormatter.AppendArgument("relationship", "child of");
+
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/src/NzbDrone.Host/Bootstrap.cs b/src/NzbDrone.Host/Bootstrap.cs
index 9f7c08b54..7d4c992f9 100644
--- a/src/NzbDrone.Host/Bootstrap.cs
+++ b/src/NzbDrone.Host/Bootstrap.cs
@@ -4,9 +4,11 @@ using System.Threading;
using NLog;
using NzbDrone.Common.Composition;
using NzbDrone.Common.EnvironmentInfo;
+using NzbDrone.Common.Exceptions;
using NzbDrone.Common.Instrumentation;
using NzbDrone.Common.Processes;
using NzbDrone.Common.Security;
+using NzbDrone.Core.Configuration;
using NzbDrone.Core.Instrumentation;
namespace Radarr.Host
@@ -49,6 +51,10 @@ namespace Radarr.Host
SpinToExit(appMode);
}
}
+ catch (InvalidConfigFileException ex)
+ {
+ throw new RadarrStartupException(ex);
+ }
catch (TerminateApplicationException e)
{
Logger.Info(e.Message);
diff --git a/src/NzbDrone.Host/MainAppContainerBuilder.cs b/src/NzbDrone.Host/MainAppContainerBuilder.cs
index e14560c38..3bbc0cc52 100644
--- a/src/NzbDrone.Host/MainAppContainerBuilder.cs
+++ b/src/NzbDrone.Host/MainAppContainerBuilder.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using Nancy.Bootstrapper;
-using NzbDrone.Api;
+using Radarr.Http;
using NzbDrone.Common.Composition;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Http.Dispatchers;
@@ -15,9 +15,11 @@ namespace Radarr.Host
var assemblies = new List
{
"Radarr.Host",
- "NzbDrone.Core",
- "NzbDrone.Api",
- "NzbDrone.SignalR"
+ "Radarr.Core",
+ "Radarr.Api",
+ "Radarr.SignalR",
+ "Radarr.Api.V2",
+ "Radarr.Http"
};
return new MainAppContainerBuilder(args, assemblies).Container;
@@ -28,7 +30,7 @@ namespace Radarr.Host
{
AutoRegisterImplementations();
- Container.Register();
+ Container.Register();
Container.Register();
}
}
diff --git a/src/NzbDrone.Host/NzbDrone.Host.csproj b/src/NzbDrone.Host/NzbDrone.Host.csproj
index dfd0f6f2f..1933f80c6 100644
--- a/src/NzbDrone.Host/NzbDrone.Host.csproj
+++ b/src/NzbDrone.Host/NzbDrone.Host.csproj
@@ -197,6 +197,14 @@
{7C2CC69F-5CA0-4E5C-85CB-983F9F6C3B36}
NzbDrone.SignalR
+
+ {38497dc6-e488-4b9e-a973-a1a7961b33c4}
+ Radarr.Api.V2
+
+
+ {c5953dab-89db-46d9-a401-d620f54b776e}
+ Radarr.Http
+
diff --git a/src/NzbDrone.Host/Owin/MiddleWare/SignalRMiddleWare.cs b/src/NzbDrone.Host/Owin/MiddleWare/SignalRMiddleWare.cs
index 008919803..51ac8bfbe 100644
--- a/src/NzbDrone.Host/Owin/MiddleWare/SignalRMiddleWare.cs
+++ b/src/NzbDrone.Host/Owin/MiddleWare/SignalRMiddleWare.cs
@@ -15,12 +15,14 @@ namespace Radarr.Host.Owin.MiddleWare
SignalRDependencyResolver.Register(container);
SignalRJsonSerializer.Register();
+ // Half the default time (110s) to get under nginx's default 60 proxy_read_timeout
+ GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(55);
GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromMinutes(3);
}
public void Attach(IAppBuilder appBuilder)
{
- appBuilder.MapConnection("/signalr", typeof(NzbDronePersistentConnection), new ConnectionConfiguration());
+ appBuilder.MapSignalR("/signalr", typeof(NzbDronePersistentConnection), new ConnectionConfiguration());
}
}
}
diff --git a/src/NzbDrone.Host/Router.cs b/src/NzbDrone.Host/Router.cs
index cfc925929..17f1e33c3 100644
--- a/src/NzbDrone.Host/Router.cs
+++ b/src/NzbDrone.Host/Router.cs
@@ -44,27 +44,27 @@ namespace Radarr.Host
case ApplicationModes.InstallService:
{
_logger.Debug("Install Service selected");
- if (_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
+ if (_serviceProvider.ServiceExist(ServiceProvider.SERVICE_NAME))
{
_consoleService.PrintServiceAlreadyExist();
}
else
{
- _serviceProvider.Install(ServiceProvider.NZBDRONE_SERVICE_NAME);
- _serviceProvider.Start(ServiceProvider.NZBDRONE_SERVICE_NAME);
+ _serviceProvider.Install(ServiceProvider.SERVICE_NAME);
+ _serviceProvider.Start(ServiceProvider.SERVICE_NAME);
}
break;
}
case ApplicationModes.UninstallService:
{
_logger.Debug("Uninstall Service selected");
- if (!_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
+ if (!_serviceProvider.ServiceExist(ServiceProvider.SERVICE_NAME))
{
_consoleService.PrintServiceDoesNotExist();
}
else
{
- _serviceProvider.UnInstall(ServiceProvider.NZBDRONE_SERVICE_NAME);
+ _serviceProvider.UnInstall(ServiceProvider.SERVICE_NAME);
}
break;
diff --git a/src/NzbDrone.Host/SingleInstancePolicy.cs b/src/NzbDrone.Host/SingleInstancePolicy.cs
index 1978c50e6..dd2f74190 100644
--- a/src/NzbDrone.Host/SingleInstancePolicy.cs
+++ b/src/NzbDrone.Host/SingleInstancePolicy.cs
@@ -65,8 +65,8 @@ namespace Radarr.Host
{
var currentId = _processProvider.GetCurrentProcess().Id;
- var otherProcesses = _processProvider.FindProcessByName(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME)
- .Union(_processProvider.FindProcessByName(ProcessProvider.NZB_DRONE_PROCESS_NAME))
+ var otherProcesses = _processProvider.FindProcessByName(ProcessProvider.RADARR_CONSOLE_PROCESS_NAME)
+ .Union(_processProvider.FindProcessByName(ProcessProvider.RADARR_PROCESS_NAME))
.Select(c => c.Id)
.Except(new[] { currentId })
.ToList();
diff --git a/src/NzbDrone.Integration.Test/Client/ClientBase.cs b/src/NzbDrone.Integration.Test/Client/ClientBase.cs
index 884fe992a..5ea21256c 100644
--- a/src/NzbDrone.Integration.Test/Client/ClientBase.cs
+++ b/src/NzbDrone.Integration.Test/Client/ClientBase.cs
@@ -1,9 +1,10 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Net;
using FluentAssertions;
using NLog;
using NzbDrone.Api;
-using NzbDrone.Api.REST;
+using Radarr.Http.REST;
+using Radarr.Http;
using NzbDrone.Common.Serializer;
using RestSharp;
using System.Linq;
@@ -176,4 +177,4 @@ namespace NzbDrone.Integration.Test.Client
Execute
@@ -175,12 +179,12 @@
- xcopy /s /y "$(SolutionDir)\..\_output\NzbDrone.Mono.*" "$(TargetDir)"
- xcopy /s /y "$(SolutionDir)\..\_output\NzbDrone.Windows.*" "$(TargetDir)"
+ xcopy /s /y "$(SolutionDir)\..\_output\Radarr.Mono.*" "$(TargetDir)"
+ xcopy /s /y "$(SolutionDir)\..\_output\Radarr.Windows.*" "$(TargetDir)"
- cp -rv $(SolutionDir)\..\_output\NzbDrone.Mono.* $(TargetDir)
- cp -rv $(SolutionDir)\..\_output\NzbDrone.Windows.* $(TargetDir)
+ cp -rv $(SolutionDir)\..\_output\Radarr.Mono.* $(TargetDir)
+ cp -rv $(SolutionDir)\..\_output\Radarr.Windows.* $(TargetDir)
+
\ No newline at end of file
diff --git a/src/Radarr.Api.V2/RadarrV2FeedModule.cs b/src/Radarr.Api.V2/RadarrV2FeedModule.cs
new file mode 100644
index 000000000..f71e28cca
--- /dev/null
+++ b/src/Radarr.Api.V2/RadarrV2FeedModule.cs
@@ -0,0 +1,12 @@
+using Nancy;
+
+namespace Radarr.Api.V2
+{
+ public abstract class RadarrV2FeedModule : NancyModule
+ {
+ protected RadarrV2FeedModule(string resource)
+ : base("/feed/v2/" + resource.Trim('/'))
+ {
+ }
+ }
+}
diff --git a/src/Radarr.Api.V2/RadarrV2Module.cs b/src/Radarr.Api.V2/RadarrV2Module.cs
new file mode 100644
index 000000000..6d05e5562
--- /dev/null
+++ b/src/Radarr.Api.V2/RadarrV2Module.cs
@@ -0,0 +1,12 @@
+using Nancy;
+
+namespace Radarr.Api.V2
+{
+ public abstract class RadarrV2Module : NancyModule
+ {
+ protected RadarrV2Module(string resource)
+ : base("/api/v2/" + resource.Trim('/'))
+ {
+ }
+ }
+}
diff --git a/src/Radarr.Api.V2/RemotePathMappings/RemotePathMappingModule.cs b/src/Radarr.Api.V2/RemotePathMappings/RemotePathMappingModule.cs
new file mode 100644
index 000000000..de7e61d9c
--- /dev/null
+++ b/src/Radarr.Api.V2/RemotePathMappings/RemotePathMappingModule.cs
@@ -0,0 +1,68 @@
+using System.Collections.Generic;
+using FluentValidation;
+using NzbDrone.Core.RemotePathMappings;
+using NzbDrone.Core.Validation.Paths;
+using Radarr.Http;
+
+namespace Radarr.Api.V2.RemotePathMappings
+{
+ public class RemotePathMappingModule : RadarrRestModule
+ {
+ private readonly IRemotePathMappingService _remotePathMappingService;
+
+ public RemotePathMappingModule(IRemotePathMappingService remotePathMappingService,
+ PathExistsValidator pathExistsValidator,
+ MappedNetworkDriveValidator mappedNetworkDriveValidator)
+ {
+ _remotePathMappingService = remotePathMappingService;
+
+ GetResourceAll = GetMappings;
+ GetResourceById = GetMappingById;
+ CreateResource = CreateMapping;
+ DeleteResource = DeleteMapping;
+ UpdateResource = UpdateMapping;
+
+ SharedValidator.RuleFor(c => c.Host)
+ .NotEmpty();
+
+ // We cannot use IsValidPath here, because it's a remote path, possibly other OS.
+ SharedValidator.RuleFor(c => c.RemotePath)
+ .NotEmpty();
+
+ SharedValidator.RuleFor(c => c.LocalPath)
+ .Cascade(CascadeMode.StopOnFirstFailure)
+ .IsValidPath()
+ .SetValidator(mappedNetworkDriveValidator)
+ .SetValidator(pathExistsValidator);
+ }
+
+ private RemotePathMappingResource GetMappingById(int id)
+ {
+ return _remotePathMappingService.Get(id).ToResource();
+ }
+
+ private int CreateMapping(RemotePathMappingResource resource)
+ {
+ var model = resource.ToModel();
+
+ return _remotePathMappingService.Add(model).Id;
+ }
+
+ private List GetMappings()
+ {
+ return _remotePathMappingService.All().ToResource();
+ }
+
+ private void DeleteMapping(int id)
+ {
+ _remotePathMappingService.Remove(id);
+ }
+
+ private void UpdateMapping(RemotePathMappingResource resource)
+ {
+ var mapping = resource.ToModel();
+
+ _remotePathMappingService.Update(mapping);
+ }
+ }
+}
diff --git a/src/Radarr.Api.V2/RemotePathMappings/RemotePathMappingResource.cs b/src/Radarr.Api.V2/RemotePathMappings/RemotePathMappingResource.cs
new file mode 100644
index 000000000..ab449fc51
--- /dev/null
+++ b/src/Radarr.Api.V2/RemotePathMappings/RemotePathMappingResource.cs
@@ -0,0 +1,50 @@
+using System.Collections.Generic;
+using System.Linq;
+using NzbDrone.Core.RemotePathMappings;
+using Radarr.Http.REST;
+
+namespace Radarr.Api.V2.RemotePathMappings
+{
+ public class RemotePathMappingResource : RestResource
+ {
+ public string Host { get; set; }
+ public string RemotePath { get; set; }
+ public string LocalPath { get; set; }
+ }
+
+ public static class RemotePathMappingResourceMapper
+ {
+ public static RemotePathMappingResource ToResource(this RemotePathMapping model)
+ {
+ if (model == null) return null;
+
+ return new RemotePathMappingResource
+ {
+ Id = model.Id,
+
+ Host = model.Host,
+ RemotePath = model.RemotePath,
+ LocalPath = model.LocalPath
+ };
+ }
+
+ public static RemotePathMapping ToModel(this RemotePathMappingResource resource)
+ {
+ if (resource == null) return null;
+
+ return new RemotePathMapping
+ {
+ Id = resource.Id,
+
+ Host = resource.Host,
+ RemotePath = resource.RemotePath,
+ LocalPath = resource.LocalPath
+ };
+ }
+
+ public static List ToResource(this IEnumerable models)
+ {
+ return models.Select(ToResource).ToList();
+ }
+ }
+}
diff --git a/src/Radarr.Api.V2/Restrictions/RestrictionModule.cs b/src/Radarr.Api.V2/Restrictions/RestrictionModule.cs
new file mode 100644
index 000000000..130802abb
--- /dev/null
+++ b/src/Radarr.Api.V2/Restrictions/RestrictionModule.cs
@@ -0,0 +1,60 @@
+using System.Collections.Generic;
+using FluentValidation.Results;
+using NzbDrone.Common.Extensions;
+using NzbDrone.Core.Restrictions;
+using Radarr.Http;
+
+namespace Radarr.Api.V2.Restrictions
+{
+ public class RestrictionModule : RadarrRestModule
+ {
+ private readonly IRestrictionService _restrictionService;
+
+
+ public RestrictionModule(IRestrictionService restrictionService)
+ {
+ _restrictionService = restrictionService;
+
+ GetResourceById = Get;
+ GetResourceAll = GetAll;
+ CreateResource = Create;
+ UpdateResource = Update;
+ DeleteResource = Delete;
+
+ SharedValidator.Custom(restriction =>
+ {
+ if (restriction.Ignored.IsNullOrWhiteSpace() && restriction.Required.IsNullOrWhiteSpace())
+ {
+ return new ValidationFailure("", "Either 'Must contain' or 'Must not contain' is required");
+ }
+
+ return null;
+ });
+ }
+
+ private RestrictionResource Get(int id)
+ {
+ return _restrictionService.Get(id).ToResource();
+ }
+
+ private List GetAll()
+ {
+ return _restrictionService.All().ToResource();
+ }
+
+ private int Create(RestrictionResource resource)
+ {
+ return _restrictionService.Add(resource.ToModel()).Id;
+ }
+
+ private void Update(RestrictionResource resource)
+ {
+ _restrictionService.Update(resource.ToModel());
+ }
+
+ private void Delete(int id)
+ {
+ _restrictionService.Delete(id);
+ }
+ }
+}
diff --git a/src/Radarr.Api.V2/Restrictions/RestrictionResource.cs b/src/Radarr.Api.V2/Restrictions/RestrictionResource.cs
new file mode 100644
index 000000000..c73c569b5
--- /dev/null
+++ b/src/Radarr.Api.V2/Restrictions/RestrictionResource.cs
@@ -0,0 +1,58 @@
+using System.Collections.Generic;
+using System.Linq;
+using NzbDrone.Core.Restrictions;
+using Radarr.Http.REST;
+
+namespace Radarr.Api.V2.Restrictions
+{
+ public class RestrictionResource : RestResource
+ {
+ public string Required { get; set; }
+ public string Preferred { get; set; }
+ public string Ignored { get; set; }
+ public HashSet Tags { get; set; }
+
+ public RestrictionResource()
+ {
+ Tags = new HashSet();
+ }
+ }
+
+ public static class RestrictionResourceMapper
+ {
+ public static RestrictionResource ToResource(this Restriction model)
+ {
+ if (model == null) return null;
+
+ return new RestrictionResource
+ {
+ Id = model.Id,
+
+ Required = model.Required,
+ Preferred = model.Preferred,
+ Ignored = model.Ignored,
+ Tags = new HashSet(model.Tags)
+ };
+ }
+
+ public static Restriction ToModel(this RestrictionResource resource)
+ {
+ if (resource == null) return null;
+
+ return new Restriction
+ {
+ Id = resource.Id,
+
+ Required = resource.Required,
+ Preferred = resource.Preferred,
+ Ignored = resource.Ignored,
+ Tags = new HashSet(resource.Tags)
+ };
+ }
+
+ public static List ToResource(this IEnumerable models)
+ {
+ return models.Select(ToResource).ToList();
+ }
+ }
+}
diff --git a/src/Radarr.Api.V2/RootFolders/RootFolderModule.cs b/src/Radarr.Api.V2/RootFolders/RootFolderModule.cs
new file mode 100644
index 000000000..cf79303c6
--- /dev/null
+++ b/src/Radarr.Api.V2/RootFolders/RootFolderModule.cs
@@ -0,0 +1,65 @@
+using System.Collections.Generic;
+using FluentValidation;
+using NzbDrone.Core.RootFolders;
+using NzbDrone.Core.Validation.Paths;
+using NzbDrone.SignalR;
+using Radarr.Http;
+
+namespace Radarr.Api.V2.RootFolders
+{
+ public class RootFolderModule : RadarrRestModuleWithSignalR
+ {
+ private readonly IRootFolderService _rootFolderService;
+
+ public RootFolderModule(IRootFolderService rootFolderService,
+ IBroadcastSignalRMessage signalRBroadcaster,
+ RootFolderValidator rootFolderValidator,
+ PathExistsValidator pathExistsValidator,
+ MappedNetworkDriveValidator mappedNetworkDriveValidator,
+ StartupFolderValidator startupFolderValidator,
+ SystemFolderValidator systemFolderValidator,
+ FolderWritableValidator folderWritableValidator
+ )
+ : base(signalRBroadcaster)
+ {
+ _rootFolderService = rootFolderService;
+
+ GetResourceAll = GetRootFolders;
+ GetResourceById = GetRootFolder;
+ CreateResource = CreateRootFolder;
+ DeleteResource = DeleteFolder;
+
+ SharedValidator.RuleFor(c => c.Path)
+ .Cascade(CascadeMode.StopOnFirstFailure)
+ .IsValidPath()
+ .SetValidator(rootFolderValidator)
+ .SetValidator(mappedNetworkDriveValidator)
+ .SetValidator(startupFolderValidator)
+ .SetValidator(pathExistsValidator)
+ .SetValidator(systemFolderValidator)
+ .SetValidator(folderWritableValidator);
+ }
+
+ private RootFolderResource GetRootFolder(int id)
+ {
+ return _rootFolderService.Get(id).ToResource();
+ }
+
+ private int CreateRootFolder(RootFolderResource rootFolderResource)
+ {
+ var model = rootFolderResource.ToModel();
+
+ return _rootFolderService.Add(model).Id;
+ }
+
+ private List GetRootFolders()
+ {
+ return _rootFolderService.AllWithUnmappedFolders().ToResource();
+ }
+
+ private void DeleteFolder(int id)
+ {
+ _rootFolderService.Remove(id);
+ }
+ }
+}
diff --git a/src/Radarr.Api.V2/RootFolders/RootFolderResource.cs b/src/Radarr.Api.V2/RootFolders/RootFolderResource.cs
new file mode 100644
index 000000000..719e297b3
--- /dev/null
+++ b/src/Radarr.Api.V2/RootFolders/RootFolderResource.cs
@@ -0,0 +1,51 @@
+using System.Collections.Generic;
+using System.Linq;
+using NzbDrone.Core.RootFolders;
+using Radarr.Http.REST;
+
+namespace Radarr.Api.V2.RootFolders
+{
+ public class RootFolderResource : RestResource
+ {
+ public string Path { get; set; }
+ public long? FreeSpace { get; set; }
+
+ public List UnmappedFolders { get; set; }
+ }
+
+ public static class RootFolderResourceMapper
+ {
+ public static RootFolderResource ToResource(this RootFolder model)
+ {
+ if (model == null) return null;
+
+ return new RootFolderResource
+ {
+ Id = model.Id,
+
+ Path = model.Path,
+ FreeSpace = model.FreeSpace,
+ UnmappedFolders = model.UnmappedFolders
+ };
+ }
+
+ public static RootFolder ToModel(this RootFolderResource resource)
+ {
+ if (resource == null) return null;
+
+ return new RootFolder
+ {
+ Id = resource.Id,
+
+ Path = resource.Path,
+ //FreeSpace
+ //UnmappedFolders
+ };
+ }
+
+ public static List ToResource(this IEnumerable models)
+ {
+ return models.Select(ToResource).ToList();
+ }
+ }
+}
diff --git a/src/Radarr.Api.V2/System/Backup/BackupModule.cs b/src/Radarr.Api.V2/System/Backup/BackupModule.cs
new file mode 100644
index 000000000..b924c48b1
--- /dev/null
+++ b/src/Radarr.Api.V2/System/Backup/BackupModule.cs
@@ -0,0 +1,33 @@
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using NzbDrone.Core.Backup;
+using Radarr.Http;
+
+namespace Radarr.Api.V2.System.Backup
+{
+ public class BackupModule : RadarrRestModule
+ {
+ private readonly IBackupService _backupService;
+
+ public BackupModule(IBackupService backupService) : base("system/backup")
+ {
+ _backupService = backupService;
+ GetResourceAll = GetBackupFiles;
+ }
+
+ public List GetBackupFiles()
+ {
+ var backups = _backupService.GetBackups();
+
+ return backups.Select(b => new BackupResource
+ {
+ Id = b.Name.GetHashCode(),
+ Name = b.Name,
+ Path = $"/backup/{b.Type.ToString().ToLower()}/{b.Name}",
+ Type = b.Type,
+ Time = b.Time
+ }).ToList();
+ }
+ }
+}
diff --git a/src/Radarr.Api.V2/System/Backup/BackupResource.cs b/src/Radarr.Api.V2/System/Backup/BackupResource.cs
new file mode 100644
index 000000000..b265f423e
--- /dev/null
+++ b/src/Radarr.Api.V2/System/Backup/BackupResource.cs
@@ -0,0 +1,14 @@
+using System;
+using Radarr.Http.REST;
+using NzbDrone.Core.Backup;
+
+namespace Radarr.Api.V2.System.Backup
+{
+ public class BackupResource : RestResource
+ {
+ public string Name { get; set; }
+ public string Path { get; set; }
+ public BackupType Type { get; set; }
+ public DateTime Time { get; set; }
+ }
+}
diff --git a/src/Radarr.Api.V2/System/SystemModule.cs b/src/Radarr.Api.V2/System/SystemModule.cs
new file mode 100644
index 000000000..25b5546a1
--- /dev/null
+++ b/src/Radarr.Api.V2/System/SystemModule.cs
@@ -0,0 +1,95 @@
+using System.Threading.Tasks;
+using Nancy;
+using Nancy.Routing;
+using Radarr.Http.Extensions;
+using NzbDrone.Common.EnvironmentInfo;
+using NzbDrone.Common.Extensions;
+using NzbDrone.Core.Configuration;
+using NzbDrone.Core.Datastore;
+using NzbDrone.Core.Lifecycle;
+
+namespace Radarr.Api.V2.System
+{
+ public class SystemModule : RadarrV2Module
+ {
+ private readonly IAppFolderInfo _appFolderInfo;
+ private readonly IRuntimeInfo _runtimeInfo;
+ private readonly IPlatformInfo _platformInfo;
+ private readonly IOsInfo _osInfo;
+ private readonly IRouteCacheProvider _routeCacheProvider;
+ private readonly IConfigFileProvider _configFileProvider;
+ private readonly IMainDatabase _database;
+ private readonly ILifecycleService _lifecycleService;
+
+ public SystemModule(IAppFolderInfo appFolderInfo,
+ IRuntimeInfo runtimeInfo,
+ IPlatformInfo platformInfo,
+ IOsInfo osInfo,
+ IRouteCacheProvider routeCacheProvider,
+ IConfigFileProvider configFileProvider,
+ IMainDatabase database,
+ ILifecycleService lifecycleService)
+ : base("system")
+ {
+ _appFolderInfo = appFolderInfo;
+ _runtimeInfo = runtimeInfo;
+ _platformInfo = platformInfo;
+ _osInfo = osInfo;
+ _routeCacheProvider = routeCacheProvider;
+ _configFileProvider = configFileProvider;
+ _database = database;
+ _lifecycleService = lifecycleService;
+ Get["/status"] = x => GetStatus();
+ Get["/routes"] = x => GetRoutes();
+ Post["/shutdown"] = x => Shutdown();
+ Post["/restart"] = x => Restart();
+ }
+
+ private Response GetStatus()
+ {
+ return new
+ {
+ Version = BuildInfo.Version.ToString(),
+ BuildTime = BuildInfo.BuildDateTime,
+ IsDebug = BuildInfo.IsDebug,
+ IsProduction = RuntimeInfo.IsProduction,
+ IsAdmin = _runtimeInfo.IsAdmin,
+ IsUserInteractive = RuntimeInfo.IsUserInteractive,
+ StartupPath = _appFolderInfo.StartUpFolder,
+ AppData = _appFolderInfo.GetAppDataPath(),
+ OsName = _osInfo.Name,
+ OsVersion = _osInfo.Version,
+ IsMonoRuntime = PlatformInfo.IsMono,
+ IsMono = PlatformInfo.IsMono,
+ IsLinux = OsInfo.IsLinux,
+ IsOsx = OsInfo.IsOsx,
+ IsWindows = OsInfo.IsWindows,
+ Mode = _runtimeInfo.Mode,
+ Branch = _configFileProvider.Branch,
+ Authentication = _configFileProvider.AuthenticationMethod,
+ SqliteVersion = _database.Version,
+ UrlBase = _configFileProvider.UrlBase,
+ RuntimeVersion = _platformInfo.Version,
+ RuntimeName = PlatformInfo.Platform,
+ StartTime = _runtimeInfo.StartTime
+ }.AsResponse();
+ }
+
+ private Response GetRoutes()
+ {
+ return _routeCacheProvider.GetCache().Values.AsResponse();
+ }
+
+ private Response Shutdown()
+ {
+ Task.Factory.StartNew(() => _lifecycleService.Shutdown());
+ return new { ShuttingDown = true }.AsResponse();
+ }
+
+ private Response Restart()
+ {
+ Task.Factory.StartNew(() => _lifecycleService.Restart());
+ return new { Restarting = true }.AsResponse();
+ }
+ }
+}
diff --git a/src/Radarr.Api.V2/System/Tasks/TaskModule.cs b/src/Radarr.Api.V2/System/Tasks/TaskModule.cs
new file mode 100644
index 000000000..3ba31e72b
--- /dev/null
+++ b/src/Radarr.Api.V2/System/Tasks/TaskModule.cs
@@ -0,0 +1,66 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Text.RegularExpressions;
+using NzbDrone.Common.Extensions;
+using NzbDrone.Core.Datastore.Events;
+using NzbDrone.Core.Jobs;
+using NzbDrone.Core.Messaging.Events;
+using NzbDrone.SignalR;
+using Radarr.Http;
+
+namespace Radarr.Api.V2.System.Tasks
+{
+ public class TaskModule : RadarrRestModuleWithSignalR, IHandle
+ {
+ private readonly ITaskManager _taskManager;
+
+ public TaskModule(ITaskManager taskManager, IBroadcastSignalRMessage broadcastSignalRMessage)
+ : base(broadcastSignalRMessage, "system/task")
+ {
+ _taskManager = taskManager;
+ GetResourceAll = GetAll;
+ GetResourceById = GetTask;
+ }
+
+ private List GetAll()
+ {
+ return _taskManager.GetAll()
+ .Select(ConvertToResource)
+ .OrderBy(t => t.Name)
+ .ToList();
+ }
+
+ private TaskResource GetTask(int id)
+ {
+ var task = _taskManager.GetAll()
+ .SingleOrDefault(t => t.Id == id);
+
+ if (task == null)
+ {
+ return null;
+ }
+
+ return ConvertToResource(task);
+ }
+
+ private static TaskResource ConvertToResource(ScheduledTask scheduledTask)
+ {
+ var taskName = scheduledTask.TypeName.Split('.').Last().Replace("Command", "");
+
+ return new TaskResource
+ {
+ Id = scheduledTask.Id,
+ Name = taskName.SplitCamelCase(),
+ TaskName = taskName,
+ Interval = scheduledTask.Interval,
+ LastExecution = scheduledTask.LastExecution,
+ NextExecution = scheduledTask.LastExecution.AddMinutes(scheduledTask.Interval)
+ };
+ }
+
+ public void Handle(CommandExecutedEvent message)
+ {
+ BroadcastResourceChange(ModelAction.Sync);
+ }
+ }
+}
diff --git a/src/Radarr.Api.V2/System/Tasks/TaskResource.cs b/src/Radarr.Api.V2/System/Tasks/TaskResource.cs
new file mode 100644
index 000000000..40663dbec
--- /dev/null
+++ b/src/Radarr.Api.V2/System/Tasks/TaskResource.cs
@@ -0,0 +1,14 @@
+using System;
+using Radarr.Http.REST;
+
+namespace Radarr.Api.V2.System.Tasks
+{
+ public class TaskResource : RestResource
+ {
+ public string Name { get; set; }
+ public string TaskName { get; set; }
+ public int Interval { get; set; }
+ public DateTime LastExecution { get; set; }
+ public DateTime NextExecution { get; set; }
+ }
+}
diff --git a/src/Radarr.Api.V2/Tags/TagDetailsModule.cs b/src/Radarr.Api.V2/Tags/TagDetailsModule.cs
new file mode 100644
index 000000000..d4826f5bd
--- /dev/null
+++ b/src/Radarr.Api.V2/Tags/TagDetailsModule.cs
@@ -0,0 +1,30 @@
+using System.Collections.Generic;
+using NzbDrone.Core.Tags;
+using Radarr.Http;
+
+namespace Radarr.Api.V2.Tags
+{
+ public class TagDetailsModule : RadarrRestModule
+ {
+ private readonly ITagService _tagService;
+
+ public TagDetailsModule(ITagService tagService)
+ : base("/tag/detail")
+ {
+ _tagService = tagService;
+
+ GetResourceById = Get;
+ GetResourceAll = GetAll;
+ }
+
+ private TagDetailsResource Get(int id)
+ {
+ return _tagService.Details(id).ToResource();
+ }
+
+ private List GetAll()
+ {
+ return _tagService.Details().ToResource();
+ }
+ }
+}
diff --git a/src/Radarr.Api.V2/Tags/TagDetailsResource.cs b/src/Radarr.Api.V2/Tags/TagDetailsResource.cs
new file mode 100644
index 000000000..384d2ee0b
--- /dev/null
+++ b/src/Radarr.Api.V2/Tags/TagDetailsResource.cs
@@ -0,0 +1,39 @@
+using System.Collections.Generic;
+using System.Linq;
+using NzbDrone.Core.Tags;
+using Radarr.Http.REST;
+
+namespace Radarr.Api.V2.Tags
+{
+ public class TagDetailsResource : RestResource
+ {
+ public string Label { get; set; }
+ public List DelayProfileIds { get; set; }
+ public List NotificationIds { get; set; }
+ public List RestrictionIds { get; set; }
+ public List MovieIds { get; set; }
+ }
+
+ public static class TagDetailsResourceMapper
+ {
+ public static TagDetailsResource ToResource(this TagDetails model)
+ {
+ if (model == null) return null;
+
+ return new TagDetailsResource
+ {
+ Id = model.Id,
+ Label = model.Label,
+ DelayProfileIds = model.DelayProfileIds,
+ NotificationIds = model.NotificationIds,
+ RestrictionIds = model.RestrictionIds,
+ MovieIds = model.MovieIds
+ };
+ }
+
+ public static List ToResource(this IEnumerable models)
+ {
+ return models.Select(ToResource).ToList();
+ }
+ }
+}
diff --git a/src/Radarr.Api.V2/Tags/TagModule.cs b/src/Radarr.Api.V2/Tags/TagModule.cs
new file mode 100644
index 000000000..8290cb4f7
--- /dev/null
+++ b/src/Radarr.Api.V2/Tags/TagModule.cs
@@ -0,0 +1,57 @@
+using System.Collections.Generic;
+using NzbDrone.Core.Datastore.Events;
+using NzbDrone.Core.Messaging.Events;
+using NzbDrone.Core.Tags;
+using NzbDrone.SignalR;
+using Radarr.Http;
+
+namespace Radarr.Api.V2.Tags
+{
+ public class TagModule : RadarrRestModuleWithSignalR, IHandle
+ {
+ private readonly ITagService _tagService;
+
+ public TagModule(IBroadcastSignalRMessage signalRBroadcaster,
+ ITagService tagService)
+ : base(signalRBroadcaster)
+ {
+ _tagService = tagService;
+
+ GetResourceById = Get;
+ GetResourceAll = GetAll;
+ CreateResource = Create;
+ UpdateResource = Update;
+ DeleteResource = Delete;
+ }
+
+ private TagResource Get(int id)
+ {
+ return _tagService.GetTag(id).ToResource();
+ }
+
+ private List GetAll()
+ {
+ return _tagService.All().ToResource();
+ }
+
+ private int Create(TagResource resource)
+ {
+ return _tagService.Add(resource.ToModel()).Id;
+ }
+
+ private void Update(TagResource resource)
+ {
+ _tagService.Update(resource.ToModel());
+ }
+
+ private void Delete(int id)
+ {
+ _tagService.Delete(id);
+ }
+
+ public void Handle(TagsUpdatedEvent message)
+ {
+ BroadcastResourceChange(ModelAction.Sync);
+ }
+ }
+}
diff --git a/src/Radarr.Api.V2/Tags/TagResource.cs b/src/Radarr.Api.V2/Tags/TagResource.cs
new file mode 100644
index 000000000..358b3705e
--- /dev/null
+++ b/src/Radarr.Api.V2/Tags/TagResource.cs
@@ -0,0 +1,42 @@
+using System.Collections.Generic;
+using System.Linq;
+using Radarr.Http.REST;
+using NzbDrone.Core.Tags;
+
+namespace Radarr.Api.V2.Tags
+{
+ public class TagResource : RestResource
+ {
+ public string Label { get; set; }
+ }
+
+ public static class TagResourceMapper
+ {
+ public static TagResource ToResource(this Tag model)
+ {
+ if (model == null) return null;
+
+ return new TagResource
+ {
+ Id = model.Id,
+ Label = model.Label
+ };
+ }
+
+ public static Tag ToModel(this TagResource resource)
+ {
+ if (resource == null) return null;
+
+ return new Tag
+ {
+ Id = resource.Id,
+ Label = resource.Label
+ };
+ }
+
+ public static List ToResource(this IEnumerable models)
+ {
+ return models.Select(ToResource).ToList();
+ }
+ }
+}
diff --git a/src/Radarr.Api.V2/Update/UpdateModule.cs b/src/Radarr.Api.V2/Update/UpdateModule.cs
new file mode 100644
index 000000000..a4b718cbb
--- /dev/null
+++ b/src/Radarr.Api.V2/Update/UpdateModule.cs
@@ -0,0 +1,46 @@
+using System.Collections.Generic;
+using System.Linq;
+using NzbDrone.Common.EnvironmentInfo;
+using NzbDrone.Core.Update;
+using Radarr.Http;
+
+namespace Radarr.Api.V2.Update
+{
+ public class UpdateModule : RadarrRestModule
+ {
+ private readonly IRecentUpdateProvider _recentUpdateProvider;
+
+ public UpdateModule(IRecentUpdateProvider recentUpdateProvider)
+ {
+ _recentUpdateProvider = recentUpdateProvider;
+ GetResourceAll = GetRecentUpdates;
+ }
+
+ private List GetRecentUpdates()
+ {
+ var resources = _recentUpdateProvider.GetRecentUpdatePackages()
+ .OrderByDescending(u => u.Version)
+ .ToResource();
+
+ if (resources.Any())
+ {
+ var first = resources.First();
+ first.Latest = true;
+
+ if (first.Version > BuildInfo.Version)
+ {
+ first.Installable = true;
+ }
+
+ var installed = resources.SingleOrDefault(r => r.Version == BuildInfo.Version);
+
+ if (installed != null)
+ {
+ installed.Installed = true;
+ }
+ }
+
+ return resources;
+ }
+ }
+}
diff --git a/src/Radarr.Api.V2/Update/UpdateResource.cs b/src/Radarr.Api.V2/Update/UpdateResource.cs
new file mode 100644
index 000000000..7019ff3ae
--- /dev/null
+++ b/src/Radarr.Api.V2/Update/UpdateResource.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Newtonsoft.Json;
+using NzbDrone.Core.Update;
+using Radarr.Http.REST;
+
+namespace Radarr.Api.V2.Update
+{
+ public class UpdateResource : RestResource
+ {
+ [JsonConverter(typeof(Newtonsoft.Json.Converters.VersionConverter))]
+ public Version Version { get; set; }
+
+ public string Branch { get; set; }
+ public DateTime ReleaseDate { get; set; }
+ public string FileName { get; set; }
+ public string Url { get; set; }
+ public bool Installed { get; set; }
+ public bool Installable { get; set; }
+ public bool Latest { get; set; }
+ public UpdateChanges Changes { get; set; }
+ public string Hash { get; set; }
+ }
+
+ public static class UpdateResourceMapper
+ {
+ public static UpdateResource ToResource(this UpdatePackage model)
+ {
+ if (model == null) return null;
+
+ return new UpdateResource
+ {
+ Version = model.Version,
+
+ Branch = model.Branch,
+ ReleaseDate = model.ReleaseDate,
+ FileName = model.FileName,
+ Url = model.Url,
+ //Installed
+ //Installable
+ //Latest
+ Changes = model.Changes,
+ Hash = model.Hash,
+ };
+ }
+
+ public static List ToResource(this IEnumerable models)
+ {
+ return models.Select(ToResource).ToList();
+ }
+ }
+}
diff --git a/src/Radarr.Api.V2/app.config b/src/Radarr.Api.V2/app.config
new file mode 100644
index 000000000..d4d6857aa
--- /dev/null
+++ b/src/Radarr.Api.V2/app.config
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Radarr.Api.V2/packages.config b/src/Radarr.Api.V2/packages.config
new file mode 100644
index 000000000..cea694345
--- /dev/null
+++ b/src/Radarr.Api.V2/packages.config
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/NzbDrone.Api/Authentication/1tews5g3.gd1~ b/src/Radarr.Http/Authentication/1tews5g3.gd1~
similarity index 100%
rename from src/NzbDrone.Api/Authentication/1tews5g3.gd1~
rename to src/Radarr.Http/Authentication/1tews5g3.gd1~
diff --git a/src/NzbDrone.Api/Authentication/AuthenticationModule.cs b/src/Radarr.Http/Authentication/AuthenticationModule.cs
similarity index 89%
rename from src/NzbDrone.Api/Authentication/AuthenticationModule.cs
rename to src/Radarr.Http/Authentication/AuthenticationModule.cs
index df940a947..d6d111172 100644
--- a/src/NzbDrone.Api/Authentication/AuthenticationModule.cs
+++ b/src/Radarr.Http/Authentication/AuthenticationModule.cs
@@ -7,7 +7,7 @@ using NzbDrone.Common.EnsureThat;
using NzbDrone.Core.Authentication;
using NzbDrone.Core.Configuration;
-namespace NzbDrone.Api.Authentication
+namespace Radarr.Http.Authentication
{
public class AuthenticationModule : NancyModule
{
@@ -33,7 +33,8 @@ namespace NzbDrone.Api.Authentication
if (user == null)
{
- return Context.GetRedirect("~/login?returnUrl=" + (string)Request.Query.returnUrl);
+ var returnUrl = (string)Request.Query.returnUrl;
+ return Context.GetRedirect($"~/login?returnUrl={returnUrl}&loginFailed=true");
}
DateTime? expiry = null;
diff --git a/src/NzbDrone.Api/Authentication/AuthenticationService.cs b/src/Radarr.Http/Authentication/AuthenticationService.cs
similarity index 95%
rename from src/NzbDrone.Api/Authentication/AuthenticationService.cs
rename to src/Radarr.Http/Authentication/AuthenticationService.cs
index beb908b11..294f5f6d0 100644
--- a/src/NzbDrone.Api/Authentication/AuthenticationService.cs
+++ b/src/Radarr.Http/Authentication/AuthenticationService.cs
@@ -4,12 +4,12 @@ using Nancy;
using Nancy.Authentication.Basic;
using Nancy.Authentication.Forms;
using Nancy.Security;
-using NzbDrone.Api.Extensions;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Authentication;
using NzbDrone.Core.Configuration;
+using Radarr.Http.Extensions;
-namespace NzbDrone.Api.Authentication
+namespace Radarr.Http.Authentication
{
public interface IAuthenticationService : IUserValidator, IUserMapper
{
@@ -18,7 +18,6 @@ namespace NzbDrone.Api.Authentication
public class AuthenticationService : IAuthenticationService
{
- private readonly IConfigFileProvider _configFileProvider;
private readonly IUserService _userService;
private static readonly NzbDroneUser AnonymousUser = new NzbDroneUser { UserName = "Anonymous" };
@@ -27,7 +26,6 @@ namespace NzbDrone.Api.Authentication
public AuthenticationService(IConfigFileProvider configFileProvider, IUserService userService)
{
- _configFileProvider = configFileProvider;
_userService = userService;
API_KEY = configFileProvider.ApiKey;
AUTH_METHOD = configFileProvider.AuthenticationMethod;
diff --git a/src/NzbDrone.Api/Authentication/EnableAuthInNancy.cs b/src/Radarr.Http/Authentication/EnableAuthInNancy.cs
similarity index 62%
rename from src/NzbDrone.Api/Authentication/EnableAuthInNancy.cs
rename to src/Radarr.Http/Authentication/EnableAuthInNancy.cs
index e18a2a9dc..4f50c1473 100644
--- a/src/NzbDrone.Api/Authentication/EnableAuthInNancy.cs
+++ b/src/Radarr.Http/Authentication/EnableAuthInNancy.cs
@@ -1,22 +1,25 @@
-using System;
+using System;
using System.Text;
using Nancy;
using Nancy.Authentication.Basic;
using Nancy.Authentication.Forms;
using Nancy.Bootstrapper;
+using Nancy.Cookies;
using Nancy.Cryptography;
-using NzbDrone.Api.Extensions;
-using NzbDrone.Api.Extensions.Pipelines;
+using NzbDrone.Common.Extensions;
using NzbDrone.Core.Authentication;
using NzbDrone.Core.Configuration;
+using Radarr.Http.Extensions;
+using Radarr.Http.Extensions.Pipelines;
-namespace NzbDrone.Api.Authentication
+namespace Radarr.Http.Authentication
{
public class EnableAuthInNancy : IRegisterNancyPipeline
{
private readonly IAuthenticationService _authenticationService;
private readonly IConfigService _configService;
private readonly IConfigFileProvider _configFileProvider;
+ private FormsAuthenticationConfiguration FormsAuthConfig;
public EnableAuthInNancy(IAuthenticationService authenticationService,
IConfigService configService,
@@ -34,6 +37,7 @@ namespace NzbDrone.Api.Authentication
if (_configFileProvider.AuthenticationMethod == AuthenticationType.Forms)
{
RegisterFormsAuth(pipelines);
+ pipelines.AfterRequest.AddItemToEndOfPipeline((Action)SlidingAuthenticationForFormsAuth);
}
else if (_configFileProvider.AuthenticationMethod == AuthenticationType.Basic)
@@ -41,8 +45,8 @@ namespace NzbDrone.Api.Authentication
pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(_authenticationService, "Radarr"));
}
- pipelines.BeforeRequest.AddItemToEndOfPipeline((Func) RequiresAuthentication);
- pipelines.AfterRequest.AddItemToEndOfPipeline((Action) RemoveLoginHooksForApiCalls);
+ pipelines.BeforeRequest.AddItemToEndOfPipeline((Func)RequiresAuthentication);
+ pipelines.AfterRequest.AddItemToEndOfPipeline((Action)RemoveLoginHooksForApiCalls);
}
private Response RequiresAuthentication(NancyContext context)
@@ -59,20 +63,22 @@ namespace NzbDrone.Api.Authentication
private void RegisterFormsAuth(IPipelines pipelines)
{
+ FormsAuthentication.FormsAuthenticationCookieName = "RadarrAuth";
+
var cryptographyConfiguration = new CryptographyConfiguration(
new RijndaelEncryptionProvider(new PassphraseKeyGenerator(_configService.RijndaelPassphrase, Encoding.ASCII.GetBytes(_configService.RijndaelSalt))),
new DefaultHmacProvider(new PassphraseKeyGenerator(_configService.HmacPassphrase, Encoding.ASCII.GetBytes(_configService.HmacSalt)))
);
- FormsAuthentication.FormsAuthenticationCookieName = "_ncfaradarr"; //For those people that both have sonarr and radarr.
-
- FormsAuthentication.Enable(pipelines, new FormsAuthenticationConfiguration
+ FormsAuthConfig = new FormsAuthenticationConfiguration
{
RedirectUrl = _configFileProvider.UrlBase + "/login",
UserMapper = _authenticationService,
- Path = _configFileProvider.UrlBase,
+ Path = GetCookiePath(),
CryptographyConfiguration = cryptographyConfiguration
- });
+ };
+
+ FormsAuthentication.Enable(pipelines, FormsAuthConfig);
}
private void RemoveLoginHooksForApiCalls(NancyContext context)
@@ -87,5 +93,43 @@ namespace NzbDrone.Api.Authentication
}
}
}
+
+ private void SlidingAuthenticationForFormsAuth(NancyContext context)
+ {
+ if (context.CurrentUser == null)
+ {
+ return;
+ }
+
+ var formsAuthCookieName = FormsAuthentication.FormsAuthenticationCookieName;
+
+ if (!context.Request.Path.Equals("/logout") &&
+ context.Request.Cookies.ContainsKey(formsAuthCookieName))
+ {
+ var formsAuthCookieValue = context.Request.Cookies[formsAuthCookieName];
+
+ if (FormsAuthentication.DecryptAndValidateAuthenticationCookie(formsAuthCookieValue, FormsAuthConfig).IsNotNullOrWhiteSpace())
+ {
+ var formsAuthCookie = new NancyCookie(formsAuthCookieName, formsAuthCookieValue, true, false, DateTime.UtcNow.AddDays(7))
+ {
+ Path = GetCookiePath()
+ };
+
+ context.Response.WithCookie(formsAuthCookie);
+ }
+ }
+ }
+
+ private string GetCookiePath()
+ {
+ var urlBase = _configFileProvider.UrlBase;
+
+ if (urlBase.IsNullOrWhiteSpace())
+ {
+ return "/";
+ }
+
+ return urlBase;
+ }
}
}
diff --git a/src/NzbDrone.Api/Authentication/LoginResource.cs b/src/Radarr.Http/Authentication/LoginResource.cs
similarity index 81%
rename from src/NzbDrone.Api/Authentication/LoginResource.cs
rename to src/Radarr.Http/Authentication/LoginResource.cs
index 5d6a5c9f5..13d2aee0b 100644
--- a/src/NzbDrone.Api/Authentication/LoginResource.cs
+++ b/src/Radarr.Http/Authentication/LoginResource.cs
@@ -1,4 +1,4 @@
-namespace NzbDrone.Api.Authentication
+namespace Radarr.Http.Authentication
{
public class LoginResource
{
diff --git a/src/NzbDrone.Api/Authentication/NzbDroneUser.cs b/src/Radarr.Http/Authentication/NzbDroneUser.cs
similarity index 85%
rename from src/NzbDrone.Api/Authentication/NzbDroneUser.cs
rename to src/Radarr.Http/Authentication/NzbDroneUser.cs
index c8fce02fd..65297fd82 100644
--- a/src/NzbDrone.Api/Authentication/NzbDroneUser.cs
+++ b/src/Radarr.Http/Authentication/NzbDroneUser.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using Nancy.Security;
-namespace NzbDrone.Api.Authentication
+namespace Radarr.Http.Authentication
{
public class NzbDroneUser : IUserIdentity
{
diff --git a/src/NzbDrone.Api/ClientSchema/Field.cs b/src/Radarr.Http/ClientSchema/Field.cs
similarity index 63%
rename from src/NzbDrone.Api/ClientSchema/Field.cs
rename to src/Radarr.Http/ClientSchema/Field.cs
index ec611e8d6..9ec4e7ccc 100644
--- a/src/NzbDrone.Api/ClientSchema/Field.cs
+++ b/src/Radarr.Http/ClientSchema/Field.cs
@@ -1,17 +1,24 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
-namespace NzbDrone.Api.ClientSchema
+namespace Radarr.Http.ClientSchema
{
public class Field
{
public int Order { get; set; }
public string Name { get; set; }
public string Label { get; set; }
+ public string Unit { get; set; }
public string HelpText { get; set; }
public string HelpLink { get; set; }
public object Value { get; set; }
public string Type { get; set; }
public bool Advanced { get; set; }
public List SelectOptions { get; set; }
+ public string Section { get; set; }
+
+ public Field Clone()
+ {
+ return (Field)MemberwiseClone();
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/Radarr.Http/ClientSchema/FieldMapping.cs b/src/Radarr.Http/ClientSchema/FieldMapping.cs
new file mode 100644
index 000000000..420a379f6
--- /dev/null
+++ b/src/Radarr.Http/ClientSchema/FieldMapping.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace Radarr.Http.ClientSchema
+{
+ public class FieldMapping
+ {
+ public Field Field { get; set; }
+ public Type PropertyType { get; set; }
+ public Func