Reformat and apply Stylecop rules

This commit is contained in:
ta264 2019-12-22 22:08:53 +00:00 committed by Qstick
parent d4fa9b7345
commit f02fa629cc
1186 changed files with 7105 additions and 5616 deletions

View File

@ -9,6 +9,35 @@ insert_final_newline = true
indent_style = space
indent_size = 4
# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true
# Avoid "this." and "Me." if not necessary
dotnet_style_qualification_for_field = false:refactoring
dotnet_style_qualification_for_property = false:refactoring
dotnet_style_qualification_for_method = false:refactoring
dotnet_style_qualification_for_event = false:refactoring
# Indentation preferences
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = true
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion
dotnet_naming_style.instance_field_style.capitalization = camel_case
dotnet_naming_style.instance_field_style.required_prefix = _
# Prefer "var" everywhere
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = true:suggestion
[*.{js,html,js,hbs,less,css}]
charset = utf-8
trim_trailing_whitespace = true

1
.gitignore vendored
View File

@ -85,7 +85,6 @@ TestResults
[Tt]est[Rr]esult*
*.Cache
ClientBin
[Ss]tyle[Cc]op.*
~$*
*.dbmdl
Generated_Code #added for RIA/Silverlight projects

View File

@ -2,7 +2,7 @@
<!-- Common to all Radarr Projects -->
<PropertyGroup>
<CodeAnalysisRuleSet>$(SolutionDir)Stylecop.ruleset</CodeAnalysisRuleSet>
<!-- <TreatWarningsAsErrors>true</TreatWarningsAsErrors> -->
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<PlatformTarget>AnyCPU</PlatformTarget>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
@ -94,7 +94,7 @@
</ItemGroup>
<!-- Set up stylecop -->
<ItemGroup Condition="'$(RadarrProject)'=='true' and '$(RadarrOutputType)'!='Test'">
<ItemGroup Condition="'$(RadarrProject)'=='true'">
<!-- StyleCop analysis -->
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>

View File

@ -50,4 +50,3 @@ namespace Marr.Data.Converters
#endregion
}
}

View File

