diff --git a/src/NzbDrone.Api.Test/ClientSchemaTests/SchemaBuilderFixture.cs b/src/NzbDrone.Api.Test/ClientSchemaTests/SchemaBuilderFixture.cs
index 5a767365d..a49020351 100644
--- a/src/NzbDrone.Api.Test/ClientSchemaTests/SchemaBuilderFixture.cs
+++ b/src/NzbDrone.Api.Test/ClientSchemaTests/SchemaBuilderFixture.cs
@@ -1,8 +1,8 @@
using FluentAssertions;
using NUnit.Framework;
-using NzbDrone.Api.ClientSchema;
using NzbDrone.Core.Annotations;
using NzbDrone.Test.Common;
+using Sonarr.Http.ClientSchema;
namespace NzbDrone.Api.Test.ClientSchemaTests
{
diff --git a/src/NzbDrone.Api.Test/NzbDrone.Api.Test.csproj b/src/NzbDrone.Api.Test/NzbDrone.Api.Test.csproj
index 9d787542e..bca5c6d2d 100644
--- a/src/NzbDrone.Api.Test/NzbDrone.Api.Test.csproj
+++ b/src/NzbDrone.Api.Test/NzbDrone.Api.Test.csproj
@@ -90,6 +90,10 @@
{CADDFCE0-7509-4430-8364-2074E1EEFCA2}
NzbDrone.Test.Common
+
+ {5370BFF7-1BD7-46BC-AF06-7D9EA5CDA1D6}
+ Sonarr.Http
+
diff --git a/src/NzbDrone.Api/Blacklist/BlacklistModule.cs b/src/NzbDrone.Api/Blacklist/BlacklistModule.cs
index 1687b31e3..29002875b 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.Datastore;
+using Sonarr.Http;
namespace NzbDrone.Api.Blacklist
{
- public class BlacklistModule : NzbDroneRestModule
+ public class BlacklistModule : SonarrRestModule
{
private readonly IBlacklistService _blacklistService;
diff --git a/src/NzbDrone.Api/Blacklist/BlacklistResource.cs b/src/NzbDrone.Api/Blacklist/BlacklistResource.cs
index c3f1c6b1b..e7bba03a3 100644
--- a/src/NzbDrone.Api/Blacklist/BlacklistResource.cs
+++ b/src/NzbDrone.Api/Blacklist/BlacklistResource.cs
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
-using NzbDrone.Api.REST;
+using Sonarr.Http.REST;
using NzbDrone.Core.Qualities;
using NzbDrone.Api.Series;
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/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 0d085eb3e..bfd6ddf68 100644
--- a/src/NzbDrone.Api/Commands/CommandModule.cs
+++ b/src/NzbDrone.Api/Commands/CommandModule.cs
@@ -1,8 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.Extensions;
-using NzbDrone.Api.Validation;
+using Sonarr.Http.Extensions;
using NzbDrone.Common;
using NzbDrone.Common.TPL;
using NzbDrone.Core.Datastore.Events;
@@ -10,11 +9,14 @@ using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.ProgressMessaging;
using NzbDrone.SignalR;
+using Sonarr.Http;
+using Sonarr.Http.Mapping;
+using Sonarr.Http.Validation;
namespace NzbDrone.Api.Commands
{
- public class CommandModule : NzbDroneRestModuleWithSignalR, IHandle
+ public class CommandModule : SonarrRestModuleWithSignalR, IHandle
{
private readonly IManageCommandQueue _commandQueueManager;
private readonly IServiceFactory _serviceFactory;
diff --git a/src/NzbDrone.Api/Commands/CommandResource.cs b/src/NzbDrone.Api/Commands/CommandResource.cs
index cf09f12ac..4180851f4 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 Sonarr.Http.REST;
using NzbDrone.Core.Messaging.Commands;
namespace NzbDrone.Api.Commands
diff --git a/src/NzbDrone.Api/Config/DownloadClientConfigResource.cs b/src/NzbDrone.Api/Config/DownloadClientConfigResource.cs
index 8309c9f4d..0c4b00173 100644
--- a/src/NzbDrone.Api/Config/DownloadClientConfigResource.cs
+++ b/src/NzbDrone.Api/Config/DownloadClientConfigResource.cs
@@ -1,4 +1,4 @@
-using NzbDrone.Api.REST;
+using Sonarr.Http.REST;
using NzbDrone.Core.Configuration;
namespace NzbDrone.Api.Config
diff --git a/src/NzbDrone.Api/Config/HostConfigModule.cs b/src/NzbDrone.Api/Config/HostConfigModule.cs
index 367bf770d..d661a5ecf 100644
--- a/src/NzbDrone.Api/Config/HostConfigModule.cs
+++ b/src/NzbDrone.Api/Config/HostConfigModule.cs
@@ -8,10 +8,11 @@ using NzbDrone.Core.Configuration;
using NzbDrone.Core.Update;
using NzbDrone.Core.Validation;
using NzbDrone.Core.Validation.Paths;
+using Sonarr.Http;
namespace NzbDrone.Api.Config
{
- public class HostConfigModule : NzbDroneRestModule
+ public class HostConfigModule : SonarrRestModule
{
private readonly IConfigFileProvider _configFileProvider;
private readonly IConfigService _configService;
diff --git a/src/NzbDrone.Api/Config/HostConfigResource.cs b/src/NzbDrone.Api/Config/HostConfigResource.cs
index 930e0301c..90d51ab19 100644
--- a/src/NzbDrone.Api/Config/HostConfigResource.cs
+++ b/src/NzbDrone.Api/Config/HostConfigResource.cs
@@ -1,4 +1,4 @@
-using NzbDrone.Api.REST;
+using Sonarr.Http.REST;
using NzbDrone.Core.Authentication;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Update;
diff --git a/src/NzbDrone.Api/Config/IndexerConfigModule.cs b/src/NzbDrone.Api/Config/IndexerConfigModule.cs
index ebb8f7cd8..f8c034754 100644
--- a/src/NzbDrone.Api/Config/IndexerConfigModule.cs
+++ b/src/NzbDrone.Api/Config/IndexerConfigModule.cs
@@ -1,6 +1,6 @@
using FluentValidation;
-using NzbDrone.Api.Validation;
using NzbDrone.Core.Configuration;
+using Sonarr.Http.Validation;
namespace NzbDrone.Api.Config
{
diff --git a/src/NzbDrone.Api/Config/IndexerConfigResource.cs b/src/NzbDrone.Api/Config/IndexerConfigResource.cs
index 59fcb48e3..f70c03e68 100644
--- a/src/NzbDrone.Api/Config/IndexerConfigResource.cs
+++ b/src/NzbDrone.Api/Config/IndexerConfigResource.cs
@@ -1,4 +1,4 @@
-using NzbDrone.Api.REST;
+using Sonarr.Http.REST;
using NzbDrone.Core.Configuration;
namespace NzbDrone.Api.Config
diff --git a/src/NzbDrone.Api/Config/MediaManagementConfigResource.cs b/src/NzbDrone.Api/Config/MediaManagementConfigResource.cs
index b10d8209f..0593f33b3 100644
--- a/src/NzbDrone.Api/Config/MediaManagementConfigResource.cs
+++ b/src/NzbDrone.Api/Config/MediaManagementConfigResource.cs
@@ -1,4 +1,4 @@
-using NzbDrone.Api.REST;
+using Sonarr.Http.REST;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles;
diff --git a/src/NzbDrone.Api/Config/NamingConfigModule.cs b/src/NzbDrone.Api/Config/NamingConfigModule.cs
index 0b72e0b0c..f7dc2bf19 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 Sonarr.Http.Extensions;
+using Sonarr.Http;
+using Sonarr.Http.Mapping;
namespace NzbDrone.Api.Config
{
- public class NamingConfigModule : NzbDroneRestModule
+ public class NamingConfigModule : SonarrRestModule
{
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 39147b993..cfc6d507a 100644
--- a/src/NzbDrone.Api/Config/NamingConfigResource.cs
+++ b/src/NzbDrone.Api/Config/NamingConfigResource.cs
@@ -1,4 +1,4 @@
-using NzbDrone.Api.REST;
+using Sonarr.Http.REST;
using NzbDrone.Core.Organizer;
namespace NzbDrone.Api.Config
diff --git a/src/NzbDrone.Api/Config/NzbDroneConfigModule.cs b/src/NzbDrone.Api/Config/NzbDroneConfigModule.cs
index e5d324950..50e1d82e3 100644
--- a/src/NzbDrone.Api/Config/NzbDroneConfigModule.cs
+++ b/src/NzbDrone.Api/Config/NzbDroneConfigModule.cs
@@ -1,11 +1,12 @@
using System.Linq;
using System.Reflection;
-using NzbDrone.Api.REST;
+using Sonarr.Http.REST;
using NzbDrone.Core.Configuration;
+using Sonarr.Http;
namespace NzbDrone.Api.Config
{
- public abstract class NzbDroneConfigModule : NzbDroneRestModule where TResource : RestResource, new()
+ public abstract class NzbDroneConfigModule : SonarrRestModule 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..accda475e 100644
--- a/src/NzbDrone.Api/Config/UiConfigResource.cs
+++ b/src/NzbDrone.Api/Config/UiConfigResource.cs
@@ -1,4 +1,4 @@
-using NzbDrone.Api.REST;
+using Sonarr.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..d19c33f03 100644
--- a/src/NzbDrone.Api/DiskSpace/DiskSpaceModule.cs
+++ b/src/NzbDrone.Api/DiskSpace/DiskSpaceModule.cs
@@ -1,9 +1,10 @@
using System.Collections.Generic;
using NzbDrone.Core.DiskSpace;
+using Sonarr.Http;
namespace NzbDrone.Api.DiskSpace
{
- public class DiskSpaceModule :NzbDroneRestModule
+ public class DiskSpaceModule :SonarrRestModule
{
private readonly IDiskSpaceService _diskSpaceService;
diff --git a/src/NzbDrone.Api/DiskSpace/DiskSpaceResource.cs b/src/NzbDrone.Api/DiskSpace/DiskSpaceResource.cs
index fc36f9d5c..068bf7ad5 100644
--- a/src/NzbDrone.Api/DiskSpace/DiskSpaceResource.cs
+++ b/src/NzbDrone.Api/DiskSpace/DiskSpaceResource.cs
@@ -1,4 +1,4 @@
-using NzbDrone.Api.REST;
+using Sonarr.Http.REST;
namespace NzbDrone.Api.DiskSpace
{
diff --git a/src/NzbDrone.Api/EpisodeFiles/EpisodeFileModule.cs b/src/NzbDrone.Api/EpisodeFiles/EpisodeFileModule.cs
index b061ef343..9919e8907 100644
--- a/src/NzbDrone.Api/EpisodeFiles/EpisodeFileModule.cs
+++ b/src/NzbDrone.Api/EpisodeFiles/EpisodeFileModule.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using Sonarr.Http.REST;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.Events;
@@ -11,7 +12,7 @@ using HttpStatusCode = System.Net.HttpStatusCode;
namespace NzbDrone.Api.EpisodeFiles
{
- public class EpisodeFileModule : NzbDroneRestModuleWithSignalR,
+ public class EpisodeFileModule : SonarrRestModuleWithSignalR,
IHandle
{
private readonly IMediaFileService _mediaFileService;
diff --git a/src/NzbDrone.Api/EpisodeFiles/EpisodeFileResource.cs b/src/NzbDrone.Api/EpisodeFiles/EpisodeFileResource.cs
index ed85d7119..9ce4d9938 100644
--- a/src/NzbDrone.Api/EpisodeFiles/EpisodeFileResource.cs
+++ b/src/NzbDrone.Api/EpisodeFiles/EpisodeFileResource.cs
@@ -1,6 +1,8 @@
using System;
using System.IO;
-using NzbDrone.Api.REST;
+using NzbDrone.Core.DecisionEngine;
+using NzbDrone.Core.MediaFiles;
+using Sonarr.Http.REST;
using NzbDrone.Core.Qualities;
namespace NzbDrone.Api.EpisodeFiles
@@ -23,7 +25,7 @@ namespace NzbDrone.Api.EpisodeFiles
public static class EpisodeFileResourceMapper
{
- private static EpisodeFileResource ToResource(this Core.MediaFiles.EpisodeFile model)
+ private static EpisodeFileResource ToResource(this EpisodeFile model)
{
if (model == null) return null;
@@ -44,7 +46,7 @@ namespace NzbDrone.Api.EpisodeFiles
};
}
- public static EpisodeFileResource ToResource(this Core.MediaFiles.EpisodeFile model, Core.Tv.Series series, Core.DecisionEngine.IQualityUpgradableSpecification qualityUpgradableSpecification)
+ public static EpisodeFileResource ToResource(this EpisodeFile model, Core.Tv.Series series, IQualityUpgradableSpecification qualityUpgradableSpecification)
{
if (model == null) return null;
@@ -60,7 +62,7 @@ namespace NzbDrone.Api.EpisodeFiles
DateAdded = model.DateAdded,
SceneName = model.SceneName,
Quality = model.Quality,
- QualityCutoffNotMet = qualityUpgradableSpecification.CutoffNotMet(series.Profile.Value, model.Quality),
+ QualityCutoffNotMet = upgradableSpecification.QualityCutoffNotMet(series.Profile.Value, model.Quality),
MediaInfo = model.MediaInfo.ToResource(model.SceneName),
OriginalFilePath = model.OriginalFilePath
};
diff --git a/src/NzbDrone.Api/EpisodeFiles/MediaInfoResource.cs b/src/NzbDrone.Api/EpisodeFiles/MediaInfoResource.cs
index 672c48fcd..f34cafd2f 100644
--- a/src/NzbDrone.Api/EpisodeFiles/MediaInfoResource.cs
+++ b/src/NzbDrone.Api/EpisodeFiles/MediaInfoResource.cs
@@ -1,5 +1,5 @@
-using NzbDrone.Api.REST;
using NzbDrone.Core.MediaFiles.MediaInfo;
+using Sonarr.Http.REST;
namespace NzbDrone.Api.EpisodeFiles
{
diff --git a/src/NzbDrone.Api/Episodes/EpisodeModule.cs b/src/NzbDrone.Api/Episodes/EpisodeModule.cs
index 7f6f5692c..bd57332b7 100644
--- a/src/NzbDrone.Api/Episodes/EpisodeModule.cs
+++ b/src/NzbDrone.Api/Episodes/EpisodeModule.cs
@@ -1,5 +1,5 @@
using System.Collections.Generic;
-using NzbDrone.Api.REST;
+using Sonarr.Http.REST;
using NzbDrone.Core.Tv;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.SignalR;
diff --git a/src/NzbDrone.Api/Episodes/EpisodeModuleWithSignalR.cs b/src/NzbDrone.Api/Episodes/EpisodeModuleWithSignalR.cs
index 349a629a4..ffdc051fa 100644
--- a/src/NzbDrone.Api/Episodes/EpisodeModuleWithSignalR.cs
+++ b/src/NzbDrone.Api/Episodes/EpisodeModuleWithSignalR.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
-using NzbDrone.Common.Extensions;
using NzbDrone.Api.EpisodeFiles;
using NzbDrone.Api.Series;
+using NzbDrone.Common.Extensions;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
@@ -9,10 +9,11 @@ using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Tv;
using NzbDrone.SignalR;
+using Sonarr.Http;
namespace NzbDrone.Api.Episodes
{
- public abstract class EpisodeModuleWithSignalR : NzbDroneRestModuleWithSignalR,
+ public abstract class EpisodeModuleWithSignalR : SonarrRestModuleWithSignalR,
IHandle,
IHandle
{
diff --git a/src/NzbDrone.Api/Episodes/EpisodeResource.cs b/src/NzbDrone.Api/Episodes/EpisodeResource.cs
index 3eb09bbf4..6c785c8b5 100644
--- a/src/NzbDrone.Api/Episodes/EpisodeResource.cs
+++ b/src/NzbDrone.Api/Episodes/EpisodeResource.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using NzbDrone.Api.EpisodeFiles;
-using NzbDrone.Api.REST;
+using Sonarr.Http.REST;
using NzbDrone.Api.Series;
using NzbDrone.Core.Tv;
diff --git a/src/NzbDrone.Api/Episodes/RenameEpisodeModule.cs b/src/NzbDrone.Api/Episodes/RenameEpisodeModule.cs
index 87f39b964..b0bb2ecb7 100644
--- a/src/NzbDrone.Api/Episodes/RenameEpisodeModule.cs
+++ b/src/NzbDrone.Api/Episodes/RenameEpisodeModule.cs
@@ -1,10 +1,11 @@
using System.Collections.Generic;
-using NzbDrone.Api.REST;
+using Sonarr.Http.REST;
using NzbDrone.Core.MediaFiles;
+using Sonarr.Http;
namespace NzbDrone.Api.Episodes
{
- public class RenameEpisodeModule : NzbDroneRestModule
+ public class RenameEpisodeModule : SonarrRestModule
{
private readonly IRenameEpisodeFileService _renameEpisodeFileService;
diff --git a/src/NzbDrone.Api/Episodes/RenameEpisodeResource.cs b/src/NzbDrone.Api/Episodes/RenameEpisodeResource.cs
index c48f2cdf4..b1f99a28b 100644
--- a/src/NzbDrone.Api/Episodes/RenameEpisodeResource.cs
+++ b/src/NzbDrone.Api/Episodes/RenameEpisodeResource.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.REST;
+using Sonarr.Http.REST;
namespace NzbDrone.Api.Episodes
{
diff --git a/src/NzbDrone.Api/FileSystem/FileSystemModule.cs b/src/NzbDrone.Api/FileSystem/FileSystemModule.cs
index 67c2be7bd..0dab92ee8 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 Sonarr.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 218d185f5..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)=\"")(?.*?(?css|js|png|ico|ics|svg))(?:\"")(?:\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..c3b64c607 100644
--- a/src/NzbDrone.Api/Health/HealthModule.cs
+++ b/src/NzbDrone.Api/Health/HealthModule.cs
@@ -3,10 +3,11 @@ using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.HealthCheck;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.SignalR;
+using Sonarr.Http;
namespace NzbDrone.Api.Health
{
- public class HealthModule : NzbDroneRestModuleWithSignalR,
+ public class HealthModule : SonarrRestModuleWithSignalR,
IHandle
{
private readonly IHealthCheckService _healthCheckService;
diff --git a/src/NzbDrone.Api/Health/HealthResource.cs b/src/NzbDrone.Api/Health/HealthResource.cs
index e860cb778..934079d38 100644
--- a/src/NzbDrone.Api/Health/HealthResource.cs
+++ b/src/NzbDrone.Api/Health/HealthResource.cs
@@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.REST;
using NzbDrone.Common.Http;
using NzbDrone.Core.HealthCheck;
+using Sonarr.Http.REST;
namespace NzbDrone.Api.Health
{
diff --git a/src/NzbDrone.Api/History/HistoryModule.cs b/src/NzbDrone.Api/History/HistoryModule.cs
index 4902c195a..3b441dd6b 100644
--- a/src/NzbDrone.Api/History/HistoryModule.cs
+++ b/src/NzbDrone.Api/History/HistoryModule.cs
@@ -3,17 +3,18 @@ using System.Collections.Generic;
using System.Linq;
using Nancy;
using NzbDrone.Api.Episodes;
-using NzbDrone.Api.Extensions;
-using NzbDrone.Api.REST;
+using Sonarr.Http.Extensions;
using NzbDrone.Api.Series;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.History;
+using Sonarr.Http;
+using Sonarr.Http.REST;
namespace NzbDrone.Api.History
{
- public class HistoryModule : NzbDroneRestModule
+ public class HistoryModule : SonarrRestModule
{
private readonly IHistoryService _historyService;
private readonly IQualityUpgradableSpecification _qualityUpgradableSpecification;
@@ -50,19 +51,19 @@ namespace NzbDrone.Api.History
private PagingResource GetHistory(PagingResource pagingResource)
{
var episodeId = Request.Query.EpisodeId;
-
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 (episodeId.HasValue)
{
int i = (int)episodeId;
- pagingSpec.FilterExpression = h => h.EpisodeId == i;
+ pagingSpec.FilterExpressions.Add(h => h.EpisodeId == i);
}
return ApplyToPage(_historyService.Paged, pagingSpec, MapToResource);
diff --git a/src/NzbDrone.Api/History/HistoryResource.cs b/src/NzbDrone.Api/History/HistoryResource.cs
index dba4149dd..ad5786f34 100644
--- a/src/NzbDrone.Api/History/HistoryResource.cs
+++ b/src/NzbDrone.Api/History/HistoryResource.cs
@@ -1,12 +1,11 @@
using System;
using System.Collections.Generic;
using NzbDrone.Api.Episodes;
-using NzbDrone.Api.REST;
+using Sonarr.Http.REST;
using NzbDrone.Api.Series;
using NzbDrone.Core.History;
using NzbDrone.Core.Qualities;
-
namespace NzbDrone.Api.History
{
public class HistoryResource : RestResource
diff --git a/src/NzbDrone.Api/Indexers/ReleaseModule.cs b/src/NzbDrone.Api/Indexers/ReleaseModule.cs
index 0f28dc3fa..9793800b5 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 Sonarr.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 f6a223475..e5d0cca47 100644
--- a/src/NzbDrone.Api/Indexers/ReleaseModuleBase.cs
+++ b/src/NzbDrone.Api/Indexers/ReleaseModuleBase.cs
@@ -1,9 +1,10 @@
using System.Collections.Generic;
using NzbDrone.Core.DecisionEngine;
+using Sonarr.Http;
namespace NzbDrone.Api.Indexers
{
- public abstract class ReleaseModuleBase : NzbDroneRestModule
+ public abstract class ReleaseModuleBase : SonarrRestModule
{
protected virtual List MapDecisions(IEnumerable decisions)
{
diff --git a/src/NzbDrone.Api/Indexers/ReleasePushModule.cs b/src/NzbDrone.Api/Indexers/ReleasePushModule.cs
index 7cb93739c..e9e6da37f 100644
--- a/src/NzbDrone.Api/Indexers/ReleasePushModule.cs
+++ b/src/NzbDrone.Api/Indexers/ReleasePushModule.cs
@@ -11,6 +11,8 @@ using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Parser.Model;
+using Sonarr.Http.Extensions;
+using Sonarr.Http.Mapping;
namespace NzbDrone.Api.Indexers
{
diff --git a/src/NzbDrone.Api/Indexers/ReleaseResource.cs b/src/NzbDrone.Api/Indexers/ReleaseResource.cs
index 6bf07910d..c9c0f6d78 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 Sonarr.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..53c8e57a3 100644
--- a/src/NzbDrone.Api/Logs/LogFileModuleBase.cs
+++ b/src/NzbDrone.Api/Logs/LogFileModuleBase.cs
@@ -5,10 +5,11 @@ using NzbDrone.Common.Disk;
using Nancy;
using Nancy.Responses;
using NzbDrone.Core.Configuration;
+using Sonarr.Http;
namespace NzbDrone.Api.Logs
{
- public abstract class LogFileModuleBase : NzbDroneRestModule
+ public abstract class LogFileModuleBase : SonarrRestModule
{
protected const string LOGFILE_ROUTE = @"/(?[-.a-zA-Z0-9]+?\.txt)";
diff --git a/src/NzbDrone.Api/Logs/LogFileResource.cs b/src/NzbDrone.Api/Logs/LogFileResource.cs
index 9f67c8af7..743d797f3 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 Sonarr.Http.REST;
namespace NzbDrone.Api.Logs
{
diff --git a/src/NzbDrone.Api/Logs/LogModule.cs b/src/NzbDrone.Api/Logs/LogModule.cs
index 88ead3ec0..3e395a6fa 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 Sonarr.Http;
namespace NzbDrone.Api.Logs
{
- public class LogModule : NzbDroneRestModule
+ public class LogModule : SonarrRestModule
{
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..27a8f7047 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 Sonarr.Http.REST;
namespace NzbDrone.Api.Logs
{
diff --git a/src/NzbDrone.Api/ManualImport/ManualImportModule.cs b/src/NzbDrone.Api/ManualImport/ManualImportModule.cs
index 024b8e452..1937d01f8 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.EpisodeImport.Manual;
using NzbDrone.Core.Qualities;
+using Sonarr.Http;
+using Sonarr.Http.Extensions;
namespace NzbDrone.Api.ManualImport
{
- public class ManualImportModule : NzbDroneRestModule
+ public class ManualImportModule : SonarrRestModule
{
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)
@@ -40,4 +43,4 @@ namespace NzbDrone.Api.ManualImport
return item;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Api/ManualImport/ManualImportResource.cs b/src/NzbDrone.Api/ManualImport/ManualImportResource.cs
index 1a779a410..f283b543e 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.Episodes;
-using NzbDrone.Api.REST;
+using Sonarr.Http.REST;
using NzbDrone.Api.Series;
using NzbDrone.Common.Crypto;
using NzbDrone.Core.DecisionEngine;
diff --git a/src/NzbDrone.Api/NzbDrone.Api.csproj b/src/NzbDrone.Api/NzbDrone.Api.csproj
index dfa4bfb4e..039f70edd 100644
--- a/src/NzbDrone.Api/NzbDrone.Api.csproj
+++ b/src/NzbDrone.Api/NzbDrone.Api.csproj
@@ -78,7 +78,6 @@
-
False
@@ -88,43 +87,31 @@
+
+ ..\packages\ValueInjecter.2.3.3\lib\net35\Omu.ValueInjecter.dll
+
Properties\SharedAssemblyInfo.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -154,31 +141,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -196,14 +158,9 @@
-
-
-
-
-
@@ -212,21 +169,13 @@
-
-
-
-
-
-
-
-
@@ -245,12 +194,8 @@
-
-
-
-
@@ -278,6 +223,10 @@
{7C2CC69F-5CA0-4E5C-85CB-983F9F6C3B36}
NzbDrone.SignalR
+
+ {5370BFF7-1BD7-46BC-AF06-7D9EA5CDA1D6}
+ Sonarr.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 266f66eb4..0dec532ae 100644
--- a/src/NzbDrone.Api/Parse/ParseModule.cs
+++ b/src/NzbDrone.Api/Parse/ParseModule.cs
@@ -2,10 +2,11 @@
using NzbDrone.Api.Series;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Parser;
+using Sonarr.Http;
namespace NzbDrone.Api.Parse
{
- public class ParseModule : NzbDroneRestModule
+ public class ParseModule : SonarrRestModule
{
private readonly IParsingService _parsingService;
diff --git a/src/NzbDrone.Api/Parse/ParseResource.cs b/src/NzbDrone.Api/Parse/ParseResource.cs
index c795f09c3..8ba51bd0e 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.Episodes;
-using NzbDrone.Api.REST;
+using Sonarr.Http.REST;
using NzbDrone.Api.Series;
using NzbDrone.Core.Parser.Model;
diff --git a/src/NzbDrone.Api/Profiles/Delay/DelayProfileModule.cs b/src/NzbDrone.Api/Profiles/Delay/DelayProfileModule.cs
index e7975b661..636979d86 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 FluentValidation;
using FluentValidation.Results;
-using NzbDrone.Api.REST;
-using NzbDrone.Api.Validation;
+using Sonarr.Http.REST;
using NzbDrone.Core.Profiles.Delay;
+using Sonarr.Http;
+using Sonarr.Http.Validation;
namespace NzbDrone.Api.Profiles.Delay
{
- public class DelayProfileModule : NzbDroneRestModule
+ public class DelayProfileModule : SonarrRestModule
{
private readonly IDelayProfileService _delayProfileService;
diff --git a/src/NzbDrone.Api/Profiles/Delay/DelayProfileResource.cs b/src/NzbDrone.Api/Profiles/Delay/DelayProfileResource.cs
index e35df9043..53b7c4f19 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 Sonarr.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..5576c8e9f 100644
--- a/src/NzbDrone.Api/Profiles/Languages/LanguageModule.cs
+++ b/src/NzbDrone.Api/Profiles/Languages/LanguageModule.cs
@@ -2,10 +2,11 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Parser;
+using Sonarr.Http;
namespace NzbDrone.Api.Profiles.Languages
{
- public class LanguageModule : NzbDroneRestModule
+ public class LanguageModule : SonarrRestModule
{
public LanguageModule()
{
diff --git a/src/NzbDrone.Api/Profiles/Languages/LanguageResource.cs b/src/NzbDrone.Api/Profiles/Languages/LanguageResource.cs
index 09e5ba28c..adae3854c 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 Sonarr.Http.REST;
namespace NzbDrone.Api.Profiles.Languages
{
diff --git a/src/NzbDrone.Api/Profiles/ProfileModule.cs b/src/NzbDrone.Api/Profiles/ProfileModule.cs
index e5803db20..4290c5a56 100644
--- a/src/NzbDrone.Api/Profiles/ProfileModule.cs
+++ b/src/NzbDrone.Api/Profiles/ProfileModule.cs
@@ -2,10 +2,12 @@
using FluentValidation;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Validation;
+using Sonarr.Http;
+using Sonarr.Http.Mapping;
namespace NzbDrone.Api.Profiles
{
- public class ProfileModule : NzbDroneRestModule
+ public class ProfileModule : SonarrRestModule
{
private readonly IProfileService _profileService;
diff --git a/src/NzbDrone.Api/Profiles/ProfileResource.cs b/src/NzbDrone.Api/Profiles/ProfileResource.cs
index ee02bcb32..d407942dc 100644
--- a/src/NzbDrone.Api/Profiles/ProfileResource.cs
+++ b/src/NzbDrone.Api/Profiles/ProfileResource.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.REST;
+using Sonarr.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 ec5f3ae01..423db02bd 100644
--- a/src/NzbDrone.Api/Profiles/ProfileSchemaModule.cs
+++ b/src/NzbDrone.Api/Profiles/ProfileSchemaModule.cs
@@ -3,10 +3,12 @@ using System.Linq;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Qualities;
+using Sonarr.Http;
+using Sonarr.Http.Mapping;
namespace NzbDrone.Api.Profiles
{
- public class ProfileSchemaModule : NzbDroneRestModule
+ public class ProfileSchemaModule : SonarrRestModule
{
private readonly IQualityDefinitionService _qualityDefinitionService;
diff --git a/src/NzbDrone.Api/ProviderModuleBase.cs b/src/NzbDrone.Api/ProviderModuleBase.cs
index d7ad2ec67..6705437bf 100644
--- a/src/NzbDrone.Api/ProviderModuleBase.cs
+++ b/src/NzbDrone.Api/ProviderModuleBase.cs
@@ -3,16 +3,18 @@ using System.Linq;
using FluentValidation;
using FluentValidation.Results;
using Nancy;
-using NzbDrone.Api.ClientSchema;
-using NzbDrone.Api.Extensions;
+using Sonarr.Http.Extensions;
using NzbDrone.Common.Reflection;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
using Newtonsoft.Json;
+using Sonarr.Http;
+using Sonarr.Http.ClientSchema;
+using Sonarr.Http.Mapping;
namespace NzbDrone.Api
{
- public abstract class ProviderModuleBase : NzbDroneRestModule
+ public abstract class ProviderModuleBase : SonarrRestModule
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..832e6becf 100644
--- a/src/NzbDrone.Api/ProviderResource.cs
+++ b/src/NzbDrone.Api/ProviderResource.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
-using NzbDrone.Api.ClientSchema;
-using NzbDrone.Api.REST;
+using Sonarr.Http.REST;
using NzbDrone.Core.ThingiProvider;
+using Sonarr.Http.ClientSchema;
namespace NzbDrone.Api
{
diff --git a/src/NzbDrone.Api/Qualities/QualityDefinitionModule.cs b/src/NzbDrone.Api/Qualities/QualityDefinitionModule.cs
index 1b5351300..bf1740db3 100644
--- a/src/NzbDrone.Api/Qualities/QualityDefinitionModule.cs
+++ b/src/NzbDrone.Api/Qualities/QualityDefinitionModule.cs
@@ -1,9 +1,11 @@
using System.Collections.Generic;
using NzbDrone.Core.Qualities;
+using Sonarr.Http;
+using Sonarr.Http.Mapping;
namespace NzbDrone.Api.Qualities
{
- public class QualityDefinitionModule : NzbDroneRestModule
+ public class QualityDefinitionModule : SonarrRestModule
{
private readonly IQualityDefinitionService _qualityDefinitionService;
diff --git a/src/NzbDrone.Api/Qualities/QualityDefinitionResource.cs b/src/NzbDrone.Api/Qualities/QualityDefinitionResource.cs
index ea0edc0ab..fefe8fcd0 100644
--- a/src/NzbDrone.Api/Qualities/QualityDefinitionResource.cs
+++ b/src/NzbDrone.Api/Qualities/QualityDefinitionResource.cs
@@ -1,6 +1,6 @@
-using System.Collections.Generic;
+using Sonarr.Http.REST;
+using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.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 9882e60e6..7f5307929 100644
--- a/src/NzbDrone.Api/Queue/QueueActionModule.cs
+++ b/src/NzbDrone.Api/Queue/QueueActionModule.cs
@@ -1,16 +1,17 @@
using System;
using Nancy;
using Nancy.Responses;
-using NzbDrone.Api.Extensions;
-using NzbDrone.Api.REST;
+using Sonarr.Http.Extensions;
+using Sonarr.Http.REST;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Pending;
using NzbDrone.Core.Download.TrackedDownloads;
using NzbDrone.Core.Queue;
+using Sonarr.Http;
namespace NzbDrone.Api.Queue
{
- public class QueueActionModule : NzbDroneRestModule
+ public class QueueActionModule : SonarrRestModule
{
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..39053d0fc 100644
--- a/src/NzbDrone.Api/Queue/QueueModule.cs
+++ b/src/NzbDrone.Api/Queue/QueueModule.cs
@@ -5,10 +5,11 @@ using NzbDrone.Core.Download.Pending;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Queue;
using NzbDrone.SignalR;
+using Sonarr.Http;
namespace NzbDrone.Api.Queue
{
- public class QueueModule : NzbDroneRestModuleWithSignalR,
+ public class QueueModule : SonarrRestModuleWithSignalR,
IHandle, IHandle
{
private readonly IQueueService _queueService;
diff --git a/src/NzbDrone.Api/Queue/QueueResource.cs b/src/NzbDrone.Api/Queue/QueueResource.cs
index cf1356c49..88fd05f43 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 Sonarr.Http.REST;
using NzbDrone.Core.Qualities;
using NzbDrone.Api.Series;
using NzbDrone.Api.Episodes;
diff --git a/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingModule.cs b/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingModule.cs
index a61b5f7b3..c5e2f0bd3 100644
--- a/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingModule.cs
+++ b/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingModule.cs
@@ -2,10 +2,11 @@
using FluentValidation;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.Validation.Paths;
+using Sonarr.Http;
namespace NzbDrone.Api.RemotePathMappings
{
- public class RemotePathMappingModule : NzbDroneRestModule
+ public class RemotePathMappingModule : SonarrRestModule
{
private readonly IRemotePathMappingService _remotePathMappingService;
diff --git a/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingResource.cs b/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingResource.cs
index 60c01b682..5b5ff727b 100644
--- a/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingResource.cs
+++ b/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingResource.cs
@@ -1,6 +1,6 @@
-using System.Collections.Generic;
+using Sonarr.Http.REST;
+using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.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..569b9efd9 100644
--- a/src/NzbDrone.Api/Restrictions/RestrictionModule.cs
+++ b/src/NzbDrone.Api/Restrictions/RestrictionModule.cs
@@ -2,10 +2,12 @@
using FluentValidation.Results;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Restrictions;
+using Sonarr.Http;
+using Sonarr.Http.Mapping;
namespace NzbDrone.Api.Restrictions
{
- public class RestrictionModule : NzbDroneRestModule
+ public class RestrictionModule : SonarrRestModule
{
private readonly IRestrictionService _restrictionService;
diff --git a/src/NzbDrone.Api/Restrictions/RestrictionResource.cs b/src/NzbDrone.Api/Restrictions/RestrictionResource.cs
index 14085e820..0e1eddfb1 100644
--- a/src/NzbDrone.Api/Restrictions/RestrictionResource.cs
+++ b/src/NzbDrone.Api/Restrictions/RestrictionResource.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.REST;
+using Sonarr.Http.REST;
using NzbDrone.Core.Restrictions;
namespace NzbDrone.Api.Restrictions
diff --git a/src/NzbDrone.Api/RootFolders/RootFolderModule.cs b/src/NzbDrone.Api/RootFolders/RootFolderModule.cs
index 30303ab73..2581f4c35 100644
--- a/src/NzbDrone.Api/RootFolders/RootFolderModule.cs
+++ b/src/NzbDrone.Api/RootFolders/RootFolderModule.cs
@@ -3,10 +3,12 @@ using FluentValidation;
using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Validation.Paths;
using NzbDrone.SignalR;
+using Sonarr.Http;
+using Sonarr.Http.Mapping;
namespace NzbDrone.Api.RootFolders
{
- public class RootFolderModule : NzbDroneRestModuleWithSignalR
+ public class RootFolderModule : SonarrRestModuleWithSignalR
{
private readonly IRootFolderService _rootFolderService;
diff --git a/src/NzbDrone.Api/RootFolders/RootFolderResource.cs b/src/NzbDrone.Api/RootFolders/RootFolderResource.cs
index df55fcf1a..13fc1b198 100644
--- a/src/NzbDrone.Api/RootFolders/RootFolderResource.cs
+++ b/src/NzbDrone.Api/RootFolders/RootFolderResource.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
+using Sonarr.Http.REST;
using System.Linq;
-using NzbDrone.Api.REST;
using NzbDrone.Core.RootFolders;
namespace NzbDrone.Api.RootFolders
diff --git a/src/NzbDrone.Api/SeasonPass/SeasonPassModule.cs b/src/NzbDrone.Api/SeasonPass/SeasonPassModule.cs
index 93cd25ce5..78c7d713a 100644
--- a/src/NzbDrone.Api/SeasonPass/SeasonPassModule.cs
+++ b/src/NzbDrone.Api/SeasonPass/SeasonPassModule.cs
@@ -1,5 +1,5 @@
using Nancy;
-using NzbDrone.Api.Extensions;
+using Sonarr.Http.Extensions;
using NzbDrone.Core.Tv;
namespace NzbDrone.Api.SeasonPass
diff --git a/src/NzbDrone.Api/Series/SeriesEditorModule.cs b/src/NzbDrone.Api/Series/SeriesEditorModule.cs
index d68fa7aa4..7fa65a16e 100644
--- a/src/NzbDrone.Api/Series/SeriesEditorModule.cs
+++ b/src/NzbDrone.Api/Series/SeriesEditorModule.cs
@@ -1,8 +1,9 @@
using System.Collections.Generic;
using System.Linq;
using Nancy;
-using NzbDrone.Api.Extensions;
+using Sonarr.Http.Extensions;
using NzbDrone.Core.Tv;
+using Sonarr.Http.Mapping;
namespace NzbDrone.Api.Series
{
@@ -23,7 +24,7 @@ namespace NzbDrone.Api.Series
var series = resources.Select(seriesResource => seriesResource.ToModel(_seriesService.GetSeries(seriesResource.Id))).ToList();
- return _seriesService.UpdateSeries(series)
+ return _seriesService.UpdateSeries(series, true)
.ToResource(false)
.AsResponse(HttpStatusCode.Accepted);
}
diff --git a/src/NzbDrone.Api/Series/SeriesLookupModule.cs b/src/NzbDrone.Api/Series/SeriesLookupModule.cs
index 6506c1f82..843edc7b7 100644
--- a/src/NzbDrone.Api/Series/SeriesLookupModule.cs
+++ b/src/NzbDrone.Api/Series/SeriesLookupModule.cs
@@ -1,13 +1,15 @@
using System.Collections.Generic;
using Nancy;
-using NzbDrone.Api.Extensions;
+using Sonarr.Http.Extensions;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource;
using System.Linq;
+using Sonarr.Http;
+using Sonarr.Http.Mapping;
namespace NzbDrone.Api.Series
{
- public class SeriesLookupModule : NzbDroneRestModule
+ public class SeriesLookupModule : SonarrRestModule
{
private readonly ISearchForNewSeries _searchProxy;
diff --git a/src/NzbDrone.Api/Series/SeriesModule.cs b/src/NzbDrone.Api/Series/SeriesModule.cs
index 2ad1012e0..2ba912aec 100644
--- a/src/NzbDrone.Api/Series/SeriesModule.cs
+++ b/src/NzbDrone.Api/Series/SeriesModule.cs
@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using FluentValidation;
-using NzbDrone.Api.Extensions;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.MediaCover;
@@ -16,10 +15,12 @@ using NzbDrone.Core.Validation.Paths;
using NzbDrone.Core.DataAugmentation.Scene;
using NzbDrone.Core.Validation;
using NzbDrone.SignalR;
+using Sonarr.Http;
+using Sonarr.Http.Extensions;
namespace NzbDrone.Api.Series
{
- public class SeriesModule : NzbDroneRestModuleWithSignalR,
+ public class SeriesModule : SonarrRestModuleWithSignalR,
IHandle,
IHandle,
IHandle,
@@ -64,7 +65,7 @@ namespace NzbDrone.Api.Series
UpdateResource = UpdateSeries;
DeleteResource = DeleteSeries;
- Validation.RuleBuilderExtensions.ValidId(SharedValidator.RuleFor(s => s.ProfileId));
+ SharedValidator.RuleFor(s => s.ProfileId).ValidId();
SharedValidator.RuleFor(s => s.Path)
.Cascade(CascadeMode.StopOnFirstFailure)
@@ -207,7 +208,12 @@ namespace NzbDrone.Api.Series
if (mappings == null) return;
- resource.AlternateTitles = mappings.Select(v => new AlternateTitleResource { Title = v.Title, SeasonNumber = v.SeasonNumber, SceneSeasonNumber = v.SceneSeasonNumber }).ToList();
+ resource.AlternateTitles = mappings.Select(v => new AlternateTitleResource
+ {
+ Title = v.Title,
+ SeasonNumber = v.SeasonNumber,
+ SceneSeasonNumber = v.SceneSeasonNumber
+ }).ToList();
}
public void Handle(EpisodeImportedEvent message)
diff --git a/src/NzbDrone.Api/Series/SeriesResource.cs b/src/NzbDrone.Api/Series/SeriesResource.cs
index b973ad30d..e73b9db3e 100644
--- a/src/NzbDrone.Api/Series/SeriesResource.cs
+++ b/src/NzbDrone.Api/Series/SeriesResource.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.REST;
+using Sonarr.Http.REST;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.Tv;
@@ -76,8 +76,6 @@ namespace NzbDrone.Api.Series
public AddSeriesOptions AddOptions { get; set; }
public Ratings Ratings { get; set; }
- //TODO: Add series statistics as a property of the series (instead of individual properties)
-
//Used to support legacy consumers
public int QualityProfileId
{
diff --git a/src/NzbDrone.Api/System/Backup/BackupModule.cs b/src/NzbDrone.Api/System/Backup/BackupModule.cs
index 8874ad420..d9bbb4f5a 100644
--- a/src/NzbDrone.Api/System/Backup/BackupModule.cs
+++ b/src/NzbDrone.Api/System/Backup/BackupModule.cs
@@ -2,10 +2,11 @@
using System.IO;
using System.Linq;
using NzbDrone.Core.Backup;
+using Sonarr.Http;
namespace NzbDrone.Api.System.Backup
{
- public class BackupModule : NzbDroneRestModule
+ public class BackupModule : SonarrRestModule
{
private readonly IBackupService _backupService;
diff --git a/src/NzbDrone.Api/System/Backup/BackupResource.cs b/src/NzbDrone.Api/System/Backup/BackupResource.cs
index 7eac82838..40a0877f1 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 Sonarr.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 c62ed3b9e..27b10f385 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 Sonarr.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 db8c4f376..7eb75a79d 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 Sonarr.Http;
namespace NzbDrone.Api.System.Tasks
{
- public class TaskModule : NzbDroneRestModuleWithSignalR, IHandle
+ public class TaskModule : SonarrRestModuleWithSignalR, IHandle
{
private readonly ITaskManager _taskManager;
diff --git a/src/NzbDrone.Api/System/Tasks/TaskResource.cs b/src/NzbDrone.Api/System/Tasks/TaskResource.cs
index fda392cae..91d54f95c 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 Sonarr.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..da4a04cbb 100644
--- a/src/NzbDrone.Api/Tags/TagModule.cs
+++ b/src/NzbDrone.Api/Tags/TagModule.cs
@@ -3,10 +3,12 @@ using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Tags;
using NzbDrone.SignalR;
+using Sonarr.Http;
+using Sonarr.Http.Mapping;
namespace NzbDrone.Api.Tags
{
- public class TagModule : NzbDroneRestModuleWithSignalR, IHandle
+ public class TagModule : SonarrRestModuleWithSignalR, IHandle
{
private readonly ITagService _tagService;
diff --git a/src/NzbDrone.Api/Tags/TagResource.cs b/src/NzbDrone.Api/Tags/TagResource.cs
index 678107bf5..13ca810ba 100644
--- a/src/NzbDrone.Api/Tags/TagResource.cs
+++ b/src/NzbDrone.Api/Tags/TagResource.cs
@@ -1,6 +1,6 @@
-using System.Collections.Generic;
+using Sonarr.Http.REST;
+using System.Collections.Generic;
using System.Linq;
-using NzbDrone.Api.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..79b269b32 100644
--- a/src/NzbDrone.Api/Update/UpdateModule.cs
+++ b/src/NzbDrone.Api/Update/UpdateModule.cs
@@ -2,10 +2,12 @@
using System.Linq;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Core.Update;
+using Sonarr.Http;
+using Sonarr.Http.Mapping;
namespace NzbDrone.Api.Update
{
- public class UpdateModule : NzbDroneRestModule
+ public class UpdateModule : SonarrRestModule
{
private readonly IRecentUpdateProvider _recentUpdateProvider;
diff --git a/src/NzbDrone.Api/Update/UpdateResource.cs b/src/NzbDrone.Api/Update/UpdateResource.cs
index dca6f6725..d1d7a33d2 100644
--- a/src/NzbDrone.Api/Update/UpdateResource.cs
+++ b/src/NzbDrone.Api/Update/UpdateResource.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
-using NzbDrone.Api.REST;
+using Sonarr.Http.REST;
using NzbDrone.Core.Update;
namespace NzbDrone.Api.Update
diff --git a/src/NzbDrone.Api/Wanted/CutoffModule.cs b/src/NzbDrone.Api/Wanted/CutoffModule.cs
index d2d08edab..58a4f748f 100644
--- a/src/NzbDrone.Api/Wanted/CutoffModule.cs
+++ b/src/NzbDrone.Api/Wanted/CutoffModule.cs
@@ -1,8 +1,10 @@
-using NzbDrone.Api.Episodes;
+using System.Linq;
+using NzbDrone.Api.Episodes;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Tv;
using NzbDrone.SignalR;
+using Sonarr.Http;
namespace NzbDrone.Api.Wanted
{
@@ -24,14 +26,15 @@ namespace NzbDrone.Api.Wanted
private PagingResource GetCutoffUnmetEpisodes(PagingResource pagingResource)
{
var pagingSpec = pagingResource.MapToPagingSpec("airDateUtc", SortDirection.Descending);
+ var filter = pagingResource.Filters.FirstOrDefault(f => f.Key == "monitored");
- if (pagingResource.FilterKey == "monitored" && pagingResource.FilterValue == "false")
+ if (filter != null && filter.Value == "false")
{
- pagingSpec.FilterExpression = v => v.Monitored == false || v.Series.Monitored == false;
+ pagingSpec.FilterExpressions.Add(v => v.Monitored == false || v.Series.Monitored == false);
}
else
{
- pagingSpec.FilterExpression = v => v.Monitored == true && v.Series.Monitored == true;
+ pagingSpec.FilterExpressions.Add(v => v.Monitored == true && v.Series.Monitored == true);
}
var resource = ApplyToPage(_episodeCutoffService.EpisodesWhereCutoffUnmet, pagingSpec, v => MapToResource(v, true, true));
diff --git a/src/NzbDrone.Api/Wanted/MissingModule.cs b/src/NzbDrone.Api/Wanted/MissingModule.cs
index 9f6215a2e..e30dc9cf4 100644
--- a/src/NzbDrone.Api/Wanted/MissingModule.cs
+++ b/src/NzbDrone.Api/Wanted/MissingModule.cs
@@ -1,8 +1,10 @@
-using NzbDrone.Api.Episodes;
+using System.Linq;
+using NzbDrone.Api.Episodes;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Tv;
using NzbDrone.SignalR;
+using Sonarr.Http;
namespace NzbDrone.Api.Wanted
{
@@ -20,14 +22,15 @@ namespace NzbDrone.Api.Wanted
private PagingResource GetMissingEpisodes(PagingResource pagingResource)
{
var pagingSpec = pagingResource.MapToPagingSpec("airDateUtc", SortDirection.Descending);
+ var monitoredFilter = pagingResource.Filters.FirstOrDefault(f => f.Key == "monitored");
- if (pagingResource.FilterKey == "monitored" && pagingResource.FilterValue == "false")
+ if (monitoredFilter != null && monitoredFilter.Value == "false")
{
- pagingSpec.FilterExpression = v => v.Monitored == false || v.Series.Monitored == false;
+ pagingSpec.FilterExpressions.Add(v => v.Monitored == false || v.Series.Monitored == false);
}
else
{
- pagingSpec.FilterExpression = v => v.Monitored == true && v.Series.Monitored == true;
+ pagingSpec.FilterExpressions.Add(v => v.Monitored == true && v.Series.Monitored == true);
}
var resource = ApplyToPage(_episodeService.EpisodesWithoutFiles, pagingSpec, v => MapToResource(v, true, false));
diff --git a/src/NzbDrone.Common.Test/DiskTests/DirectoryLookupServiceFixture.cs b/src/NzbDrone.Common.Test/DiskTests/DirectoryLookupServiceFixture.cs
index 804666ea1..70b68ca0a 100644
--- a/src/NzbDrone.Common.Test/DiskTests/DirectoryLookupServiceFixture.cs
+++ b/src/NzbDrone.Common.Test/DiskTests/DirectoryLookupServiceFixture.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using FluentAssertions;
@@ -49,7 +49,7 @@ namespace NzbDrone.Common.Test.DiskTests
.Setup(s => s.GetDirectoryInfos(It.IsAny()))
.Returns(_folders);
- Subject.LookupContents(root, false).Directories.Should().NotContain(Path.Combine(root, RECYCLING_BIN));
+ Subject.LookupContents(root, false, false).Directories.Should().NotContain(Path.Combine(root, RECYCLING_BIN));
}
[Test]
@@ -62,7 +62,7 @@ namespace NzbDrone.Common.Test.DiskTests
.Setup(s => s.GetDirectoryInfos(It.IsAny()))
.Returns(_folders);
- Subject.LookupContents(root, false).Directories.Should().NotContain(Path.Combine(root, SYSTEM_VOLUME_INFORMATION));
+ Subject.LookupContents(root, false, false).Directories.Should().NotContain(Path.Combine(root, SYSTEM_VOLUME_INFORMATION));
}
[Test]
@@ -75,7 +75,7 @@ namespace NzbDrone.Common.Test.DiskTests
.Setup(s => s.GetDirectoryInfos(It.IsAny()))
.Returns(_folders);
- var result = Subject.LookupContents(root, false);
+ var result = Subject.LookupContents(root, false, false);
result.Directories.Should().HaveCount(_folders.Count - 3);
diff --git a/src/NzbDrone.Common.Test/EnvironmentInfo/BuildInfoFixture.cs b/src/NzbDrone.Common.Test/EnvironmentInfo/BuildInfoFixture.cs
index dca0b292e..40d2012a7 100644
--- a/src/NzbDrone.Common.Test/EnvironmentInfo/BuildInfoFixture.cs
+++ b/src/NzbDrone.Common.Test/EnvironmentInfo/BuildInfoFixture.cs
@@ -1,4 +1,4 @@
-using FluentAssertions;
+using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.EnvironmentInfo;
@@ -10,7 +10,7 @@ namespace NzbDrone.Common.Test.EnvironmentInfo
[Test]
public void should_return_version()
{
- BuildInfo.Version.Major.Should().BeOneOf(2, 10);
+ BuildInfo.Version.Major.Should().BeOneOf(3, 10);
}
[Test]
@@ -20,4 +20,4 @@ namespace NzbDrone.Common.Test.EnvironmentInfo
BuildInfo.Branch.Should().NotBeNullOrWhiteSpace();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Common/Disk/FileSystemLookupService.cs b/src/NzbDrone.Common/Disk/FileSystemLookupService.cs
index b262c9918..a3aa8810d 100644
--- a/src/NzbDrone.Common/Disk/FileSystemLookupService.cs
+++ b/src/NzbDrone.Common/Disk/FileSystemLookupService.cs
@@ -1,8 +1,7 @@
-using System;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using NLog;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions;
@@ -10,13 +9,13 @@ namespace NzbDrone.Common.Disk
{
public interface IFileSystemLookupService
{
- FileSystemResult LookupContents(string query, bool includeFiles);
+ FileSystemResult LookupContents(string query, bool includeFiles, bool allowFoldersWithoutTrailingSlashes);
}
public class FileSystemLookupService : IFileSystemLookupService
{
private readonly IDiskProvider _diskProvider;
- private readonly Logger _logger;
+ private readonly IRuntimeInfo _runtimeInfo;
private readonly HashSet _setToRemove = new HashSet
{
@@ -48,20 +47,19 @@ namespace NzbDrone.Common.Disk
"@eadir"
};
- public FileSystemLookupService(IDiskProvider diskProvider, Logger logger)
+ public FileSystemLookupService(IDiskProvider diskProvider, IRuntimeInfo runtimeInfo)
{
_diskProvider = diskProvider;
- _logger = logger;
+ _runtimeInfo = runtimeInfo;
}
- public FileSystemResult LookupContents(string query, bool includeFiles)
+ public FileSystemResult LookupContents(string query, bool includeFiles, bool allowFoldersWithoutTrailingSlashes)
{
- var result = new FileSystemResult();
-
if (query.IsNullOrWhiteSpace())
{
if (OsInfo.IsWindows)
{
+ var result = new FileSystemResult();
result.Directories = GetDrives();
return result;
@@ -70,67 +68,94 @@ namespace NzbDrone.Common.Disk
query = "/";
}
+ if (
+ allowFoldersWithoutTrailingSlashes &&
+ query.IsPathValid() &&
+ _diskProvider.FolderExists(query))
+ {
+ return GetResult(query, includeFiles);
+ }
+
var lastSeparatorIndex = query.LastIndexOf(Path.DirectorySeparatorChar);
var path = query.Substring(0, lastSeparatorIndex + 1);
if (lastSeparatorIndex != -1)
{
- try
- {
- result.Parent = GetParent(path);
- result.Directories = GetDirectories(path);
-
- if (includeFiles)
- {
- result.Files = GetFiles(path);
- }
- }
-
- catch (DirectoryNotFoundException)
- {
- return new FileSystemResult { Parent = GetParent(path) };
- }
- catch (ArgumentException)
- {
- return new FileSystemResult();
- }
- catch (IOException)
- {
- return new FileSystemResult { Parent = GetParent(path) };
- }
- catch (UnauthorizedAccessException)
- {
- return new FileSystemResult { Parent = GetParent(path) };
- }
+ return GetResult(path, includeFiles);
}
- return result;
+ return new FileSystemResult();
}
private List GetDrives()
{
return _diskProvider.GetMounts()
+ .Where(d =>
+ {
+ // Fow Windows Services, exclude mapped network drives.
+ if (_runtimeInfo.IsWindowsService)
+ {
+ return d.DriveType != DriveType.Network;
+ }
+
+ return true;
+ })
.Select(d => new FileSystemModel
- {
- Type = FileSystemEntityType.Drive,
- Name = d.VolumeName,
- Path = d.RootDirectory,
- LastModified = null
- })
+ {
+ Type = FileSystemEntityType.Drive,
+ Name = GetVolumeName(d),
+ Path = d.RootDirectory,
+ LastModified = null
+ })
.ToList();
}
+ private FileSystemResult GetResult(string path, bool includeFiles)
+ {
+ var result = new FileSystemResult();
+
+ try
+ {
+ result.Parent = GetParent(path);
+ result.Directories = GetDirectories(path);
+
+ if (includeFiles)
+ {
+ result.Files = GetFiles(path);
+ }
+ }
+
+ catch (DirectoryNotFoundException)
+ {
+ return new FileSystemResult { Parent = GetParent(path) };
+ }
+ catch (ArgumentException)
+ {
+ return new FileSystemResult();
+ }
+ catch (IOException)
+ {
+ return new FileSystemResult { Parent = GetParent(path) };
+ }
+ catch (UnauthorizedAccessException)
+ {
+ return new FileSystemResult { Parent = GetParent(path) };
+ }
+
+ return result;
+ }
+
private List GetDirectories(string path)
{
var directories = _diskProvider.GetDirectoryInfos(path)
.OrderBy(d => d.Name)
.Select(d => new FileSystemModel
- {
- Name = d.Name,
- Path = GetDirectoryPath(d.FullName.GetActualCasing()),
- LastModified = d.LastWriteTimeUtc,
- Type = FileSystemEntityType.Folder
- })
+ {
+ Name = d.Name,
+ Path = GetDirectoryPath(d.FullName.GetActualCasing()),
+ LastModified = d.LastWriteTimeUtc,
+ Type = FileSystemEntityType.Folder
+ })
.ToList();
directories.RemoveAll(d => _setToRemove.Contains(d.Name.ToLowerInvariant()));
@@ -143,18 +168,28 @@ namespace NzbDrone.Common.Disk
return _diskProvider.GetFileInfos(path)
.OrderBy(d => d.Name)
.Select(d => new FileSystemModel
- {
- Name = d.Name,
- Path = d.FullName.GetActualCasing(),
- LastModified = d.LastWriteTimeUtc,
- Extension = d.Extension,
- Size = d.Length,
- Type = FileSystemEntityType.File
- })
+ {
+ Name = d.Name,
+ Path = d.FullName.GetActualCasing(),
+ LastModified = d.LastWriteTimeUtc,
+ Extension = d.Extension,
+ Size = d.Length,
+ Type = FileSystemEntityType.File
+ })
.ToList();
}
- private string GetDirectoryPath(string path)
+ private static string GetVolumeName(IMount mountInfo)
+ {
+ if (mountInfo.VolumeLabel.IsNullOrWhiteSpace())
+ {
+ return mountInfo.Name;
+ }
+
+ return $"{mountInfo.Name} ({mountInfo.VolumeLabel})";
+ }
+
+ private static string GetDirectoryPath(string path)
{
if (path.Last() != Path.DirectorySeparatorChar)
{
@@ -164,7 +199,7 @@ namespace NzbDrone.Common.Disk
return path;
}
- private string GetParent(string path)
+ private static string GetParent(string path)
{
var di = new DirectoryInfo(path);
diff --git a/src/NzbDrone.Common/EnvironmentInfo/IRuntimeInfo.cs b/src/NzbDrone.Common/EnvironmentInfo/IRuntimeInfo.cs
index d387001ef..a8e4bd9ad 100644
--- a/src/NzbDrone.Common/EnvironmentInfo/IRuntimeInfo.cs
+++ b/src/NzbDrone.Common/EnvironmentInfo/IRuntimeInfo.cs
@@ -1,12 +1,17 @@
+using System;
+
namespace NzbDrone.Common.EnvironmentInfo
{
public interface IRuntimeInfo
{
+ DateTime StartTime { get; }
bool IsUserInteractive { get; }
bool IsAdmin { get; }
bool IsWindowsService { get; }
bool IsWindowsTray { get; }
bool IsExiting { get; set; }
+ bool IsTray { get; }
+ RuntimeMode Mode { get; }
bool RestartPending { get; set; }
string ExecutingApplication { get; }
}
diff --git a/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs b/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs
index 3337b99b8..753bd91e6 100644
--- a/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs
+++ b/src/NzbDrone.Common/EnvironmentInfo/RuntimeInfo.cs
@@ -12,6 +12,7 @@ namespace NzbDrone.Common.EnvironmentInfo
public class RuntimeInfo : IRuntimeInfo
{
private readonly Logger _logger;
+ private readonly DateTime _startTime = DateTime.UtcNow;
public RuntimeInfo(IServiceProvider serviceProvider, Logger logger)
{
@@ -37,6 +38,14 @@ namespace NzbDrone.Common.EnvironmentInfo
IsProduction = InternalIsProduction();
}
+ public DateTime StartTime
+ {
+ get
+ {
+ return _startTime;
+ }
+ }
+
public static bool IsUserInteractive => Environment.UserInteractive;
bool IRuntimeInfo.IsUserInteractive => IsUserInteractive;
@@ -61,6 +70,37 @@ namespace NzbDrone.Common.EnvironmentInfo
public bool IsWindowsService { get; private set; }
public bool IsExiting { get; set; }
+ public bool IsTray
+ {
+ get
+ {
+ if (OsInfo.IsWindows)
+ {
+ return IsUserInteractive && Process.GetCurrentProcess().ProcessName.Equals(ProcessProvider.NZB_DRONE_PROCESS_NAME, StringComparison.InvariantCultureIgnoreCase);
+ }
+
+ return false;
+ }
+ }
+
+ public RuntimeMode Mode
+ {
+ get
+ {
+ if (IsWindowsService)
+ {
+ return RuntimeMode.Service;
+ }
+
+ if (IsTray)
+ {
+ return RuntimeMode.Tray;
+ }
+
+ return RuntimeMode.Console;
+ }
+ }
+
public bool RestartPending { get; set; }
public string ExecutingApplication { get; }
diff --git a/src/NzbDrone.Common/EnvironmentInfo/RuntimeMode.cs b/src/NzbDrone.Common/EnvironmentInfo/RuntimeMode.cs
new file mode 100644
index 000000000..ad4c0a786
--- /dev/null
+++ b/src/NzbDrone.Common/EnvironmentInfo/RuntimeMode.cs
@@ -0,0 +1,9 @@
+namespace NzbDrone.Common.EnvironmentInfo
+{
+ public enum RuntimeMode
+ {
+ Console,
+ Service,
+ Tray
+ }
+}
diff --git a/src/NzbDrone.Common/Extensions/IEnumerableExtensions.cs b/src/NzbDrone.Common/Extensions/IEnumerableExtensions.cs
index 2eeb2fe4e..afa00d3a5 100644
--- a/src/NzbDrone.Common/Extensions/IEnumerableExtensions.cs
+++ b/src/NzbDrone.Common/Extensions/IEnumerableExtensions.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Linq.Expressions;
namespace NzbDrone.Common.Extensions
{
@@ -108,5 +109,13 @@ namespace NzbDrone.Common.Extensions
{
return source.Select(predicate).ToList();
}
+
+// public static IOrderedEnumerable OrderBy(this IEnumerable source, string propertyName, bool descending)
+// {
+// var property = typeof(TEntity).GetProperty(propertyName);
+// Func orderByFunc = x => property.GetValue(x, null);
+//
+// return descending ? source.OrderByDescending(orderByFunc) : source.OrderBy(orderByFunc);
+// }
}
}
diff --git a/src/NzbDrone.Common/NzbDrone.Common.csproj b/src/NzbDrone.Common/NzbDrone.Common.csproj
index cf854bdb6..4e16b072c 100644
--- a/src/NzbDrone.Common/NzbDrone.Common.csproj
+++ b/src/NzbDrone.Common/NzbDrone.Common.csproj
@@ -97,6 +97,7 @@
+
diff --git a/src/NzbDrone.Common/Serializer/Json.cs b/src/NzbDrone.Common/Serializer/Json.cs
index 5f8cbfd8d..4a0565a4d 100644
--- a/src/NzbDrone.Common/Serializer/Json.cs
+++ b/src/NzbDrone.Common/Serializer/Json.cs
@@ -10,11 +10,17 @@ namespace NzbDrone.Common.Serializer
public static class Json
{
private static readonly JsonSerializer Serializer;
- private static readonly JsonSerializerSettings SerializerSetting;
+ private static readonly JsonSerializerSettings SerializerSettings;
static Json()
{
- SerializerSetting = new JsonSerializerSettings
+ SerializerSettings = GetSerializerSettings();
+ Serializer = JsonSerializer.Create(SerializerSettings);
+ }
+
+ public static JsonSerializerSettings GetSerializerSettings()
+ {
+ var serializerSettings = new JsonSerializerSettings
{
DateTimeZoneHandling = DateTimeZoneHandling.Utc,
NullValueHandling = NullValueHandling.Ignore,
@@ -23,14 +29,11 @@ namespace NzbDrone.Common.Serializer
ContractResolver = new CamelCasePropertyNamesContractResolver()
};
+ serializerSettings.Converters.Add(new StringEnumConverter { CamelCaseText = true });
+ serializerSettings.Converters.Add(new VersionConverter());
+ serializerSettings.Converters.Add(new HttpUriConverter());
- SerializerSetting.Converters.Add(new StringEnumConverter { CamelCaseText = true });
- //SerializerSetting.Converters.Add(new IntConverter());
- SerializerSetting.Converters.Add(new VersionConverter());
- SerializerSetting.Converters.Add(new HttpUriConverter());
-
- Serializer = JsonSerializer.Create(SerializerSetting);
-
+ return serializerSettings;
}
public static T Deserialize(string json) where T : new()
@@ -113,7 +116,7 @@ namespace NzbDrone.Common.Serializer
public static string ToJson(this object obj)
{
- return JsonConvert.SerializeObject(obj, SerializerSetting);
+ return JsonConvert.SerializeObject(obj, SerializerSettings);
}
public static void Serialize(TModel model, TextWriter outputStream)
diff --git a/src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingProxyFixture.cs b/src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingProxyFixture.cs
index ce59cf37c..699b6d5ab 100644
--- a/src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingProxyFixture.cs
+++ b/src/NzbDrone.Core.Test/DataAugmentation/Scene/SceneMappingProxyFixture.cs
@@ -1,3 +1,4 @@
+using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.Extensions;
diff --git a/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs b/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs
index 660a58d6f..d57c01893 100644
--- a/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs
+++ b/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs
@@ -1,4 +1,5 @@
-using System.IO;
+using System.Collections.Generic;
+using System.IO;
using System.Linq;
using FizzWare.NBuilder;
using Moq;
diff --git a/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs
index ee77f0df0..fa14ed95b 100644
--- a/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs
+++ b/src/NzbDrone.Core.Test/MediaFiles/DiskScanServiceTests/ScanFixture.cs
@@ -8,6 +8,7 @@ using NzbDrone.Common.Disk;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.EpisodeImport;
+using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Test.Common;
@@ -39,6 +40,10 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
Mocker.GetMock()
.Setup(s => s.GetParentFolder(It.IsAny()))
.Returns((string path) => Directory.GetParent(path).FullName);
+
+ Mocker.GetMock()
+ .Setup(s => s.GetBestRootFolderPath(It.IsAny()))
+ .Returns(_rootFolder);
}
private void GivenRootFolder(params string[] subfolders)
diff --git a/src/NzbDrone.Core.Test/MediaFiles/DownloadedEpisodesImportServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/DownloadedEpisodesImportServiceFixture.cs
index 2acbe077b..a81bc9215 100644
--- a/src/NzbDrone.Core.Test/MediaFiles/DownloadedEpisodesImportServiceFixture.cs
+++ b/src/NzbDrone.Core.Test/MediaFiles/DownloadedEpisodesImportServiceFixture.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using FizzWare.NBuilder;
@@ -80,7 +80,7 @@ namespace NzbDrone.Core.Test.MediaFiles
imported.Add(new ImportDecision(localEpisode));
Mocker.GetMock()
- .Setup(s => s.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), null, true))
+ .Setup(s => s.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), null, true, true))
.Returns(imported);
Mocker.GetMock()
@@ -124,7 +124,7 @@ namespace NzbDrone.Core.Test.MediaFiles
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
Mocker.GetMock()
- .Verify(c => c.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()),
+ .Verify(c => c.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), true),
Times.Never());
VerifyNoImport();
@@ -175,7 +175,7 @@ namespace NzbDrone.Core.Test.MediaFiles
imported.Add(new ImportDecision(localEpisode));
Mocker.GetMock()
- .Setup(s => s.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), null, true))
+ .Setup(s => s.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), null, true, true))
.Returns(imported);
Mocker.GetMock()
@@ -201,7 +201,7 @@ namespace NzbDrone.Core.Test.MediaFiles
imported.Add(new ImportDecision(localEpisode));
Mocker.GetMock()
- .Setup(s => s.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), null, true))
+ .Setup(s => s.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), null, true, true))
.Returns(imported);
Mocker.GetMock()
@@ -271,7 +271,7 @@ namespace NzbDrone.Core.Test.MediaFiles
imported.Add(new ImportDecision(localEpisode));
Mocker.GetMock()
- .Setup(s => s.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), null, true))
+ .Setup(s => s.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), null, true, true))
.Returns(imported);
Mocker.GetMock()
@@ -380,7 +380,7 @@ namespace NzbDrone.Core.Test.MediaFiles
imported.Add(new ImportDecision(localEpisode));
Mocker.GetMock()
- .Setup(s => s.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), null, true))
+ .Setup(s => s.GetImportDecisions(It.IsAny>(), It.IsAny(), It.IsAny(), null, true, true))
.Returns(imported);
Mocker.GetMock()
diff --git a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/ImportDecisionMakerFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/ImportDecisionMakerFixture.cs
index 719682080..ac9d8d97b 100644
--- a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/ImportDecisionMakerFixture.cs
+++ b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/ImportDecisionMakerFixture.cs
@@ -102,7 +102,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
GivenAugmentationSuccess();
GivenSpecifications(_pass1, _pass2, _pass3, _fail1, _fail2, _fail3);
- Subject.GetImportDecisions(_videoFiles, _series, downloadClientItem, null, false);
+ Subject.GetImportDecisions(_videoFiles, _series, downloadClientItem, null, false, true);
_fail1.Verify(c => c.IsSatisfiedBy(It.IsAny(), downloadClientItem), Times.Once());
_fail2.Verify(c => c.IsSatisfiedBy(It.IsAny(), downloadClientItem), Times.Once());
diff --git a/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedEpisodesFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedEpisodesFixture.cs
index 3c510140c..2ecb0b1f9 100644
--- a/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedEpisodesFixture.cs
+++ b/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedEpisodesFixture.cs
@@ -317,5 +317,16 @@ namespace NzbDrone.Core.Test.MediaFiles
Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.OriginalFilePath == $"{name}\\subfolder\\{name}.mkv".AsOsAgnostic())));
}
+ public void should_delete_existing_metadata_files_with_the_same_path()
+ {
+ Mocker.GetMock()
+ .Setup(s => s.GetFilesWithRelativePath(It.IsAny(), It.IsAny()))
+ .Returns(Builder.CreateListOfSize(1).BuildList());
+
+ Subject.Import(new List { _approvedDecisions.First() }, false);
+
+ Mocker.GetMock()
+ .Verify(v => v.Delete(It.IsAny(), DeleteMediaFileReason.ManualOverride), Times.Once());
+ }
}
}
diff --git a/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs b/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs
index 4dd7560ac..1134911d2 100644
--- a/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs
+++ b/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs
@@ -1,7 +1,9 @@
using FluentAssertions;
+using Moq;
using NUnit.Framework;
using NzbDrone.Core.MetadataSource.SkyHook;
using NzbDrone.Core.Test.Framework;
+using NzbDrone.Core.Tv;
using NzbDrone.Test.Common;
using NzbDrone.Test.Common.Categories;
@@ -52,5 +54,24 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook
ExceptionVerification.IgnoreWarns();
}
+
+ [TestCase("tvdbid:78804")]
+ [TestCase("Doctor Who")]
+ public void should_return_existing_series_if_found(string term)
+ {
+ const int tvdbId = 78804;
+ var existingSeries = new Series
+ {
+ TvdbId = tvdbId
+ };
+
+ Mocker.GetMock().Setup(c => c.FindByTvdbId(tvdbId)).Returns(existingSeries);
+
+ var result = Subject.SearchForNewSeries("tvdbid: " + tvdbId);
+
+ result.Should().Contain(existingSeries);
+ result.Should().ContainSingle(c => c.TvdbId == tvdbId);
+
+ }
}
}
diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
index 401a909da..4f23ec461 100644
--- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
+++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
@@ -340,6 +340,7 @@
+
@@ -407,6 +408,7 @@
+
@@ -420,6 +422,7 @@
+
diff --git a/src/NzbDrone.Core.Test/Profiles/Delay/DelayProfileServiceFixture.cs b/src/NzbDrone.Core.Test/Profiles/Delay/DelayProfileServiceFixture.cs
new file mode 100644
index 000000000..ff2df10f4
--- /dev/null
+++ b/src/NzbDrone.Core.Test/Profiles/Delay/DelayProfileServiceFixture.cs
@@ -0,0 +1,112 @@
+using System.Collections.Generic;
+using System.Linq;
+using FizzWare.NBuilder;
+using FluentAssertions;
+using NUnit.Framework;
+using NzbDrone.Core.Profiles.Delay;
+using NzbDrone.Core.Test.Framework;
+
+namespace NzbDrone.Core.Test.Profiles.Delay
+{
+ [TestFixture]
+ public class DelayProfileServiceFixture : CoreTest
+ {
+ private List _delayProfiles;
+ private DelayProfile _first;
+ private DelayProfile _last;
+
+ [SetUp]
+ public void Setup()
+ {
+ _delayProfiles = Builder.CreateListOfSize(4)
+ .TheFirst(1)
+ .With(d => d.Order = int.MaxValue)
+ .TheNext(1)
+ .With(d => d.Order = 1)
+ .TheNext(1)
+ .With(d => d.Order = 2)
+ .TheNext(1)
+ .With(d => d.Order = 3)
+ .Build()
+ .ToList();
+
+ _first = _delayProfiles[1];
+ _last = _delayProfiles.Last();
+
+ Mocker.GetMock()
+ .Setup(s => s.All())
+ .Returns(_delayProfiles);
+ }
+
+ [Test]
+ public void should_move_to_first_if_afterId_is_null()
+ {
+ var moving = _last;
+ var result = Subject.Reorder(moving.Id, null).OrderBy(d => d.Order).ToList();
+ var moved = result.First();
+
+ moved.Id.Should().Be(moving.Id);
+ moved.Order.Should().Be(1);
+ }
+
+ [Test]
+ public void should_move_after_if_afterId_is_not_null()
+ {
+ var after = _first;
+ var moving = _last;
+ var result = Subject.Reorder(moving.Id, _first.Id).OrderBy(d => d.Order).ToList();
+ var moved = result[1];
+
+ moved.Id.Should().Be(moving.Id);
+ moved.Order.Should().Be(after.Order + 1);
+ }
+
+ [Test]
+ public void should_reorder_delay_profiles_that_are_after_moved()
+ {
+ var moving = _last;
+ var result = Subject.Reorder(moving.Id, null).OrderBy(d => d.Order).ToList();
+
+ for (int i = 1; i < result.Count; i++)
+ {
+ var delayProfile = result[i];
+
+ if (delayProfile.Id == 1)
+ {
+ delayProfile.Order.Should().Be(int.MaxValue);
+ }
+
+ else
+ {
+ delayProfile.Order.Should().Be(i + 1);
+ }
+ }
+ }
+
+ [Test]
+ public void should_not_change_afters_order_if_moving_was_after()
+ {
+ var after = _first;
+ var afterOrder = after.Order;
+ var moving = _last;
+ var result = Subject.Reorder(moving.Id, _first.Id).OrderBy(d => d.Order).ToList();
+ var afterMove = result.First();
+
+ afterMove.Id.Should().Be(after.Id);
+ afterMove.Order.Should().Be(afterOrder);
+ }
+
+ [Test]
+ public void should_change_afters_order_if_moving_was_before()
+ {
+ var after = _last;
+ var afterOrder = after.Order;
+ var moving = _first;
+
+ var result = Subject.Reorder(moving.Id, after.Id).OrderBy(d => d.Order).ToList();
+ var afterMove = result.Single(d => d.Id == after.Id);
+
+ afterMove.Order.Should().BeLessThan(afterOrder);
+ }
+ }
+}
diff --git a/src/NzbDrone.Core.Test/Profiles/ProfileServiceFixture.cs b/src/NzbDrone.Core.Test/Profiles/ProfileServiceFixture.cs
index e621801e8..737ddfd05 100644
--- a/src/NzbDrone.Core.Test/Profiles/ProfileServiceFixture.cs
+++ b/src/NzbDrone.Core.Test/Profiles/ProfileServiceFixture.cs
@@ -10,7 +10,6 @@ using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Test.Profiles
{
[TestFixture]
-
public class ProfileServiceFixture : CoreTest
{
[Test]
diff --git a/src/NzbDrone.Core.Test/TvTests/EpisodeMonitoredServiceTests/LegacySetEpisodeMontitoredFixture.cs b/src/NzbDrone.Core.Test/TvTests/EpisodeMonitoredServiceTests/LegacySetEpisodeMontitoredFixture.cs
new file mode 100644
index 000000000..963c45d5b
--- /dev/null
+++ b/src/NzbDrone.Core.Test/TvTests/EpisodeMonitoredServiceTests/LegacySetEpisodeMontitoredFixture.cs
@@ -0,0 +1,261 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using FizzWare.NBuilder;
+using Moq;
+using NUnit.Framework;
+using NzbDrone.Common.Extensions;
+using NzbDrone.Core.Test.Framework;
+using NzbDrone.Core.Tv;
+
+namespace NzbDrone.Core.Test.TvTests.EpisodeMonitoredServiceTests
+{
+ [TestFixture]
+ public class LegacySetEpisodeMontitoredFixture : CoreTest
+ {
+ private Series _series;
+ private List _episodes;
+
+ [SetUp]
+ public void Setup()
+ {
+ var seasons = 4;
+
+ _series = Builder.CreateNew()
+ .With(s => s.Seasons = Builder.CreateListOfSize(seasons)
+ .All()
+ .With(n => n.Monitored = true)
+ .Build()
+ .ToList())
+ .Build();
+
+ _episodes = Builder.CreateListOfSize(seasons)
+ .All()
+ .With(e => e.Monitored = true)
+ .With(e => e.AirDateUtc = DateTime.UtcNow.AddDays(-7))
+ //Missing
+ .TheFirst(1)
+ .With(e => e.EpisodeFileId = 0)
+ //Has File
+ .TheNext(1)
+ .With(e => e.EpisodeFileId = 1)
+ //Future
+ .TheNext(1)
+ .With(e => e.EpisodeFileId = 0)
+ .With(e => e.AirDateUtc = DateTime.UtcNow.AddDays(7))
+ //Future/TBA
+ .TheNext(1)
+ .With(e => e.EpisodeFileId = 0)
+ .With(e => e.AirDateUtc = null)
+ .Build()
+ .ToList();
+
+ Mocker.GetMock()
+ .Setup(s => s.GetEpisodeBySeries(It.IsAny()))
+ .Returns(_episodes);
+ }
+
+ private void GivenSpecials()
+ {
+ foreach (var episode in _episodes)
+ {
+ episode.SeasonNumber = 0;
+ }
+
+ _series.Seasons = new List{new Season { Monitored = false, SeasonNumber = 0 }};
+ }
+
+ [Test]
+ public void should_be_able_to_monitor_series_without_changing_episodes()
+ {
+ Subject.SetEpisodeMonitoredStatus(_series, null);
+
+ Mocker.GetMock()
+ .Verify(v => v.UpdateSeries(It.IsAny(), It.IsAny()), Times.Once());
+
+ Mocker.GetMock()
+ .Verify(v => v.UpdateEpisodes(It.IsAny>()), Times.Never());
+ }
+
+ [Test]
+ public void should_be_able_to_monitor_all_episodes()
+ {
+ Subject.SetEpisodeMonitoredStatus(_series, new MonitoringOptions());
+
+ Mocker.GetMock()
+ .Verify(v => v.UpdateEpisodes(It.Is>(l => l.All(e => e.Monitored))));
+ }
+
+ [Test]
+ public void should_be_able_to_monitor_missing_episodes_only()
+ {
+ var monitoringOptions = new MonitoringOptions
+ {
+ IgnoreEpisodesWithFiles = true,
+ IgnoreEpisodesWithoutFiles = false
+ };
+
+ Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions);
+
+ VerifyMonitored(e => !e.HasFile);
+ VerifyNotMonitored(e => e.HasFile);
+ }
+
+ [Test]
+ public void should_be_able_to_monitor_new_episodes_only()
+ {
+ var monitoringOptions = new MonitoringOptions
+ {
+ IgnoreEpisodesWithFiles = true,
+ IgnoreEpisodesWithoutFiles = true
+ };
+
+ Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions);
+
+ VerifyMonitored(e => e.AirDateUtc.HasValue && e.AirDateUtc.Value.After(DateTime.UtcNow));
+ VerifyMonitored(e => !e.AirDateUtc.HasValue);
+ VerifyNotMonitored(e => e.AirDateUtc.HasValue && e.AirDateUtc.Value.Before(DateTime.UtcNow));
+ }
+
+ [Test]
+ public void should_not_monitor_missing_specials()
+ {
+ GivenSpecials();
+
+ var monitoringOptions = new MonitoringOptions
+ {
+ IgnoreEpisodesWithFiles = true,
+ IgnoreEpisodesWithoutFiles = false
+ };
+
+ Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions);
+
+ VerifyNotMonitored(e => e.SeasonNumber == 0);
+ }
+
+ [Test]
+ public void should_not_monitor_new_specials()
+ {
+ GivenSpecials();
+
+ var monitoringOptions = new MonitoringOptions
+ {
+ IgnoreEpisodesWithFiles = true,
+ IgnoreEpisodesWithoutFiles = true
+ };
+
+ Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions);
+
+ VerifyNotMonitored(e => e.SeasonNumber == 0);
+ }
+
+ [Test]
+ public void should_not_monitor_season_when_all_episodes_are_monitored_except_latest_season()
+ {
+ _series.Seasons = Builder.CreateListOfSize(2)
+ .All()
+ .With(n => n.Monitored = true)
+ .Build()
+ .ToList();
+
+ _episodes = Builder.CreateListOfSize(5)
+ .All()
+ .With(e => e.SeasonNumber = 1)
+ .With(e => e.EpisodeFileId = 0)
+ .With(e => e.AirDateUtc = DateTime.UtcNow.AddDays(-5))
+ .TheLast(1)
+ .With(e => e.SeasonNumber = 2)
+ .Build()
+ .ToList();
+
+ Mocker.GetMock()
+ .Setup(s => s.GetEpisodeBySeries(It.IsAny()))
+ .Returns(_episodes);
+
+ var monitoringOptions = new MonitoringOptions
+ {
+ IgnoreEpisodesWithoutFiles = true
+ };
+
+ Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions);
+
+ VerifySeasonMonitored(n => n.SeasonNumber == 2);
+ VerifySeasonNotMonitored(n => n.SeasonNumber == 1);
+ }
+
+ [Test]
+ public void should_ignore_episodes_when_season_is_not_monitored()
+ {
+ _series.Seasons.ForEach(s => s.Monitored = false);
+
+ Subject.SetEpisodeMonitoredStatus(_series, new MonitoringOptions());
+
+ Mocker.GetMock()
+ .Verify(v => v.UpdateEpisodes(It.Is>(l => l.All(e => !e.Monitored))));
+ }
+
+ [Test]
+ public void should_should_not_monitor_episodes_if_season_is_not_monitored()
+ {
+ _series = Builder.CreateNew()
+ .With(s => s.Seasons = Builder.CreateListOfSize(2)
+ .TheFirst(1)
+ .With(n => n.Monitored = true)
+ .TheLast(1)
+ .With(n => n.Monitored = false)
+ .Build()
+ .ToList())
+ .Build();
+
+ var episodes = Builder.CreateListOfSize(10)
+ .All()
+ .With(e => e.Monitored = true)
+ .With(e => e.EpisodeFileId = 0)
+ .With(e => e.AirDateUtc = DateTime.UtcNow.AddDays(-7))
+ .TheFirst(5)
+ .With(e => e.SeasonNumber = 1)
+ .TheLast(5)
+ .With(e => e.SeasonNumber = 2)
+ .BuildList();
+
+ Mocker.GetMock()
+ .Setup(s => s.GetEpisodeBySeries(It.IsAny()))
+ .Returns(episodes);
+
+ Subject.SetEpisodeMonitoredStatus(_series, new MonitoringOptions
+ {
+ IgnoreEpisodesWithFiles = true,
+ IgnoreEpisodesWithoutFiles = false
+ });
+
+ VerifyMonitored(e => e.SeasonNumber == 1);
+ VerifyNotMonitored(e => e.SeasonNumber == 2);
+ VerifySeasonMonitored(s => s.SeasonNumber == 1);
+ VerifySeasonNotMonitored(s => s.SeasonNumber == 2);
+ }
+
+ private void VerifyMonitored(Func predicate)
+ {
+ Mocker.GetMock()
+ .Verify(v => v.UpdateEpisodes(It.Is>(l => l.Where(predicate).All(e => e.Monitored))));
+ }
+
+ private void VerifyNotMonitored(Func predicate)
+ {
+ Mocker.GetMock()
+ .Verify(v => v.UpdateEpisodes(It.Is>(l => l.Where(predicate).All(e => !e.Monitored))));
+ }
+
+ private void VerifySeasonMonitored(Func predicate)
+ {
+ Mocker.GetMock()
+ .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Where(predicate).All(n => n.Monitored)), It.IsAny()));
+ }
+
+ private void VerifySeasonNotMonitored(Func predicate)
+ {
+ Mocker.GetMock()
+ .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Where(predicate).All(n => !n.Monitored)), It.IsAny()));
+ }
+ }
+}
diff --git a/src/NzbDrone.Core.Test/TvTests/EpisodeMonitoredServiceTests/SetEpisodeMontitoredFixture.cs b/src/NzbDrone.Core.Test/TvTests/EpisodeMonitoredServiceTests/SetEpisodeMontitoredFixture.cs
index 70108d1be..120661418 100644
--- a/src/NzbDrone.Core.Test/TvTests/EpisodeMonitoredServiceTests/SetEpisodeMontitoredFixture.cs
+++ b/src/NzbDrone.Core.Test/TvTests/EpisodeMonitoredServiceTests/SetEpisodeMontitoredFixture.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
@@ -91,8 +91,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeMonitoredServiceTests
{
var monitoringOptions = new MonitoringOptions
{
- IgnoreEpisodesWithFiles = true,
- IgnoreEpisodesWithoutFiles = false
+ Monitor = MonitorTypes.Missing
};
Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions);
@@ -106,8 +105,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeMonitoredServiceTests
{
var monitoringOptions = new MonitoringOptions
{
- IgnoreEpisodesWithFiles = true,
- IgnoreEpisodesWithoutFiles = true
+ Monitor = MonitorTypes.Future
};
Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions);
@@ -124,8 +122,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeMonitoredServiceTests
var monitoringOptions = new MonitoringOptions
{
- IgnoreEpisodesWithFiles = true,
- IgnoreEpisodesWithoutFiles = false
+ Monitor = MonitorTypes.Missing
};
Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions);
@@ -140,8 +137,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeMonitoredServiceTests
var monitoringOptions = new MonitoringOptions
{
- IgnoreEpisodesWithFiles = true,
- IgnoreEpisodesWithoutFiles = true
+ Monitor = MonitorTypes.Future
};
Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions);
@@ -174,7 +170,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeMonitoredServiceTests
var monitoringOptions = new MonitoringOptions
{
- IgnoreEpisodesWithoutFiles = true
+ Monitor = MonitorTypes.LatestSeason
};
Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions);
@@ -184,54 +180,31 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeMonitoredServiceTests
}
[Test]
- public void should_ignore_episodes_when_season_is_not_monitored()
+ public void should_be_able_to_monitor_no_episodes()
{
- _series.Seasons.ForEach(s => s.Monitored = false);
+ var monitoringOptions = new MonitoringOptions
+ {
+ Monitor = MonitorTypes.None
+ };
- Subject.SetEpisodeMonitoredStatus(_series, new MonitoringOptions());
+ Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions);
Mocker.GetMock()
.Verify(v => v.UpdateEpisodes(It.Is>(l => l.All(e => !e.Monitored))));
}
[Test]
- public void should_should_not_monitor_episodes_if_season_is_not_monitored()
+ public void should_monitor_missing_episodes()
{
- _series = Builder.CreateNew()
- .With(s => s.Seasons = Builder.CreateListOfSize(2)
- .TheFirst(1)
- .With(n => n.Monitored = true)
- .TheLast(1)
- .With(n => n.Monitored = false)
- .Build()
- .ToList())
- .Build();
+ var monitoringOptions = new MonitoringOptions
+ {
+ Monitor = MonitorTypes.Missing
+ };
- var episodes = Builder.CreateListOfSize(10)
- .All()
- .With(e => e.Monitored = true)
- .With(e => e.EpisodeFileId = 0)
- .With(e => e.AirDateUtc = DateTime.UtcNow.AddDays(-7))
- .TheFirst(5)
- .With(e => e.SeasonNumber = 1)
- .TheLast(5)
- .With(e => e.SeasonNumber = 2)
- .BuildList();
+ Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions);
- Mocker.GetMock()
- .Setup(s => s.GetEpisodeBySeries(It.IsAny()))
- .Returns(episodes);
-
- Subject.SetEpisodeMonitoredStatus(_series, new MonitoringOptions
- {
- IgnoreEpisodesWithFiles = true,
- IgnoreEpisodesWithoutFiles = false
- });
-
- VerifyMonitored(e => e.SeasonNumber == 1);
- VerifyNotMonitored(e => e.SeasonNumber == 2);
- VerifySeasonMonitored(s => s.SeasonNumber == 1);
- VerifySeasonNotMonitored(s => s.SeasonNumber == 2);
+ VerifyMonitored(e => !e.HasFile);
+ VerifyNotMonitored(e => e.HasFile);
}
private void VerifyMonitored(Func predicate)
diff --git a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWhereCutoffUnmetFixture.cs b/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWhereCutoffUnmetFixture.cs
index 3b8ebeedf..363214a5d 100644
--- a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWhereCutoffUnmetFixture.cs
+++ b/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWhereCutoffUnmetFixture.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
@@ -126,12 +126,12 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests
private void GivenMonitoredFilterExpression()
{
- _pagingSpec.FilterExpression = e => e.Monitored == true && e.Series.Monitored == true;
+ _pagingSpec.FilterExpressions.Add(e => e.Monitored == true && e.Series.Monitored == true);
}
private void GivenUnmonitoredFilterExpression()
{
- _pagingSpec.FilterExpression = e => e.Monitored == false || e.Series.Monitored == false;
+ _pagingSpec.FilterExpressions.Add(e => e.Monitored == false || e.Series.Monitored == false);
}
[Test]
diff --git a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWithoutFilesFixture.cs b/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWithoutFilesFixture.cs
index 4f8f9eb23..c9dece998 100644
--- a/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWithoutFilesFixture.cs
+++ b/src/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWithoutFilesFixture.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
@@ -90,12 +90,12 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests
private void GivenMonitoredFilterExpression()
{
- _pagingSpec.FilterExpression = e => e.Monitored == true && e.Series.Monitored == true;
+ _pagingSpec.FilterExpressions.Add(e => e.Monitored == true && e.Series.Monitored == true);
}
private void GivenUnmonitoredFilterExpression()
{
- _pagingSpec.FilterExpression = e => e.Monitored == false || e.Series.Monitored == false;
+ _pagingSpec.FilterExpressions.Add(e => e.Monitored == false || e.Series.Monitored == false);
}
[Test]
diff --git a/src/NzbDrone.Core.Test/TvTests/MoveSeriesServiceFixture.cs b/src/NzbDrone.Core.Test/TvTests/MoveSeriesServiceFixture.cs
index fcf92117d..523452754 100644
--- a/src/NzbDrone.Core.Test/TvTests/MoveSeriesServiceFixture.cs
+++ b/src/NzbDrone.Core.Test/TvTests/MoveSeriesServiceFixture.cs
@@ -1,4 +1,6 @@
-using System.IO;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
@@ -16,6 +18,7 @@ namespace NzbDrone.Core.Test.TvTests
{
private Series _series;
private MoveSeriesCommand _command;
+ private BulkMoveSeriesCommand _bulkCommand;
[SetUp]
public void Setup()
@@ -31,9 +34,26 @@ namespace NzbDrone.Core.Test.TvTests
DestinationPath = @"C:\Test\TV2\Series".AsOsAgnostic()
};
+ _bulkCommand = new BulkMoveSeriesCommand
+ {
+ Series = new List
+ {
+ new BulkMoveSeries
+ {
+ SeriesId = 1,
+ SourcePath = @"C:\Test\TV\Series".AsOsAgnostic()
+ }
+ },
+ DestinationRootFolder = @"C:\Test\TV2".AsOsAgnostic()
+ };
+
Mocker.GetMock()
.Setup(s => s.GetSeries(It.IsAny()))
.Returns(_series);
+
+ Mocker.GetMock()
+ .Setup(s => s.FolderExists(It.IsAny()))
+ .Returns(true);
}
private void GivenFailedMove()
@@ -48,49 +68,64 @@ namespace NzbDrone.Core.Test.TvTests
{
GivenFailedMove();
- Assert.Throws(() => Subject.Execute(_command));
+ Subject.Execute(_command);
ExceptionVerification.ExpectedErrors(1);
}
[Test]
- public void should_no_update_series_path_on_error()
+ public void should_revert_series_path_on_error()
{
GivenFailedMove();
- Assert.Throws(() => Subject.Execute(_command));
+ Subject.Execute(_command);
ExceptionVerification.ExpectedErrors(1);
Mocker.GetMock()
- .Verify(v => v.UpdateSeries(It.IsAny(), It.IsAny()), Times.Never());
+ .Verify(v => v.UpdateSeries(It.IsAny(), It.IsAny()), Times.Once());
+ }
+
+ [Test]
+ public void should_use_destination_path()
+ {
+ Subject.Execute(_command);
+
+ Mocker.GetMock()
+ .Verify(v => v.TransferFolder(_command.SourcePath, _command.DestinationPath, TransferMode.Move, It.IsAny()), Times.Once());
+
+ Mocker.GetMock()
+ .Verify(v => v.GetSeriesFolder(It.IsAny(), null), Times.Never());
}
[Test]
public void should_build_new_path_when_root_folder_is_provided()
{
- _command.DestinationPath = null;
- _command.DestinationRootFolder = @"C:\Test\TV3".AsOsAgnostic();
-
- var expectedPath = @"C:\Test\TV3\Series".AsOsAgnostic();
-
+ var seriesFolder = "Series";
+ var expectedPath = Path.Combine(_bulkCommand.DestinationRootFolder, seriesFolder);
+
Mocker.GetMock()
- .Setup(s => s.GetSeriesFolder(It.IsAny(), null))
- .Returns("Series");
+ .Setup(s => s.GetSeriesFolder(It.IsAny(), null))
+ .Returns(seriesFolder);
+
+ Subject.Execute(_bulkCommand);
- Subject.Execute(_command);
-
- Mocker.GetMock()
- .Verify(v => v.UpdateSeries(It.Is(s => s.Path == expectedPath), It.IsAny()), Times.Once());
+ Mocker.GetMock()
+ .Verify(v => v.TransferFolder(_bulkCommand.Series.First().SourcePath, expectedPath, TransferMode.Move, It.IsAny()), Times.Once());
}
[Test]
- public void should_use_destination_path_if_destination_root_folder_is_blank()
+ public void should_skip_series_folder_if_it_does_not_exist()
{
- Subject.Execute(_command);
+ Mocker.GetMock()
+ .Setup(s => s.FolderExists(It.IsAny()))
+ .Returns(false);
- Mocker.GetMock()
- .Verify(v => v.UpdateSeries(It.Is(s => s.Path == _command.DestinationPath), It.IsAny()), Times.Once());
+
+ Subject.Execute(_command);
+
+ Mocker.GetMock()
+ .Verify(v => v.TransferFolder(_command.SourcePath, _command.DestinationPath, TransferMode.Move, It.IsAny()), Times.Never());
Mocker.GetMock()
.Verify(v => v.GetSeriesFolder(It.IsAny(), null), Times.Never());
diff --git a/src/NzbDrone.Core.Test/TvTests/SeriesFolderPathBuilderFixture.cs b/src/NzbDrone.Core.Test/TvTests/SeriesFolderPathBuilderFixture.cs
new file mode 100644
index 000000000..93343034f
--- /dev/null
+++ b/src/NzbDrone.Core.Test/TvTests/SeriesFolderPathBuilderFixture.cs
@@ -0,0 +1,94 @@
+using System.IO;
+using FizzWare.NBuilder;
+using FluentAssertions;
+using Moq;
+using NUnit.Framework;
+using NzbDrone.Core.Organizer;
+using NzbDrone.Core.RootFolders;
+using NzbDrone.Core.Test.Framework;
+using NzbDrone.Core.Tv;
+using NzbDrone.Test.Common;
+
+namespace NzbDrone.Core.Test.TvTests
+{
+ [TestFixture]
+ public class SeriesFolderPathBuilderFixture : CoreTest
+ {
+ private Series _series;
+
+ [SetUp]
+ public void Setup()
+ {
+ _series = Builder.CreateNew()
+ .With(s => s.Title = "Series Title")
+ .With(s => s.Path = @"C:\Test\TV\Series.Title".AsOsAgnostic())
+ .With(s => s.RootFolderPath = null)
+ .Build();
+ }
+
+ public void GivenSeriesFolderName(string name)
+ {
+ Mocker.GetMock()
+ .Setup(s => s.GetSeriesFolder(_series, null))
+ .Returns(name);
+ }
+ public void GivenExistingRootFolder(string rootFolder)
+ {
+ Mocker.GetMock()
+ .Setup(s => s.GetBestRootFolderPath(It.IsAny()))
+ .Returns(rootFolder);
+ }
+
+ [Test]
+ public void should_create_new_series_path()
+ {
+ var rootFolder = @"C:\Test\TV2".AsOsAgnostic();
+
+ GivenSeriesFolderName(_series.Title);
+ _series.RootFolderPath = rootFolder;
+
+
+ Subject.BuildPath(_series, false).Should().Be(Path.Combine(rootFolder, _series.Title));
+ }
+
+ [Test]
+ public void should_reuse_existing_relative_folder_name()
+ {
+ var folderName = Path.GetFileName(_series.Path);
+ var rootFolder = @"C:\Test\TV2".AsOsAgnostic();
+
+ GivenExistingRootFolder(Path.GetDirectoryName(_series.Path));
+ GivenSeriesFolderName(_series.Title);
+ _series.RootFolderPath = rootFolder;
+
+ Subject.BuildPath(_series, true).Should().Be(Path.Combine(rootFolder, folderName));
+ }
+
+ [Test]
+ public void should_reuse_existing_relative_folder_structure()
+ {
+ var existingRootFolder = @"C:\Test\TV".AsOsAgnostic();
+ var existingRelativePath = @"S\Series.Title";
+ var rootFolder = @"C:\Test\TV2".AsOsAgnostic();
+
+ GivenExistingRootFolder(existingRootFolder);
+ GivenSeriesFolderName(_series.Title);
+ _series.RootFolderPath = rootFolder;
+ _series.Path = Path.Combine(existingRootFolder, existingRelativePath);
+
+ Subject.BuildPath(_series, true).Should().Be(Path.Combine(rootFolder, existingRelativePath));
+ }
+
+ [Test]
+ public void should_use_built_path_for_new_series()
+ {
+ var rootFolder = @"C:\Test\TV2".AsOsAgnostic();
+
+ GivenSeriesFolderName(_series.Title);
+ _series.RootFolderPath = rootFolder;
+ _series.Path = null;
+
+ Subject.BuildPath(_series, true).Should().Be(Path.Combine(rootFolder, _series.Title));
+ }
+ }
+}
diff --git a/src/NzbDrone.Core.Test/TvTests/SeriesServiceTests/UpdateMultipleSeriesFixture.cs b/src/NzbDrone.Core.Test/TvTests/SeriesServiceTests/UpdateMultipleSeriesFixture.cs
index 0fa33a68f..d8ad08ec6 100644
--- a/src/NzbDrone.Core.Test/TvTests/SeriesServiceTests/UpdateMultipleSeriesFixture.cs
+++ b/src/NzbDrone.Core.Test/TvTests/SeriesServiceTests/UpdateMultipleSeriesFixture.cs
@@ -1,9 +1,12 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
+using System.IO;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
+using NzbDrone.Core.Organizer;
+using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
@@ -31,7 +34,7 @@ namespace NzbDrone.Core.Test.TvTests.SeriesServiceTests
[Test]
public void should_call_repo_updateMany()
{
- Subject.UpdateSeries(_series);
+ Subject.UpdateSeries(_series, false);
Mocker.GetMock().Verify(v => v.UpdateMany(_series), Times.Once());
}
@@ -42,13 +45,17 @@ namespace NzbDrone.Core.Test.TvTests.SeriesServiceTests
var newRoot = @"C:\Test\TV2".AsOsAgnostic();
_series.ForEach(s => s.RootFolderPath = newRoot);
- Subject.UpdateSeries(_series).ForEach(s => s.Path.Should().StartWith(newRoot));
+ Mocker.GetMock()
+ .Setup(s => s.BuildPath(It.IsAny(), false))
+ .Returns((s, u) => Path.Combine(s.RootFolderPath, s.Title));
+
+ Subject.UpdateSeries(_series, false).ForEach(s => s.Path.Should().StartWith(newRoot));
}
[Test]
public void should_not_update_path_when_rootFolderPath_is_empty()
{
- Subject.UpdateSeries(_series).ForEach(s =>
+ Subject.UpdateSeries(_series, false).ForEach(s =>
{
var expectedPath = _series.Single(ser => ser.Id == s.Id).Path;
s.Path.Should().Be(expectedPath);
@@ -67,7 +74,11 @@ namespace NzbDrone.Core.Test.TvTests.SeriesServiceTests
var newRoot = @"C:\Test\TV2".AsOsAgnostic();
series.ForEach(s => s.RootFolderPath = newRoot);
- Subject.UpdateSeries(series);
+ Mocker.GetMock()
+ .Setup(s => s.GetSeriesFolder(It.IsAny(), (NamingConfig)null))
+ .Returns((s, n) => s.Title);
+
+ Subject.UpdateSeries(series, false);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Core/Annotations/FieldDefinitionAttribute.cs b/src/NzbDrone.Core/Annotations/FieldDefinitionAttribute.cs
index 97927d442..35dd1e5df 100644
--- a/src/NzbDrone.Core/Annotations/FieldDefinitionAttribute.cs
+++ b/src/NzbDrone.Core/Annotations/FieldDefinitionAttribute.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
namespace NzbDrone.Core.Annotations
{
@@ -18,11 +18,13 @@ namespace NzbDrone.Core.Annotations
public FieldType Type { get; set; }
public bool Advanced { get; set; }
public Type SelectOptions { get; set; }
+ public string Section { get; set; }
}
public enum FieldType
{
Textbox,
+ Number,
Password,
Checkbox,
Select,
@@ -32,6 +34,7 @@ namespace NzbDrone.Core.Annotations
Tag,
Action,
Url,
- Captcha
+ Captcha,
+ OAuth
}
}
diff --git a/src/NzbDrone.Core/CustomFilters/CustomFilter.cs b/src/NzbDrone.Core/CustomFilters/CustomFilter.cs
new file mode 100644
index 000000000..1c6e3e9b9
--- /dev/null
+++ b/src/NzbDrone.Core/CustomFilters/CustomFilter.cs
@@ -0,0 +1,11 @@
+using NzbDrone.Core.Datastore;
+
+namespace NzbDrone.Core.CustomFilters
+{
+ public class CustomFilter : ModelBase
+ {
+ public string Type { get; set; }
+ public string Label { get; set; }
+ public string Filters { get; set; }
+ }
+}
diff --git a/src/NzbDrone.Core/CustomFilters/CustomFilterRepository.cs b/src/NzbDrone.Core/CustomFilters/CustomFilterRepository.cs
new file mode 100644
index 000000000..9bdb8fd07
--- /dev/null
+++ b/src/NzbDrone.Core/CustomFilters/CustomFilterRepository.cs
@@ -0,0 +1,17 @@
+using NzbDrone.Core.Datastore;
+using NzbDrone.Core.Messaging.Events;
+
+namespace NzbDrone.Core.CustomFilters
+{
+ public interface ICustomFilterRepository : IBasicRepository
+ {
+ }
+
+ public class CustomFilterRepository : BasicRepository, ICustomFilterRepository
+ {
+ public CustomFilterRepository(IMainDatabase database, IEventAggregator eventAggregator)
+ : base(database, eventAggregator)
+ {
+ }
+ }
+}
diff --git a/src/NzbDrone.Core/CustomFilters/CustomFilterService.cs b/src/NzbDrone.Core/CustomFilters/CustomFilterService.cs
new file mode 100644
index 000000000..9ef98f8be
--- /dev/null
+++ b/src/NzbDrone.Core/CustomFilters/CustomFilterService.cs
@@ -0,0 +1,49 @@
+using System.Collections.Generic;
+using System.Linq;
+
+namespace NzbDrone.Core.CustomFilters
+{
+ public interface ICustomFilterService
+ {
+ CustomFilter Add(CustomFilter customFilter);
+ List All();
+ void Delete(int id);
+ CustomFilter Get(int id);
+ CustomFilter Update(CustomFilter customFilter);
+ }
+
+ public class CustomFilterService : ICustomFilterService
+ {
+ private readonly ICustomFilterRepository _repo;
+
+ public CustomFilterService(ICustomFilterRepository repo)
+ {
+ _repo = repo;
+ }
+
+ public CustomFilter Add(CustomFilter customFilter)
+ {
+ return _repo.Insert(customFilter);
+ }
+
+ public CustomFilter Update(CustomFilter customFilter)
+ {
+ return _repo.Update(customFilter);
+ }
+
+ public void Delete(int id)
+ {
+ _repo.Delete(id);
+ }
+
+ public CustomFilter Get(int id)
+ {
+ return _repo.Get(id);
+ }
+
+ public List All()
+ {
+ return _repo.All().ToList();
+ }
+ }
+}
diff --git a/src/NzbDrone.Core/Datastore/BasicRepository.cs b/src/NzbDrone.Core/Datastore/BasicRepository.cs
index b2afafdc4..3cf47611b 100644
--- a/src/NzbDrone.Core/Datastore/BasicRepository.cs
+++ b/src/NzbDrone.Core/Datastore/BasicRepository.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
@@ -254,10 +254,21 @@ namespace NzbDrone.Core.Datastore
protected virtual SortBuilder GetPagedQuery(QueryBuilder query, PagingSpec pagingSpec)
{
- return query.Where(pagingSpec.FilterExpression)
- .OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection())
- .Skip(pagingSpec.PagingOffset())
- .Take(pagingSpec.PageSize);
+ var filterExpressions = pagingSpec.FilterExpressions;
+ var sortQuery = query.Where(filterExpressions.FirstOrDefault());
+
+ if (filterExpressions.Count > 1)
+ {
+ // Start at the second item for the AndWhere clauses
+ for (var i = 1; i < filterExpressions.Count; i++)
+ {
+ sortQuery.AndWhere(filterExpressions[i]);
+ }
+ }
+
+ return sortQuery.OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection())
+ .Skip(pagingSpec.PagingOffset())
+ .Take(pagingSpec.PageSize);
}
protected void ModelCreated(TModel model)
diff --git a/src/NzbDrone.Core/Datastore/Migration/123_add_history_seriesId_index.cs b/src/NzbDrone.Core/Datastore/Migration/123_add_history_seriesId_index.cs
new file mode 100644
index 000000000..0dd463d8c
--- /dev/null
+++ b/src/NzbDrone.Core/Datastore/Migration/123_add_history_seriesId_index.cs
@@ -0,0 +1,14 @@
+using FluentMigrator;
+using NzbDrone.Core.Datastore.Migration.Framework;
+
+namespace NzbDrone.Core.Datastore.Migration
+{
+ [Migration(123)]
+ public class add_history_seriesId_index : NzbDroneMigrationBase
+ {
+ protected override void MainDbUpgrade()
+ {
+ Create.Index().OnTable("History").OnColumn("SeriesId");
+ }
+ }
+}
diff --git a/src/NzbDrone.Core/Datastore/Migration/126_add_custom_filters.cs b/src/NzbDrone.Core/Datastore/Migration/126_add_custom_filters.cs
new file mode 100644
index 000000000..21792c3be
--- /dev/null
+++ b/src/NzbDrone.Core/Datastore/Migration/126_add_custom_filters.cs
@@ -0,0 +1,17 @@
+using FluentMigrator;
+using NzbDrone.Core.Datastore.Migration.Framework;
+
+namespace NzbDrone.Core.Datastore.Migration
+{
+ [Migration(126)]
+ public class add_custom_filters : NzbDroneMigrationBase
+ {
+ protected override void MainDbUpgrade()
+ {
+ Create.TableForModel("CustomFilters")
+ .WithColumn("Type").AsString().NotNullable()
+ .WithColumn("Label").AsString().NotNullable()
+ .WithColumn("Filters").AsString().NotNullable();
+ }
+ }
+}
diff --git a/src/NzbDrone.Core/Datastore/Migration/Framework/NzbDroneMigrationBase.cs b/src/NzbDrone.Core/Datastore/Migration/Framework/NzbDroneMigrationBase.cs
index 7ebac899c..a76086d28 100644
--- a/src/NzbDrone.Core/Datastore/Migration/Framework/NzbDroneMigrationBase.cs
+++ b/src/NzbDrone.Core/Datastore/Migration/Framework/NzbDroneMigrationBase.cs
@@ -1,4 +1,5 @@
using System;
+using System.Windows.Forms;
using FluentMigrator;
using NLog;
using NzbDrone.Common.Instrumentation;
diff --git a/src/NzbDrone.Core/Datastore/Migration/Framework/NzbDroneSqliteProcessor.cs b/src/NzbDrone.Core/Datastore/Migration/Framework/NzbDroneSqliteProcessor.cs
index 9d10255e0..5b1fb0a58 100644
--- a/src/NzbDrone.Core/Datastore/Migration/Framework/NzbDroneSqliteProcessor.cs
+++ b/src/NzbDrone.Core/Datastore/Migration/Framework/NzbDroneSqliteProcessor.cs
@@ -6,6 +6,7 @@ using FluentMigrator;
using FluentMigrator.Expressions;
using FluentMigrator.Model;
using FluentMigrator.Runner;
+using FluentMigrator.Runner.Announcers;
using FluentMigrator.Runner.Generators.SQLite;
using FluentMigrator.Runner.Processors.SQLite;
using System.Text.RegularExpressions;
diff --git a/src/NzbDrone.Core/Datastore/PagingSpec.cs b/src/NzbDrone.Core/Datastore/PagingSpec.cs
index 63f8d719c..0c9179844 100644
--- a/src/NzbDrone.Core/Datastore/PagingSpec.cs
+++ b/src/NzbDrone.Core/Datastore/PagingSpec.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq.Expressions;
@@ -12,7 +12,12 @@ namespace NzbDrone.Core.Datastore
public string SortKey { get; set; }
public SortDirection SortDirection { get; set; }
public List Records { get; set; }
- public Expression> FilterExpression { get; set; }
+ public List>> FilterExpressions { get; set; }
+
+ public PagingSpec()
+ {
+ FilterExpressions = new List>>();
+ }
}
public enum SortDirection
diff --git a/src/NzbDrone.Core/Datastore/TableMapping.cs b/src/NzbDrone.Core/Datastore/TableMapping.cs
index cea8b2898..945ed40b2 100644
--- a/src/NzbDrone.Core/Datastore/TableMapping.cs
+++ b/src/NzbDrone.Core/Datastore/TableMapping.cs
@@ -29,6 +29,7 @@ using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Tv;
using NzbDrone.Common.Disk;
using NzbDrone.Core.Authentication;
+using NzbDrone.Core.CustomFilters;
using NzbDrone.Core.Extras.Metadata;
using NzbDrone.Core.Extras.Metadata.Files;
using NzbDrone.Core.Extras.Others;
@@ -57,7 +58,8 @@ namespace NzbDrone.Core.Datastore
.Ignore(i => i.Enable)
.Ignore(i => i.Protocol)
.Ignore(i => i.SupportsRss)
- .Ignore(i => i.SupportsSearch);
+ .Ignore(i => i.SupportsSearch)
+ .Ignore(d => d.Tags);
Mapper.Entity().RegisterDefinition("Notifications")
.Ignore(i => i.SupportsOnGrab)
@@ -65,10 +67,12 @@ namespace NzbDrone.Core.Datastore
.Ignore(i => i.SupportsOnUpgrade)
.Ignore(i => i.SupportsOnRename);
- Mapper.Entity().RegisterDefinition("Metadata");
+ Mapper.Entity().RegisterDefinition("Metadata")
+ .Ignore(d => d.Tags);
Mapper.Entity().RegisterDefinition("DownloadClients")
- .Ignore(d => d.Protocol);
+ .Ignore(d => d.Protocol)
+ .Ignore(d => d.Tags);
Mapper.Entity().RegisterModel("SceneMappings");
@@ -121,6 +125,8 @@ namespace NzbDrone.Core.Datastore
Mapper.Entity().RegisterModel("IndexerStatus");
Mapper.Entity