@ -105,7 +105,8 @@ namespace MonoTorrent
int infohashOffset = 0;
byte[] hash = new byte[20];
var temp = new byte[8];
for (int i = 0; i < hash.Length; ) {
for (int i = 0; i < hash.Length;)
{
for (int j = 0; j < 8; j++)
if (!base32DecodeTable.TryGetValue(infoHash[infohashOffset++], out temp[j]))
throw new ArgumentException("infoHash", "Value is not a valid base32 encoded string");

View File

@ -7,19 +7,23 @@ namespace MonoTorrent
{
public class MagnetLink
{
public RawTrackerTier AnnounceUrls {
public RawTrackerTier AnnounceUrls
{
get; private set;
}
public InfoHash InfoHash {
public InfoHash InfoHash
{
get; private set;
}
public string Name {
public string Name
{
get; private set;
}
public List<string> Webseeds {
public List<string> Webseeds
{
get; private set;
}

View File

@ -7,12 +7,14 @@ namespace MonoTorrent
{
public class RawTrackerTier : IList<string>
{
public string this[int index] {
public string this[int index]
{
get { return ((BEncodedString)Tier[index]).Text; }
set { Tier[index] = new BEncodedString(value); }
}
internal BEncodedList Tier {
internal BEncodedList Tier
{
get; set;
}
@ -74,11 +76,13 @@ namespace MonoTorrent
return Tier.Remove((BEncodedString)item);
}
public int Count {
public int Count
{
get { return Tier.Count; }
}
public bool IsReadOnly {
public bool IsReadOnly
{
get { return Tier.IsReadOnly; }
}

View File

@ -7,7 +7,8 @@ namespace MonoTorrent
{
public class RawTrackerTiers : IList<RawTrackerTier>
{
BEncodedList Tiers {
BEncodedList Tiers
{
get; set;
}
@ -23,7 +24,8 @@ namespace MonoTorrent
public int IndexOf(RawTrackerTier item)
{
if (item != null) {
if (item != null)
{
for (int i = 0; i < Tiers.Count; i++)
if (item.Tier == Tiers[i])
return i;
@ -41,7 +43,8 @@ namespace MonoTorrent
Tiers.RemoveAt(index);
}
public RawTrackerTier this[int index] {
public RawTrackerTier this[int index]
{
get { return new RawTrackerTier((BEncodedList)Tiers[index]); }
set { Tiers[index] = value.Tier; }
}
@ -82,11 +85,13 @@ namespace MonoTorrent
return index != -1;
}
public int Count {
public int Count
{
get { return Tiers.Count; }
}
public bool IsReadOnly {
public bool IsReadOnly
{
get { return Tiers.IsReadOnly; }
}

View File

@ -36,7 +36,8 @@ namespace MonoTorrent
if (e == null)
return;
ThreadPool.QueueUserWorkItem(delegate {
ThreadPool.QueueUserWorkItem(delegate
{
if (e != null)
e(o, args);
});

View File

@ -42,21 +42,30 @@ namespace MonoTorrent
int xchar;
char ch;
for (int i = 0; i < len; i++) {
for (int i = 0; i < len; i++)
{
ch = s[i];
if (ch == '%' && i + 2 < len && s [i + 1] != '%') {
if (s [i + 1] == 'u' && i + 5 < len) {
if (ch == '%' && i + 2 < len && s[i + 1] != '%')
{
if (s[i + 1] == 'u' && i + 5 < len)
{
// unicode hex sequence
xchar = GetChar(s, i + 2, 4);
if (xchar != -1) {
if (xchar != -1)
{
WriteCharBytes(bytes, (char)xchar, e);
i += 5;
} else
}
else
WriteCharBytes(bytes, '%', e);
} else if ((xchar = GetChar (s, i + 1, 2)) != -1) {
}
else if ((xchar = GetChar(s, i + 1, 2)) != -1)
{
WriteCharBytes(bytes, (char)xchar, e);
i += 2;
} else {
}
else
{
WriteCharBytes(bytes, '%', e);
}
continue;
@ -71,20 +80,25 @@ namespace MonoTorrent
return bytes.ToArray();
}
static void UrlEncodeChar (char c, Stream result, bool isUnicode) {
if (c > ' ' && NotEncoded (c)) {
static void UrlEncodeChar(char c, Stream result, bool isUnicode)
{
if (c > ' ' && NotEncoded(c))
{
result.WriteByte((byte)c);
return;
}
if (c==' ') {
if (c == ' ')
{
result.WriteByte((byte)'+');
return;
}
if ((c < '0') ||
(c < 'A' && c > '9') ||
(c > 'Z' && c < 'a') ||
(c > 'z')) {
if (isUnicode && c > 127) {
(c > 'z'))
{
if (isUnicode && c > 127)
{
result.WriteByte((byte)'%');
result.WriteByte((byte)'u');
result.WriteByte((byte)'0');
@ -98,7 +112,8 @@ namespace MonoTorrent
idx = ((int)c) & 0x0F;
result.WriteByte((byte)hexChars[idx]);
}
else {
else
{
result.WriteByte((byte)c);
}
}
@ -107,7 +122,8 @@ namespace MonoTorrent
{
int val = 0;
int end = length + offset;
for (int i = offset; i < end; i++) {
for (int i = offset; i < end; i++)
{
char c = str[i];
if (c > 127)
return -1;
@ -143,10 +159,12 @@ namespace MonoTorrent
static void WriteCharBytes(List<byte> buf, char ch, Encoding e)
{
if (ch > 255) {
if (ch > 255)
{
foreach (byte b in e.GetBytes(new char[] { ch }))
buf.Add(b);
} else
}
else
buf.Add((byte)ch);
}
}

View File

@ -1,8 +1,8 @@
using FluentAssertions;
using NUnit.Framework;
using Radarr.Http.ClientSchema;
using NzbDrone.Core.Annotations;
using NzbDrone.Test.Common;
using Radarr.Http.ClientSchema;
namespace NzbDrone.Api.Test.ClientSchemaTests
{
@ -16,7 +16,6 @@ namespace NzbDrone.Api.Test.ClientSchemaTests
schema.Should().HaveCount(2);
}
[Test]
public void schema_should_have_proper_fields()
{
@ -31,10 +30,8 @@ namespace NzbDrone.Api.Test.ClientSchemaTests
schema.Should().Contain(c => c.Order == 1 && c.Name == "lastName" && c.Label == "Last Name" && c.HelpText == "Your Last Name" && (string)c.Value == "Poop");
schema.Should().Contain(c => c.Order == 0 && c.Name == "firstName" && c.Label == "First Name" && c.HelpText == "Your First Name" && (string)c.Value == "Bob");
}
}
public class TestModel
{
[FieldDefinition(0, Label = "First Name", HelpText = "Your First Name")]

View File

@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using NzbDrone.Api.Movies;
using Radarr.Http.REST;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Qualities;
using Radarr.Http.REST;
namespace NzbDrone.Api.Blacklist
{
@ -25,7 +25,10 @@ namespace NzbDrone.Api.Blacklist
{
public static BlacklistResource MapToResource(this Core.Blacklisting.Blacklist model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new BlacklistResource
{

View File

@ -1,4 +1,3 @@
using Nancy;
using System;
using System.Collections.Generic;
using System.Linq;
@ -6,10 +5,11 @@ using Ical.Net;
using Ical.Net.CalendarComponents;
using Ical.Net.DataTypes;
using Ical.Net.Serialization;
using NzbDrone.Core.Movies;
using Nancy;
using Nancy.Responses;
using NzbDrone.Core.Tags;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Tags;
namespace NzbDrone.Api.Calendar
{
@ -36,6 +36,7 @@ namespace NzbDrone.Api.Calendar
var start = DateTime.Today.AddDays(-pastDays);
var end = DateTime.Today.AddDays(futureDays);
var unmonitored = false;
//var premiersOnly = false;
var tags = new List<int>();
@ -45,11 +46,19 @@ namespace NzbDrone.Api.Calendar
var queryPastDays = Request.Query.PastDays;
var queryFutureDays = Request.Query.FutureDays;
var queryUnmonitored = Request.Query.Unmonitored;
// var queryPremiersOnly = Request.Query.PremiersOnly;
var queryTags = Request.Query.Tags;
if (queryStart.HasValue) start = DateTime.Parse(queryStart.Value);
if (queryEnd.HasValue) end = DateTime.Parse(queryEnd.Value);
if (queryStart.HasValue)
{
start = DateTime.Parse(queryStart.Value);
}
if (queryEnd.HasValue)
{
end = DateTime.Parse(queryEnd.Value);
}
if (queryPastDays.HasValue)
{
@ -72,7 +81,6 @@ namespace NzbDrone.Api.Calendar
//{
// premiersOnly = bool.Parse(queryPremiersOnly.Value);
//}
if (queryTags.HasValue)
{
var tagInput = (string)queryTags.Value.ToString();
@ -98,7 +106,6 @@ namespace NzbDrone.Api.Calendar
CreateEvent(calendar, movie, true);
CreateEvent(calendar, movie, false);
}
var serializer = (IStringSerializer)new SerializerFactory().Build(calendar.GetType(), new SerializationContext());

View File

@ -20,7 +20,6 @@ namespace NzbDrone.Api.Calendar
IMapCoversToLocal coverMapper)
: base(signalR, "calendar")
{
_moviesService = moviesService;
_coverMapper = coverMapper;
@ -37,9 +36,20 @@ namespace NzbDrone.Api.Calendar
var queryEnd = Request.Query.End;
var queryIncludeUnmonitored = Request.Query.Unmonitored;
if (queryStart.HasValue) start = DateTime.Parse(queryStart.Value);
if (queryEnd.HasValue) end = DateTime.Parse(queryEnd.Value);
if (queryIncludeUnmonitored.HasValue) includeUnmonitored = Convert.ToBoolean(queryIncludeUnmonitored.Value);
if (queryStart.HasValue)
{
start = DateTime.Parse(queryStart.Value);
}
if (queryEnd.HasValue)
{
end = DateTime.Parse(queryEnd.Value);
}
if (queryIncludeUnmonitored.HasValue)
{
includeUnmonitored = Convert.ToBoolean(queryIncludeUnmonitored.Value);
}
var resources = _moviesService.GetMoviesBetweenDates(start, end, includeUnmonitored).Select(MapToResource);
@ -48,7 +58,10 @@ namespace NzbDrone.Api.Calendar
protected MovieResource MapToResource(Movie movie)
{
if (movie == null) return null;
if (movie == null)
{
return null;
}
var resource = movie.ToResource();

View File

@ -2,8 +2,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using NLog;
using Radarr.Http.Extensions;
using Radarr.Http.Validation;
using NzbDrone.Common;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.Messaging.Commands;
@ -11,7 +9,8 @@ using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.ProgressMessaging;
using NzbDrone.SignalR;
using Radarr.Http;
using Radarr.Http.Extensions;
using Radarr.Http.Validation;
namespace NzbDrone.Api.Commands
{

View File

@ -2,8 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Radarr.Http.REST;
using NzbDrone.Core.Messaging.Commands;
using Radarr.Http.REST;
namespace NzbDrone.Api.Commands
{
@ -27,30 +27,21 @@ namespace NzbDrone.Api.Commands
//Legacy
public CommandStatus State
{
get
{
return Status;
}
get { return Status; }
set { }
}
public bool Manual
{
get
{
return Trigger == CommandTrigger.Manual;
}
get { return Trigger == CommandTrigger.Manual; }
set { }
}
public DateTime StartedOn
{
get
{
return Queued;
}
get { return Queued; }
set { }
}
@ -59,37 +50,51 @@ namespace NzbDrone.Api.Commands
{
get
{
if (Started.HasValue) return Started.Value;
if (Started.HasValue)
{
return Started.Value;
}
return Ended;
}
set { }
set
{
}
}
public bool SendUpdatesToClient
{
get
{
if (Body != null) return (Body as Command).SendUpdatesToClient;
if (Body != null)
{
return (Body as Command).SendUpdatesToClient;
}
return false;
}
set { }
set
{
}
}
public bool UpdateScheduledTask
{
get
{
if (Body != null) return (Body as Command).UpdateScheduledTask;
if (Body != null)
{
return (Body as Command).UpdateScheduledTask;
}
return false;
}
set { }
set
{
}
}
public DateTime? LastExecutionTime { get; set; }
@ -99,7 +104,10 @@ namespace NzbDrone.Api.Commands
{
public static CommandResource ToResource(this CommandModel model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new CommandResource
{

View File

@ -7,7 +7,6 @@ namespace NzbDrone.Api.Config
public DownloadClientConfigModule(IConfigService configService)
: base(configService)
{
}
protected override DownloadClientConfigResource ToResource(IConfigService model)

View File

@ -1,5 +1,5 @@
using Radarr.Http.REST;
using NzbDrone.Core.Configuration;
using Radarr.Http.REST;
namespace NzbDrone.Api.Config
{

View File

@ -1,8 +1,8 @@
using Radarr.Http.REST;
using NzbDrone.Common.Http.Proxy;
using NzbDrone.Core.Authentication;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Update;
using NzbDrone.Common.Http.Proxy;
using Radarr.Http.REST;
namespace NzbDrone.Api.Config
{
@ -54,6 +54,7 @@ namespace NzbDrone.Api.Config
LaunchBrowser = model.LaunchBrowser,
AuthenticationMethod = model.AuthenticationMethod,
AnalyticsEnabled = model.AnalyticsEnabled,
//Username
//Password
LogLevel = model.LogLevel,

View File

@ -1,12 +1,11 @@
using FluentValidation;
using Radarr.Http.Validation;
using NzbDrone.Core.Configuration;
using Radarr.Http.Validation;
namespace NzbDrone.Api.Config
{
public class IndexerConfigModule : NzbDroneConfigModule<IndexerConfigResource>
{
public IndexerConfigModule(IConfigService configService)
: base(configService)
{

View File

@ -1,6 +1,6 @@
using Radarr.Http.REST;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Parser;
using Radarr.Http.REST;
namespace NzbDrone.Api.Config
{

View File

@ -1,6 +1,6 @@
using Radarr.Http.REST;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles;
using Radarr.Http.REST;
namespace NzbDrone.Api.Config
{

View File

@ -2,9 +2,9 @@ using System.Collections.Generic;
using System.Linq;
using FluentValidation;
using FluentValidation.Results;
using Nancy.ModelBinding;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Organizer;
using Nancy.ModelBinding;
using Radarr.Http;
namespace NzbDrone.Api.Config
@ -87,11 +87,9 @@ namespace NzbDrone.Api.Config
var movieSampleResult = _filenameSampleService.GetMovieSample(nameSpec);
//var standardMovieValidationResult = _filenameValidationService.ValidateMovieFilename(movieSampleResult); For now, let's hope the user is not stupid enough :/
var validationFailures = new List<ValidationFailure>();
//validationFailures.AddIfNotNull(standardMovieValidationResult);
if (validationFailures.Any())
{
throw new ValidationException(validationFailures.DistinctBy(v => v.PropertyName).ToArray());

View File

@ -1,5 +1,5 @@
using Radarr.Http.REST;
using NzbDrone.Core.Organizer;
using Radarr.Http.REST;
namespace NzbDrone.Api.Config
{
@ -33,6 +33,7 @@ namespace NzbDrone.Api.Config
MultiEpisodeStyle = model.MultiEpisodeStyle,
StandardMovieFormat = model.StandardMovieFormat,
MovieFolderFormat = model.MovieFolderFormat
//IncludeSeriesTitle
//IncludeEpisodeTitle
//IncludeQuality

View File

@ -1,11 +1,10 @@
using Radarr.Http.Validation;
using NzbDrone.Core.Configuration;
using Radarr.Http.Validation;
namespace NzbDrone.Api.Config
{
public class NetImportConfigModule : NzbDroneConfigModule<NetImportConfigResource>
{
public NetImportConfigModule(IConfigService configService)
: base(configService)
{

View File

@ -1,5 +1,5 @@
using Radarr.Http.REST;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Configuration;
using Radarr.Http.REST;
namespace NzbDrone.Api.Config
{

View File

@ -1,12 +1,13 @@
using System.Linq;
using System.Reflection;
using NzbDrone.Core.Configuration;
using Radarr.Http;
using Radarr.Http.REST;
using NzbDrone.Core.Configuration;
namespace NzbDrone.Api.Config
{
public abstract class NzbDroneConfigModule<TResource> : RadarrRestModule<TResource> where TResource : RestResource, new()
public abstract class NzbDroneConfigModule<TResource> : RadarrRestModule<TResource>
where TResource : RestResource, new()
{
private readonly IConfigService _configService;
@ -15,8 +16,8 @@ namespace NzbDrone.Api.Config
{
}
protected NzbDroneConfigModule(string resource, IConfigService configService) :
base("config/" + resource.Trim('/'))
protected NzbDroneConfigModule(string resource, IConfigService configService)
: base("config/" + resource.Trim('/'))
{
_configService = configService;

View File

@ -7,7 +7,6 @@ namespace NzbDrone.Api.Config
public UiConfigModule(IConfigService configService)
: base(configService)
{
}
protected override UiConfigResource ToResource(IConfigService model)

View File

@ -1,5 +1,5 @@
using Radarr.Http.REST;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Configuration;
using Radarr.Http.REST;
namespace NzbDrone.Api.Config
{

View File

@ -15,7 +15,6 @@ namespace NzbDrone.Api.DiskSpace
GetResourceAll = GetFreeSpace;
}
public List<DiskSpaceResource> GetFreeSpace()
{
return _diskSpaceService.GetFreeSpace().ConvertAll(DiskSpaceResourceMapper.MapToResource);

View File

@ -14,7 +14,10 @@ namespace NzbDrone.Api.DiskSpace
{
public static DiskSpaceResource MapToResource(this Core.DiskSpace.DiskSpace model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new DiskSpaceResource
{

View File

@ -29,7 +29,11 @@ namespace NzbDrone.Api.DownloadClient
protected override void Validate(DownloadClientDefinition definition, bool includeWarnings)
{
if (!definition.Enable) return;
if (!definition.Enable)
{
return;
}
base.Validate(definition, includeWarnings);
}
}

View File

@ -1,10 +1,10 @@
using System.Collections.Generic;
using Radarr.Http.REST;
using NzbDrone.Core.Extras.Files;
using NzbDrone.Core.Extras.Metadata.Files;
using NzbDrone.Core.Extras.Others;
using NzbDrone.Core.Extras.Subtitles;
using Radarr.Http;
using Radarr.Http.REST;
namespace NzbDrone.Api.ExtraFiles
{

View File

@ -1,10 +1,10 @@
using System.Collections.Generic;
using System.Linq;
using Radarr.Http.REST;
using NzbDrone.Core.Extras.Files;
using NzbDrone.Core.Extras.Metadata.Files;
using NzbDrone.Core.Extras.Others;
using NzbDrone.Core.Extras.Subtitles;
using Radarr.Http.REST;
namespace NzbDrone.Api.ExtraFiles
{
@ -21,7 +21,10 @@ namespace NzbDrone.Api.ExtraFiles
{
public static ExtraFileResource ToResource(this MetadataFile model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new ExtraFileResource
{
@ -36,7 +39,10 @@ namespace NzbDrone.Api.ExtraFiles
public static ExtraFileResource ToResource(this SubtitleFile model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new ExtraFileResource
{
@ -51,7 +57,10 @@ namespace NzbDrone.Api.ExtraFiles
public static ExtraFileResource ToResource(this OtherExtraFile model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new ExtraFileResource
{
@ -78,6 +87,5 @@ namespace NzbDrone.Api.ExtraFiles
{
return movies.Select(ToResource).ToList();
}
}
}

View File

@ -1,10 +1,10 @@
using System.IO;
using System.Linq;
using Nancy;
using Radarr.Http.Extensions;
using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.MediaFiles;
using Radarr.Http.Extensions;
namespace NzbDrone.Api.FileSystem
{
@ -60,7 +60,8 @@ namespace NzbDrone.Api.FileSystem
return new string[0];
}
return _diskScanService.GetVideoFiles(path).Select(f => new {
return _diskScanService.GetVideoFiles(path).Select(f => new
{
Path = f,
RelativePath = path.GetRelativePath(f),
Name = Path.GetFileName(f)

View File

@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using Radarr.Http.REST;
using NzbDrone.Common.Http;
using NzbDrone.Core.HealthCheck;
using Radarr.Http.REST;
namespace NzbDrone.Api.Health
{
@ -17,7 +17,10 @@ namespace NzbDrone.Api.Health
{
public static HealthResource ToResource(this HealthCheck model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new HealthResource
{

View File

@ -3,10 +3,10 @@ using System.Linq;
using Nancy;
using NzbDrone.Api.Movies;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Download;
using NzbDrone.Core.History;
using Radarr.Http;
using NzbDrone.Core.DecisionEngine.Specifications;
namespace NzbDrone.Api.History
{

View File

@ -1,10 +1,9 @@
using System;
using System.Collections.Generic;
using Radarr.Http.REST;
using NzbDrone.Api.Movies;
using NzbDrone.Core.History;
using NzbDrone.Core.Qualities;
using Radarr.Http.REST;
namespace NzbDrone.Api.History
{
@ -27,7 +26,10 @@ namespace NzbDrone.Api.History
{
public static HistoryResource ToResource(this Core.History.History model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new HistoryResource
{
@ -35,6 +37,7 @@ namespace NzbDrone.Api.History
MovieId = model.MovieId,
SourceTitle = model.SourceTitle,
Quality = model.Quality,
//QualityCutoffNotMet
Date = model.Date,
DownloadId = model.DownloadId,

View File

@ -31,7 +31,11 @@ namespace NzbDrone.Api.Indexers
protected override void Validate(IndexerDefinition definition, bool includeWarnings)
{
if (!definition.Enable) return;
if (!definition.Enable)
{
return;
}
base.Validate(definition, includeWarnings);
}
}

View File

@ -2,15 +2,15 @@ using System;
using System.Collections.Generic;
using FluentValidation;
using Nancy;
using Nancy.ModelBinding;
using NLog;
using NzbDrone.Common.Cache;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.Exceptions;
using NzbDrone.Core.IndexerSearch;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.IndexerSearch;
using NzbDrone.Core.Parser.Model;
using Nancy.ModelBinding;
using NzbDrone.Common.Cache;
using HttpStatusCode = System.Net.HttpStatusCode;
namespace NzbDrone.Api.Indexers
@ -60,6 +60,7 @@ namespace NzbDrone.Api.Indexers
return new NotFoundResponse();
}
try
{
_downloadService.DownloadReport(remoteMovie);
@ -115,7 +116,6 @@ namespace NzbDrone.Api.Indexers
protected override ReleaseResource MapDecision(DownloadDecision decision, int initialWeight)
{
_remoteMovieCache.Set(decision.RemoteMovie.Release.Guid, decision.RemoteMovie, TimeSpan.FromMinutes(30));
return base.MapDecision(decision, initialWeight);

View File

@ -1,17 +1,17 @@
using FluentValidation;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Parser.Model;
using FluentValidation;
using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Api.Indexers
{
class ReleasePushModule : ReleaseModuleBase
public class ReleasePushModule : ReleaseModuleBase
{
private readonly IMakeDownloadDecision _downloadDecisionMaker;
private readonly IProcessDownloadDecisions _downloadDecisionProcessor;

View File

@ -1,14 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Radarr.Http.REST;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Languages;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.DecisionEngine;
using System.Linq;
using NzbDrone.Core.Qualities;
using Radarr.Http.REST;
namespace NzbDrone.Api.Indexers
{
@ -56,7 +56,6 @@ namespace NzbDrone.Api.Indexers
public int? Leechers { get; set; }
public DownloadProtocol Protocol { get; set; }
// TODO: Remove in v3
// Used to support the original Release Push implementation
// JsonIgnore so we don't serialize it, but can still parse it
@ -122,8 +121,8 @@ namespace NzbDrone.Api.Indexers
DownloadUrl = releaseInfo.DownloadUrl,
InfoUrl = releaseInfo.InfoUrl,
MappingResult = mappingResult,
//ReleaseWeight
//ReleaseWeight
SuspectedMovieId = movieId,
MagnetUrl = torrentInfo.MagnetUrl,
@ -136,7 +135,6 @@ namespace NzbDrone.Api.Indexers
//Special = parsedMovieInfo.Special,
};
}
public static ReleaseInfo ToModel(this ReleaseResource resource)

View File

@ -60,7 +60,9 @@ namespace NzbDrone.Api.Logs
var filePath = GetLogFilePath(filename);
if (!_diskProvider.FileExists(filePath))
{
return new NotFoundResponse();
}
var data = _diskProvider.ReadAllText(filePath);

View File

@ -17,7 +17,10 @@ namespace NzbDrone.Api.Logs
{
public static LogResource ToResource(this Core.Instrumentation.Log model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new LogResource
{

View File

@ -25,7 +25,10 @@ namespace NzbDrone.Api.Logs
protected override IEnumerable<string> GetLogFiles()
{
if (!_diskProvider.FolderExists(_appFolderInfo.GetUpdateLogFolder())) return Enumerable.Empty<string>();
if (!_diskProvider.FolderExists(_appFolderInfo.GetUpdateLogFolder()))
{
return Enumerable.Empty<string>();
}
return _diskProvider.GetFiles(_appFolderInfo.GetUpdateLogFolder(), SearchOption.TopDirectoryOnly)
.Where(f => Regex.IsMatch(Path.GetFileName(f), LOGFILE_ROUTE.TrimStart('/'), RegexOptions.IgnoreCase))

View File

@ -1,10 +1,10 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Api.Movies;
using Radarr.Http.REST;
using NzbDrone.Common.Crypto;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Qualities;
using Radarr.Http.REST;
namespace NzbDrone.Api.ManualImport
{
@ -25,7 +25,10 @@ namespace NzbDrone.Api.ManualImport
{
public static ManualImportResource ToResource(this Core.MediaFiles.MovieImport.Manual.ManualImportItem model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new ManualImportResource
{
@ -37,6 +40,7 @@ namespace NzbDrone.Api.ManualImport
Size = model.Size,
Movie = model.Movie.ToResource(),
Quality = model.Quality,
//QualityWeight
DownloadId = model.DownloadId,
Rejections = model.Rejections

View File

@ -10,14 +10,14 @@ namespace NzbDrone.Api.MediaCovers
{
public class MediaCoverModule : NzbDroneApiModule
{
private const string MEDIA_COVER_ROUTE = @"/(?<movieId>\d+)/(?<filename>(.+)\.(jpg|png|gif))";
private static readonly Regex RegexResizedImage = new Regex(@"-\d+\.jpg$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private const string MEDIA_COVER_ROUTE = @"/(?<seriesId>\d+)/(?<filename>(.+)\.(jpg|png|gif))";
private readonly IAppFolderInfo _appFolderInfo;
private readonly IDiskProvider _diskProvider;
public MediaCoverModule(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider) : base("MediaCover")
public MediaCoverModule(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider)
: base("MediaCover")
{
_appFolderInfo = appFolderInfo;
_diskProvider = diskProvider;
@ -38,6 +38,7 @@ namespace NzbDrone.Api.MediaCovers
{
return new NotFoundResponse();
}
filePath = basefilePath;
}

View File

@ -25,7 +25,11 @@ namespace NzbDrone.Api.Metadata
protected override void Validate(MetadataDefinition definition, bool includeWarnings)
{
if (!definition.Enable) return;
if (!definition.Enable)
{
return;
}
base.Validate(definition, includeWarnings);
}
}

View File

@ -1,13 +1,13 @@
using System.IO;
using NLog;
using Radarr.Http;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Movies;
using NzbDrone.SignalR;
using NzbDrone.Core.DecisionEngine.Specifications;
using Radarr.Http;
namespace NzbDrone.Api.MovieFiles
{
@ -44,7 +44,6 @@ namespace NzbDrone.Api.MovieFiles
return movie.ToResource();
}
private void SetQuality(MovieFileResource movieFileResource)
{
var movieFile = _mediaFileService.GetMovie(movieFileResource.Id);

View File

@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Radarr.Http.REST;
using NzbDrone.Api.Movies;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Qualities;
using Radarr.Http.REST;
namespace NzbDrone.Api.MovieFiles
{
@ -12,13 +12,11 @@ namespace NzbDrone.Api.MovieFiles
{
public MovieFileResource()
{
}
//Todo: Sorters should be done completely on the client
//Todo: Is there an easy way to keep IgnoreArticlesWhenSorting in sync between, Series, History, Missing?
//Todo: We should get the entire Profile instead of ID and Name separately
public int MovieId { get; set; }
public string RelativePath { get; set; }
public string Path { get; set; }
@ -38,7 +36,10 @@ namespace NzbDrone.Api.MovieFiles
{
public static MovieFileResource ToResource(this MovieFile model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
MovieResource movie = null;
@ -69,11 +70,13 @@ namespace NzbDrone.Api.MovieFiles
public static MovieFile ToModel(this MovieFileResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new MovieFile
{
};
}

View File

@ -1,7 +1,7 @@
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.MetadataSource.RadarrAPI;
using NzbDrone.Core.Movies.AlternativeTitles;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Movies.AlternativeTitles;
using NzbDrone.Core.Movies.Events;
using Radarr.Http;

View File

@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using Radarr.Http.REST;
using NzbDrone.Core.Movies.AlternativeTitles;
using NzbDrone.Core.Languages;
using NzbDrone.Core.Movies.AlternativeTitles;
using Radarr.Http.REST;
namespace NzbDrone.Api.Movies
{
@ -10,13 +10,11 @@ namespace NzbDrone.Api.Movies
{
public AlternativeTitleResource()
{
}
//Todo: Sorters should be done completely on the client
//Todo: Is there an easy way to keep IgnoreArticlesWhenSorting in sync between, Series, History, Missing?
//Todo: We should get the entire Profile instead of ID and Name separately
public SourceType SourceType { get; set; }
public int MovieId { get; set; }
public string Title { get; set; }
@ -33,7 +31,10 @@ namespace NzbDrone.Api.Movies
{
public static AlternativeTitleResource ToResource(this AlternativeTitle model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new AlternativeTitleResource
{
@ -50,7 +51,10 @@ namespace NzbDrone.Api.Movies
public static AlternativeTitle ToModel(this AlternativeTitleResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new AlternativeTitle
{

View File

@ -6,13 +6,11 @@ namespace NzbDrone.Api.Movies
{
public AlternativeYearResource()
{
}
//Todo: Sorters should be done completely on the client
//Todo: Is there an easy way to keep IgnoreArticlesWhenSorting in sync between, Series, History, Missing?
//Todo: We should get the entire Profile instead of ID and Name separately
public int MovieId { get; set; }
public int Year { get; set; }

View File

@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using Nancy;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource;
using System.Linq;
using NzbDrone.Core.NetImport;
using Radarr.Http;
@ -21,7 +21,6 @@ namespace NzbDrone.Api.Movies
Get("/", x => Search());
}
private object Search()
{
var results = _fetchNetImport.FetchAndFilter((int)Request.Query.listId, false);
@ -41,7 +40,6 @@ namespace NzbDrone.Api.Movies
return MapToResource(results);
}
private static IEnumerable<MovieResource> MapToResource(IEnumerable<Core.Movies.Movie> movies)
{
foreach (var currentSeries in movies)

View File

@ -1,23 +1,22 @@
using System.Collections.Generic;
using Nancy;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource;
using NzbDrone.Core.Parser;
using System.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using Nancy;
using NzbDrone.Common.Cache;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.MovieImport;
using NzbDrone.Core.RootFolders;
using NzbDrone.Common.Cache;
using NzbDrone.Core.MetadataSource;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.RootFolders;
using Radarr.Http;
namespace NzbDrone.Api.Movies
{
public class UnmappedComparer : IComparer<UnmappedFolder>
{
public int Compare(UnmappedFolder a, UnmappedFolder b)
@ -37,10 +36,14 @@ namespace NzbDrone.Api.Movies
private readonly IProfileService _profileService;
private readonly IMovieService _movieService;
public MovieBulkImportModule(ISearchForNewMovie searchProxy, IRootFolderService rootFolderService,
public MovieBulkImportModule(ISearchForNewMovie searchProxy,
IRootFolderService rootFolderService,
IMakeImportDecision importDecisionMaker,
IDiskScanService diskScanService, ICacheManager cacheManager,
IParsingService parsingService, IProfileService profileService, IMovieService movieService)
IDiskScanService diskScanService,
ICacheManager cacheManager,
IParsingService parsingService,
IProfileService profileService,
IMovieService movieService)
: base("/movies/bulkimport")
{
_searchProxy = searchProxy;
@ -54,7 +57,6 @@ namespace NzbDrone.Api.Movies
Get("/", x => Search());
}
private object Search()
{
if (Request.Query.Id == 0)
@ -167,7 +169,6 @@ namespace NzbDrone.Api.Movies
};
}
private static IEnumerable<MovieResource> MapToResource(IEnumerable<Core.Movies.Movie> movies)
{
foreach (var currentMovie in movies)

View File

@ -1,10 +1,10 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Api.NetImport;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource;
using System.Linq;
using Radarr.Http;
using NzbDrone.Core.NetImport;
using NzbDrone.Api.NetImport;
using Radarr.Http;
namespace NzbDrone.Api.Movies
{
@ -32,7 +32,8 @@ namespace NzbDrone.Api.Movies
{
var lists = _netImportFactory.Discoverable();
return lists.Select(definition => {
return lists.Select(definition =>
{
var resource = new NetImportResource();
resource.Id = definition.Definition.Id;

View File

@ -2,8 +2,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Nancy;
using Radarr.Http.Extensions;
using NzbDrone.Core.Movies;
using Radarr.Http.Extensions;
namespace NzbDrone.Api.Movies
{
@ -15,19 +15,19 @@ namespace NzbDrone.Api.Movies
: base("/movie/editor")
{
_movieService = movieService;
Put("/", Movie => SaveAll());
Put("/delete", Movie => DeleteSelected());
Put("/", movie => SaveAll());
Put("/delete", movie => DeleteSelected());
}
private object SaveAll()
{
var resources = Request.Body.FromJson<List<MovieResource>>();
var Movie = resources.Select(MovieResource => MovieResource.ToModel(_movieService.GetMovie(MovieResource.Id))).ToList();
var movie = resources.Select(movieResource => movieResource.ToModel(_movieService.GetMovie(movieResource.Id))).ToList();
return ResponseWithCode(_movieService.UpdateMovie(Movie)
.ToResource()
, HttpStatusCode.Accepted);
return ResponseWithCode(_movieService.UpdateMovie(movie)
.ToResource(),
HttpStatusCode.Accepted);
}
private object DeleteSelected()
@ -41,10 +41,12 @@ namespace NzbDrone.Api.Movies
{
deleteFiles = Convert.ToBoolean(deleteFilesQuery.Value);
}
if (addExclusionQuery.HasValue)
{
addExclusion = Convert.ToBoolean(addExclusionQuery.Value);
}
var ids = Request.Body.FromJson<List<int>>();
foreach (var id in ids)

View File

@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Nancy;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource;
using System.Linq;
using System;
using Radarr.Http;
using Radarr.Http.REST;
@ -27,7 +27,7 @@ namespace NzbDrone.Api.Movies
private object SearchByTmdbId()
{
int tmdbId = -1;
if(Int32.TryParse(Request.Query.tmdbId, out tmdbId))
if (int.TryParse(Request.Query.tmdbId, out tmdbId))
{
var result = _movieInfo.GetMovieInfo(tmdbId, null, true);
return result.ToResource();

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using FluentValidation;
using Nancy;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.MediaCover;
@ -9,10 +10,9 @@ using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Movies.Events;
using NzbDrone.Core.Validation.Paths;
using NzbDrone.Core.Validation;
using NzbDrone.Core.Validation.Paths;
using NzbDrone.SignalR;
using Nancy;
using Radarr.Http;
namespace NzbDrone.Api.Movies
@ -25,13 +25,12 @@ namespace NzbDrone.Api.Movies
IHandle<MovieDeletedEvent>,
IHandle<MovieRenamedEvent>,
IHandle<MediaCoversUpdatedEvent>
{
private const string TITLE_SLUG_ROUTE = "/titleslug/(?<slug>[^/]+)";
protected readonly IMovieService _moviesService;
private readonly IMapCoversToLocal _coverMapper;
private const string TITLE_SLUG_ROUTE = "/titleslug/(?<slug>[^/]+)";
public MovieModule(IBroadcastSignalRMessage signalRBroadcaster,
IMovieService moviesService,
IMapCoversToLocal coverMapper,
@ -40,8 +39,7 @@ namespace NzbDrone.Api.Movies
MovieExistsValidator moviesExistsValidator,
MovieAncestorValidator moviesAncestorValidator,
SystemFolderValidator systemFolderValidator,
ProfileExistsValidator profileExistsValidator
)
ProfileExistsValidator profileExistsValidator)
: base(signalRBroadcaster)
{
_moviesService = moviesService;
@ -84,7 +82,10 @@ namespace NzbDrone.Api.Movies
protected MovieResource MapToResource(Movie movies)
{
if (movies == null) return null;
if (movies == null)
{
return null;
}
var resource = movies.ToResource();
MapCoversToLocal(resource);
@ -128,6 +129,7 @@ namespace NzbDrone.Api.Movies
{
deleteFiles = Convert.ToBoolean(deleteFilesQuery.Value);
}
if (addExclusionQuery.HasValue)
{
addExclusion = Convert.ToBoolean(addExclusionQuery.Value);
@ -151,7 +153,10 @@ namespace NzbDrone.Api.Movies
public void Handle(MovieFileDeletedEvent message)
{
if (message.Reason == DeleteMediaFileReason.Upgrade) return;
if (message.Reason == DeleteMediaFileReason.Upgrade)
{
return;
}
BroadcastResourceChange(ModelAction.Updated, message.MovieFile.MovieId);
}

View File

@ -65,7 +65,6 @@ namespace NzbDrone.Api.Movies
//add a grabbed field in MovieResource?
//resource.Grabbed = true;
BroadcastResourceChange(ModelAction.Updated, resource);
}

View File

@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Radarr.Http.REST;
using NzbDrone.Api.MovieFiles;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.Movies;
using NzbDrone.Api.MovieFiles;
using Radarr.Http.REST;
namespace NzbDrone.Api.Movies
{
@ -64,6 +64,7 @@ namespace NzbDrone.Api.Movies
public DateTime Added { get; set; }
public AddMovieOptions AddOptions { get; set; }
public Ratings Ratings { get; set; }
//public List<string> AlternativeTitles { get; set; }
public MovieFileResource MovieFile { get; set; }
@ -90,15 +91,15 @@ namespace NzbDrone.Api.Movies
{
public static MovieResource ToResource(this Core.Movies.Movie model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
long size = model.MovieFile?.Size ?? 0;
bool downloaded = model.MovieFile != null;
MovieFileResource movieFile = model.MovieFile?.ToResource();
/*if(model.MovieFile != null)
{
model.MovieFile.LazyLoad();
@ -112,12 +113,12 @@ namespace NzbDrone.Api.Movies
}*/
//model.AlternativeTitles.LazyLoad();
return new MovieResource
{
Id = model.Id,
TmdbId = model.TmdbId,
Title = model.Title,
//AlternateTitles
SortTitle = model.SortTitle,
InCinemas = model.InCinemas,
@ -125,12 +126,14 @@ namespace NzbDrone.Api.Movies
PhysicalReleaseNote = model.PhysicalReleaseNote,
HasFile = model.HasFile,
Downloaded = downloaded,
//TotalEpisodeCount
//EpisodeCount
//EpisodeFileCount
SizeOnDisk = size,
Status = model.Status,
Overview = model.Overview,
//NextAiring
//PreviousAiring
Images = model.Images,
@ -150,7 +153,6 @@ namespace NzbDrone.Api.Movies
FolderName = model.FolderName(),
//SizeOnDisk = size,
Runtime = model.Runtime,
LastInfoSync = model.LastInfoSync,
CleanTitle = model.CleanTitle,
@ -173,7 +175,10 @@ namespace NzbDrone.Api.Movies
public static Core.Movies.Movie ToModel(this MovieResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new Core.Movies.Movie
{
@ -181,16 +186,19 @@ namespace NzbDrone.Api.Movies
TmdbId = resource.TmdbId,
Title = resource.Title,
//AlternateTitles
SortTitle = resource.SortTitle,
InCinemas = resource.InCinemas,
PhysicalRelease = resource.PhysicalRelease,
PhysicalReleaseNote = resource.PhysicalReleaseNote,
//TotalEpisodeCount
//EpisodeCount
//EpisodeFileCount
//SizeOnDisk
Overview = resource.Overview,
//NextAiring
//PreviousAiring
Images = resource.Images,
@ -218,6 +226,7 @@ namespace NzbDrone.Api.Movies
Tags = resource.Tags,
Added = resource.Added,
AddOptions = resource.AddOptions,
//AlternativeTitles = resource.AlternativeTitles,
Ratings = resource.Ratings,
YouTubeTrailerId = resource.YouTubeTrailerId,

View File

@ -1,7 +1,7 @@
using Radarr.Http.REST;
using NzbDrone.Core.MediaFiles;
using System.Collections.Generic;
using NzbDrone.Core.MediaFiles;
using Radarr.Http;
using Radarr.Http.REST;
namespace NzbDrone.Api.Movies
{
@ -28,6 +28,5 @@ namespace NzbDrone.Api.Movies
return _renameMovieFileService.GetRenamePreviews(movieId).ToResource();
}
}
}

View File

@ -1,6 +1,6 @@
using Radarr.Http.REST;
using System.Collections.Generic;
using System.Linq;
using Radarr.Http.REST;
namespace NzbDrone.Api.Movies
{
@ -16,7 +16,10 @@ namespace NzbDrone.Api.Movies
{
public static RenameMovieResource ToResource(this Core.MediaFiles.RenameMovieFilePreview model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new RenameMovieResource
{

View File

@ -9,7 +9,8 @@ namespace NzbDrone.Api.NetImport
{
private readonly IImportExclusionsService _exclusionService;
public ImportExclusionsModule(NetImportFactory netImportFactory, IImportExclusionsService exclusionService) : base("exclusions")
public ImportExclusionsModule(NetImportFactory netImportFactory, IImportExclusionsService exclusionService)
: base("exclusions")
{
_exclusionService = exclusionService;
GetResourceAll = GetAll;

View File

@ -15,7 +15,10 @@ namespace NzbDrone.Api.NetImport
{
public static ImportExclusionsResource ToResource(this Core.NetImport.ImportExclusions.ImportExclusion model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new ImportExclusionsResource
{

View File

@ -2,10 +2,10 @@ using System.Collections.Generic;
using System.Linq;
using Nancy;
using Nancy.Extensions;
using Radarr.Http.Extensions;
using NzbDrone.Api.Movies;
using NzbDrone.Core.MetadataSource;
using NzbDrone.Core.Movies;
using Radarr.Http.Extensions;
namespace NzbDrone.Api.NetImport
{
@ -19,16 +19,16 @@ namespace NzbDrone.Api.NetImport
{
_movieService = movieService;
_movieSearch = movieSearch;
Put("/", Movie => SaveAll());
Put("/", movie => SaveAll());
}
private object SaveAll()
{
var resources = Request.Body.FromJson<List<MovieResource>>();
var Movies = resources.Select(MovieResource => _movieSearch.MapMovieToTmdbMovie(MovieResource.ToModel())).Where(m => m != null).DistinctBy(m => m.TmdbId).ToList();
var movies = resources.Select(movieResource => _movieSearch.MapMovieToTmdbMovie(movieResource.ToModel())).Where(m => m != null).DistinctBy(m => m.TmdbId).ToList();
return ResponseWithCode(_movieService.AddMovies(Movies).ToResource(), HttpStatusCode.Accepted);
return ResponseWithCode(_movieService.AddMovies(movies).ToResource(), HttpStatusCode.Accepted);
}
}
}

View File

@ -6,7 +6,8 @@ namespace NzbDrone.Api.NetImport
{
public class NetImportModule : ProviderModuleBase<NetImportResource, INetImport, NetImportDefinition>
{
public NetImportModule(NetImportFactory netImportFactory) : base(netImportFactory, "netimport")
public NetImportModule(NetImportFactory netImportFactory)
: base(netImportFactory, "netimport")
{
PostValidator.RuleFor(c => c.RootFolderPath).IsValidPath();
PostValidator.RuleFor(c => c.MinimumAvailability).NotNull();
@ -41,7 +42,11 @@ namespace NzbDrone.Api.NetImport
protected override void Validate(NetImportDefinition definition, bool includeWarnings)
{
if (!definition.Enable) return;
if (!definition.Enable)
{
return;
}
base.Validate(definition, includeWarnings);
}
}

View File

@ -41,7 +41,11 @@ namespace NzbDrone.Api.Notifications
protected override void Validate(NotificationDefinition definition, bool includeWarnings)
{
if (!definition.OnGrab && !definition.OnDownload) return;
if (!definition.OnGrab && !definition.OnDownload)
{
return;
}
base.Validate(definition, includeWarnings);
}
}

View File

@ -21,7 +21,6 @@ namespace NzbDrone.Api.Parse
var title = Request.Query.Title.Value as string;
var parsedMovieInfo = _parsingService.ParseMovieInfo(title, new List<object>());
if (parsedMovieInfo == null)
{
return null;

View File

@ -1,6 +1,6 @@
using NzbDrone.Api.Movies;
using Radarr.Http.REST;
using NzbDrone.Core.Parser.Model;
using Radarr.Http.REST;
namespace NzbDrone.Api.Parse
{

View File

@ -1,9 +1,9 @@
using System.Collections.Generic;
using FluentValidation;
using Radarr.Http.REST;
using Radarr.Http.Validation;
using NzbDrone.Core.Profiles.Delay;
using Radarr.Http;
using Radarr.Http.REST;
using Radarr.Http.Validation;
namespace NzbDrone.Api.Profiles.Delay
{

View File

@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using Radarr.Http.REST;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Profiles.Delay;
using Radarr.Http.REST;
namespace NzbDrone.Api.Profiles.Delay
{
@ -21,7 +21,10 @@ namespace NzbDrone.Api.Profiles.Delay
{
public static DelayProfileResource ToResource(this DelayProfile model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new DelayProfileResource
{
@ -39,7 +42,10 @@ namespace NzbDrone.Api.Profiles.Delay
public static DelayProfile ToModel(this DelayProfileResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new DelayProfile
{

View File

@ -3,7 +3,7 @@ using Nancy;
namespace NzbDrone.Api.Profiles
{
class LegacyProfileModule : NzbDroneApiModule
public class LegacyProfileModule : NzbDroneApiModule
{
public LegacyProfileModule()
: base("qualityprofile")

View File

@ -1,11 +1,11 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Api.Qualities;
using Radarr.Http.REST;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Languages;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Qualities;
using Radarr.Http.REST;
namespace NzbDrone.Api.Profiles
{
@ -36,13 +36,22 @@ namespace NzbDrone.Api.Profiles
{
public static ProfileResource ToResource(this Profile model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
var cutoffItem = model.Items.First(q =>
{
if (q.Id == model.Cutoff) return true;
if (q.Id == model.Cutoff)
{
return true;
}
if (q.Quality == null) return false;
if (q.Quality == null)
{
return false;
}
return q.Quality.Id == model.Cutoff;
});
@ -53,9 +62,15 @@ namespace NzbDrone.Api.Profiles
var formatCutoffItem = model.FormatItems.First(q =>
{
if (q.Id == model.FormatCutoff) return true;
if (q.Id == model.FormatCutoff)
{
return true;
}
if (q.Format == null) return false;
if (q.Format == null)
{
return false;
}
return q.Format.Id == model.FormatCutoff;
});
@ -93,7 +108,10 @@ namespace NzbDrone.Api.Profiles
public static ProfileQualityItemResource ToResource(this ProfileQualityItem model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new ProfileQualityItemResource
{
@ -113,7 +131,10 @@ namespace NzbDrone.Api.Profiles
public static Profile ToModel(this ProfileResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new Profile
{
@ -131,7 +152,10 @@ namespace NzbDrone.Api.Profiles
public static ProfileQualityItem ToModel(this ProfileQualityItemResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new ProfileQualityItem
{

View File

@ -31,7 +31,8 @@ namespace NzbDrone.Api.Profiles
var formatItems = _formatService.All().Select(v => new ProfileFormatItem
{
Format = v, Allowed = true
Format = v,
Allowed = true
}).ToList();
formatItems.Insert(0, new ProfileFormatItem

View File

@ -20,7 +20,6 @@ namespace NzbDrone.Api.Profiles
public AllowedValidator()
: base("Must contain at least one allowed quality")
{
}
protected override bool IsValid(PropertyValidatorContext context)

View File

@ -3,10 +3,10 @@ using System.Linq;
using FluentValidation;
using FluentValidation.Results;
using Nancy;
using Newtonsoft.Json;
using NzbDrone.Common.Reflection;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
using Newtonsoft.Json;
using Radarr.Http;
using Radarr.Http.ClientSchema;
@ -181,7 +181,6 @@ namespace NzbDrone.Api
return "{}";
}
private object RequestAction(string action, TProviderResource providerResource)
{
var providerDefinition = GetDefinition(providerResource, true, false);

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using NzbDrone.Core.ThingiProvider;
using Radarr.Http.ClientSchema;
using Radarr.Http.REST;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Api
{

View File

@ -31,7 +31,7 @@ namespace NzbDrone.Api.Qualities
var allNewTags = c.Select(t => t.ToLower());
var enumerable = allTags.ToList();
var newTags = allNewTags.ToList();
return (enumerable.All(newTags.Contains) && f.Id != v.Id && enumerable.Count() == newTags.Count());
return enumerable.All(newTags.Contains) && f.Id != v.Id && enumerable.Count() == newTags.Count();
});
})
.WithMessage("Should be unique.");
@ -100,6 +100,7 @@ namespace NzbDrone.Api.Qualities
{
return null;
}
return new CustomFormatTestResource
{
Matches = _parsingService.MatchFormatTags(parsed).ToResource(),
@ -121,6 +122,7 @@ namespace NzbDrone.Api.Qualities
{
return null;
}
return new CustomFormatTestResource
{
Matches = _parsingService.MatchFormatTags(parsed).ToResource(),

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Radarr.Http.REST;
using NzbDrone.Core.CustomFormats;
using Radarr.Http.REST;
namespace NzbDrone.Api.Qualities
{

View File

@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using Radarr.Http.REST;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.CustomFormats;
using Radarr.Http.REST;
namespace NzbDrone.Api.Qualities
{
@ -29,7 +29,10 @@ namespace NzbDrone.Api.Qualities
{
public static FormatTagMatchResultResource ToResource(this FormatTagMatchResult model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new FormatTagMatchResultResource
{

View File

@ -7,7 +7,8 @@ namespace NzbDrone.Api.Qualities
{
public class FormatTagValidator : PropertyValidator
{
public FormatTagValidator() : base("{ValidationMessage}")
public FormatTagValidator()
: base("{ValidationMessage}")
{
}
@ -23,7 +24,10 @@ namespace NzbDrone.Api.Qualities
var invalidTags = tags.Where(t => !FormatTag.QualityTagRegex.IsMatch(t));
if (invalidTags.Count() == 0) return true;
if (invalidTags.Count() == 0)
{
return true;
}
var formatMessage =
$"Format Tags ({string.Join(", ", invalidTags)}) are in an invalid format! Check the Wiki to learn how they should look.";

View File

@ -1,8 +1,8 @@
using System.Collections.Generic;
using Radarr.Http.REST;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Qualities;
using Radarr.Http;
using Radarr.Http.REST;
namespace NzbDrone.Api.Qualities
{

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Radarr.Http.REST;
using NzbDrone.Core.Qualities;
using Radarr.Http.REST;
namespace NzbDrone.Api.Qualities
{
@ -21,7 +21,10 @@ namespace NzbDrone.Api.Qualities
{
public static QualityDefinitionResource ToResource(this QualityDefinition model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new QualityDefinitionResource
{
@ -40,7 +43,10 @@ namespace NzbDrone.Api.Qualities
public static QualityDefinition ToModel(this QualityDefinitionResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new QualityDefinition
{

View File

@ -1,12 +1,12 @@
using System;
using Nancy;
using Radarr.Http.Extensions;
using Radarr.Http.REST;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Pending;
using NzbDrone.Core.Download.TrackedDownloads;
using NzbDrone.Core.Queue;
using Radarr.Http;
using Radarr.Http.Extensions;
using Radarr.Http.REST;
namespace NzbDrone.Api.Queue
{

View File

@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using Radarr.Http.REST;
using NzbDrone.Core.Qualities;
using System.Linq;
using NzbDrone.Api.Movies;
using NzbDrone.Core.Download.TrackedDownloads;
using NzbDrone.Core.Indexers;
using System.Linq;
using NzbDrone.Core.Qualities;
using Radarr.Http.REST;
namespace NzbDrone.Api.Queue
{
@ -29,7 +29,10 @@ namespace NzbDrone.Api.Queue
{
public static QueueResource ToResource(this Core.Queue.Queue model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new QueueResource
{

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Radarr.Http.REST;
using NzbDrone.Core.RemotePathMappings;
using Radarr.Http.REST;
namespace NzbDrone.Api.RemotePathMappings
{
@ -16,7 +16,10 @@ namespace NzbDrone.Api.RemotePathMappings
{
public static RemotePathMappingResource ToResource(this RemotePathMapping model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new RemotePathMappingResource
{
@ -30,7 +33,10 @@ namespace NzbDrone.Api.RemotePathMappings
public static RemotePathMapping ToModel(this RemotePathMappingResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new RemotePathMapping
{

View File

@ -9,7 +9,6 @@ namespace Radarr.Http.RESTrictions
{
private readonly IRestrictionService _restrictionService;
public RestrictionModule(IRestrictionService restrictionService)
{
_restrictionService = restrictionService;

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Radarr.Http.REST;
using NzbDrone.Core.Restrictions;
using Radarr.Http.REST;
namespace Radarr.Http.RESTrictions
{
@ -22,7 +22,10 @@ namespace Radarr.Http.RESTrictions
{
public static RestrictionResource ToResource(this Restriction model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new RestrictionResource
{
@ -37,7 +40,10 @@ namespace Radarr.Http.RESTrictions
public static Restriction ToModel(this RestrictionResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new Restriction
{

View File

@ -18,8 +18,7 @@ namespace NzbDrone.Api.RootFolders
MappedNetworkDriveValidator mappedNetworkDriveValidator,
StartupFolderValidator startupFolderValidator,
SystemFolderValidator systemFolderValidator,
FolderWritableValidator folderWritableValidator
)
FolderWritableValidator folderWritableValidator)
: base(signalRBroadcaster)
{
_rootFolderService = rootFolderService;

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Radarr.Http.REST;
using NzbDrone.Core.RootFolders;
using Radarr.Http.REST;
namespace NzbDrone.Api.RootFolders
{
@ -18,7 +18,10 @@ namespace NzbDrone.Api.RootFolders
{
public static RootFolderResource ToResource(this RootFolder model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new RootFolderResource
{
@ -33,7 +36,10 @@ namespace NzbDrone.Api.RootFolders
public static RootFolder ToModel(this RootFolderResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new RootFolder
{

View File

@ -9,7 +9,8 @@ namespace NzbDrone.Api.System.Backup
{
private readonly IBackupService _backupService;
public BackupModule(IBackupService backupService) : base("system/backup")
public BackupModule(IBackupService backupService)
: base("system/backup")
{
_backupService = backupService;
GetResourceAll = GetBackupFiles;

View File

@ -1,6 +1,6 @@
using System;
using Radarr.Http.REST;
using NzbDrone.Core.Backup;
using Radarr.Http.REST;
namespace NzbDrone.Api.System.Backup
{

View File

@ -25,7 +25,8 @@ namespace NzbDrone.Api.System
IRouteCacheProvider routeCacheProvider,
IConfigFileProvider configFileProvider,
IMainDatabase database,
ILifecycleService lifecycleService) : base("system")
ILifecycleService lifecycleService)
: base("system")
{
_appFolderInfo = appFolderInfo;
_runtimeInfo = runtimeInfo;

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Radarr.Http.REST;
using NzbDrone.Core.Tags;
using Radarr.Http.REST;
namespace NzbDrone.Api.Tags
{
@ -14,7 +14,10 @@ namespace NzbDrone.Api.Tags
{
public static TagResource ToResource(this Tag model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new TagResource
{
@ -26,7 +29,10 @@ namespace NzbDrone.Api.Tags
public static Tag ToModel(this TagResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new Tag
{

View File

@ -2,8 +2,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Radarr.Http.REST;
using NzbDrone.Core.Update;
using Radarr.Http.REST;
namespace NzbDrone.Api.Update
{
@ -27,7 +27,10 @@ namespace NzbDrone.Api.Update
{
public static UpdateResource ToResource(this UpdatePackage model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new UpdateResource
{
@ -37,6 +40,7 @@ namespace NzbDrone.Api.Update
ReleaseDate = model.ReleaseDate,
FileName = model.FileName,
Url = model.Url,
//Installed
//Installable
//Latest

View File

@ -3,9 +3,10 @@ using Nancy;
namespace NzbDrone.Api.Wanted
{
class LegacyMissingModule : NzbDroneApiModule
public class LegacyMissingModule : NzbDroneApiModule
{
public LegacyMissingModule() : base("missing")
public LegacyMissingModule()
: base("missing")
{
Get("/", x =>
{

View File

@ -1,10 +1,10 @@
using System.Linq;
using NzbDrone.Api.Movies;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Movies;
using NzbDrone.SignalR;
using Radarr.Http;
using NzbDrone.Core.DecisionEngine.Specifications;
namespace NzbDrone.Api.Wanted
{

View File

@ -1,14 +1,14 @@
using System.Linq;
using NzbDrone.Api.Movies;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Datastore;
using NzbDrone.SignalR;
using Radarr.Http;
namespace NzbDrone.Api.Wanted
{
class MovieMissingModule : MovieModuleWithSignalR
public class MovieMissingModule : MovieModuleWithSignalR
{
public MovieMissingModule(IMovieService movieService,
IUpgradableSpecification qualityUpgradableSpecification,

View File

@ -37,6 +37,7 @@ namespace NzbDrone.Automation.Test
var options = new FirefoxOptions();
options.AddArguments("--headless");
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService();
// service.Host = "::1"; // Workaround netcore/selenium bug https://github.com/SeleniumHQ/selenium/issues/7840
driver = new FirefoxDriver(service, options, new System.TimeSpan(0, 3, 0));

Some files were not shown because too many files have changed in this diff Show More