* Stylecop Rules and Fixes
This commit is contained in:
Qstick 2020-01-03 07:49:24 -05:00
parent a602611a5f
commit a4b78b44ce
1307 changed files with 8702 additions and 7403 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

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

View File

@ -1,6 +1,7 @@
<Project>
<!-- Common to all Lidarr Projects -->
<PropertyGroup>
<CodeAnalysisRuleSet>$(SolutionDir)Stylecop.ruleset</CodeAnalysisRuleSet>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<PlatformTarget>AnyCPU</PlatformTarget>
@ -92,6 +93,16 @@
</PackageReference>
</ItemGroup>
<!-- Set up stylecop -->
<ItemGroup Condition="'$(LidarrProject)'=='true'">
<!-- StyleCop analysis -->
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<AdditionalFiles Include="$(SolutionDir)stylecop.json" />
</ItemGroup>
<!--
Set runtime identifier to local system type if not specified
-->

View File

@ -1,7 +1,7 @@
using System.Linq;
using Lidarr.Http.Extensions;
using Nancy;
using NzbDrone.Core.Music;
using Lidarr.Http.Extensions;
namespace Lidarr.Api.V1.AlbumStudio
{
@ -15,7 +15,7 @@ namespace Lidarr.Api.V1.AlbumStudio
{
_artistService = artistService;
_albumMonitoredService = albumMonitoredService;
Post("/", artist => UpdateAll());
Post("/", artist => UpdateAll());
}
private object UpdateAll()

View File

@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Lidarr.Http;
using Nancy;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource;
using Lidarr.Http;
using Lidarr.Http.Extensions;
namespace Lidarr.Api.V1.Albums
{
@ -17,7 +15,7 @@ namespace Lidarr.Api.V1.Albums
: base("/album/lookup")
{
_searchProxy = searchProxy;
Get("/", x => Search());
Get("/", x => Search());
}
private object Search()

View File

@ -1,23 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FluentValidation;
using Lidarr.Http.Extensions;
using Nancy;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.ArtistStats;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Music;
using NzbDrone.SignalR;
using Lidarr.Http.Extensions;
using NzbDrone.Core.ArtistStats;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Download;
using NzbDrone.Core.Music.Events;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Validation.Paths;
using FluentValidation;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Music;
using NzbDrone.Core.Music.Events;
using NzbDrone.Core.Validation;
using NzbDrone.Core.Validation.Paths;
using NzbDrone.SignalR;
namespace Lidarr.Api.V1.Albums
{
@ -28,7 +28,6 @@ namespace Lidarr.Api.V1.Albums
IHandle<AlbumImportedEvent>,
IHandle<TrackImportedEvent>,
IHandle<TrackFileDeletedEvent>
{
protected readonly IReleaseService _releaseService;
protected readonly IAddAlbumService _addAlbumService;
@ -52,7 +51,7 @@ namespace Lidarr.Api.V1.Albums
CreateResource = AddAlbum;
UpdateResource = UpdateAlbum;
DeleteResource = DeleteAlbum;
Put("/monitor", x => SetAlbumsMonitored());
Put("/monitor", x => SetAlbumsMonitored());
PostValidator.RuleFor(s => s.ForeignAlbumId).NotEmpty();
PostValidator.RuleFor(s => s.Artist.QualityProfileId).SetValidator(profileExistsValidator);
@ -156,7 +155,7 @@ namespace Lidarr.Api.V1.Albums
BroadcastResourceChange(ModelAction.Updated, resource);
}
}
public void Handle(AlbumEditedEvent message)
{
BroadcastResourceChange(ModelAction.Updated, MapToResource(message.Album, true));
@ -184,7 +183,10 @@ namespace Lidarr.Api.V1.Albums
public void Handle(TrackFileDeletedEvent message)
{
if (message.Reason == DeleteMediaFileReason.Upgrade) return;
if (message.Reason == DeleteMediaFileReason.Upgrade)
{
return;
}
BroadcastResourceChange(ModelAction.Updated, MapToResource(message.TrackFile.Album.Value, true));
}

View File

@ -1,13 +1,13 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common.Extensions;
using Lidarr.Api.V1.Artist;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Music;
using NzbDrone.Core.ArtistStats;
using NzbDrone.SignalR;
using Lidarr.Http;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.ArtistStats;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.Music;
using NzbDrone.SignalR;
namespace Lidarr.Api.V1.Albums
{
@ -90,7 +90,7 @@ namespace Lidarr.Api.V1.Albums
resource.Artist = artist.ToResource();
}
}
var artistStats = _artistStatisticsService.ArtistStatistics();
LinkArtistStatistics(result, artistStats);
MapCoversToLocal(result.ToArray());
@ -119,7 +119,6 @@ namespace Lidarr.Api.V1.Albums
var dictAlbumStats = artistStatistics.AlbumStatistics.ToDictionary(v => v.AlbumId);
resource.Statistics = dictAlbumStats.GetValueOrDefault(resource.Id).ToResource();
}
}

View File

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Music;
@ -27,6 +26,7 @@ namespace Lidarr.Api.V1.Albums
return Media.Where(s => s.MediumNumber > 0).Count();
}
}
public string Disambiguation { get; set; }
public List<string> Country { get; set; }
public List<string> Label { get; set; }
@ -62,7 +62,6 @@ namespace Lidarr.Api.V1.Albums
.GroupBy(x => x.Format)
.Select(g => MediaFormatHelper(g.Key, g.Count()))
.ToList())
};
}
@ -92,7 +91,7 @@ namespace Lidarr.Api.V1.Albums
private static string MediaFormatHelper(string name, int count)
{
return count == 1 ? name : string.Join("x", new List<string> {count.ToString(), name});
return count == 1 ? name : string.Join("x", new List<string> { count.ToString(), name });
}
public static List<AlbumReleaseResource> ToResource(this IEnumerable<AlbumRelease> models)

View File

@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using NzbDrone.Core.Music;
using Lidarr.Api.V1.Artist;
using Lidarr.Http.REST;
using Newtonsoft.Json;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.Music;
namespace Lidarr.Api.V1.Albums
{
@ -34,6 +34,7 @@ namespace Lidarr.Api.V1.Albums
return Media.Where(s => s.MediumNumber > 0).Count();
}
}
public Ratings Ratings { get; set; }
public DateTime? ReleaseDate { get; set; }
public List<AlbumReleaseResource> Releases { get; set; }
@ -55,7 +56,10 @@ namespace Lidarr.Api.V1.Albums
{
public static AlbumResource ToResource(this Album model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
var selectedRelease = model.AlbumReleases?.Value.Where(x => x.Monitored).SingleOrDefault();
@ -86,7 +90,10 @@ namespace Lidarr.Api.V1.Albums
public static Album ToModel(this AlbumResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
var artist = resource.Artist?.ToModel() ?? new NzbDrone.Core.Music.Artist();

View File

@ -1,4 +1,3 @@
using System;
using NzbDrone.Core.ArtistStats;
namespace Lidarr.Api.V1.Albums
@ -14,9 +13,12 @@ namespace Lidarr.Api.V1.Albums
{
get
{
if (TrackCount == 0) return 0;
if (TrackCount == 0)
{
return 0;
}
return (decimal)TrackFileCount / (decimal)TrackCount * 100;
return TrackFileCount / (decimal)TrackCount * 100;
}
}
}
@ -25,7 +27,10 @@ namespace Lidarr.Api.V1.Albums
{
public static AlbumStatisticsResource ToResource(this AlbumStatistics model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new AlbumStatisticsResource
{

View File

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
namespace Lidarr.Api.V1.Albums

View File

@ -1,11 +1,11 @@
using System.Collections.Generic;
using System.Linq;
using Lidarr.Http.Extensions;
using Nancy;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Music;
using NzbDrone.Core.Music.Commands;
using Lidarr.Http.Extensions;
namespace Lidarr.Api.V1.Artist
{
@ -19,8 +19,8 @@ namespace Lidarr.Api.V1.Artist
{
_artistService = artistService;
_commandQueueManager = commandQueueManager;
Put("/", artist => SaveAll());
Delete("/", artist => DeleteArtist());
Put("/", artist => SaveAll());
Delete("/", artist => DeleteArtist());
}
private object SaveAll()
@ -59,7 +59,6 @@ namespace Lidarr.Api.V1.Artist
ArtistId = artist.Id,
SourcePath = artist.Path
});
}
if (resource.Tags != null)
@ -92,8 +91,8 @@ namespace Lidarr.Api.V1.Artist
}
return ResponseWithCode(_artistService.UpdateArtists(artistToUpdate, !resource.MoveFiles)
.ToResource()
, HttpStatusCode.Accepted);
.ToResource(),
HttpStatusCode.Accepted);
}
private object DeleteArtist()

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using NzbDrone.Core.Music;
namespace Lidarr.Api.V1.Artist
{

View File

@ -1,8 +1,8 @@
using System.Collections.Generic;
using Nancy;
using NzbDrone.Core.Music;
using Lidarr.Http;
using Lidarr.Http.Extensions;
using Nancy;
using NzbDrone.Core.Music;
namespace Lidarr.Api.V1.Artist
{
@ -14,10 +14,9 @@ namespace Lidarr.Api.V1.Artist
: base("/artist/import")
{
_addArtistService = addArtistService;
Post("/", x => Import());
Post("/", x => Import());
}
private object Import()
{
var resource = Request.Body.FromJson<List<ArtistResource>>();

View File

@ -1,10 +1,9 @@
using System.Collections.Generic;
using System.Linq;
using Lidarr.Http;
using Nancy;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource;
using Lidarr.Http;
using Lidarr.Http.Extensions;
namespace Lidarr.Api.V1.Artist
{
@ -16,7 +15,7 @@ namespace Lidarr.Api.V1.Artist
: base("/artist/lookup")
{
_searchProxy = searchProxy;
Get("/", x => Search());
Get("/", x => Search());
}
private object Search()

View File

@ -1,38 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FluentValidation;
using Lidarr.Http;
using Lidarr.Http.Extensions;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.ArtistStats;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.RootFolders;
using NzbDrone.Core.ArtistStats;
using NzbDrone.Core.Music;
using NzbDrone.Core.Music.Commands;
using NzbDrone.Core.Music.Events;
using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Validation;
using NzbDrone.Core.Validation.Paths;
using Lidarr.Api.V1.Albums;
using NzbDrone.SignalR;
using Lidarr.Http;
using Lidarr.Http.Extensions;
namespace Lidarr.Api.V1.Artist
{
public class ArtistModule : LidarrRestModuleWithSignalR<ArtistResource, NzbDrone.Core.Music.Artist>,
public class ArtistModule : LidarrRestModuleWithSignalR<ArtistResource, NzbDrone.Core.Music.Artist>,
IHandle<AlbumImportedEvent>,
IHandle<AlbumEditedEvent>,
IHandle<TrackFileDeletedEvent>,
IHandle<ArtistUpdatedEvent>,
IHandle<ArtistEditedEvent>,
IHandle<ArtistUpdatedEvent>,
IHandle<ArtistEditedEvent>,
IHandle<ArtistDeletedEvent>,
IHandle<ArtistRenamedEvent>,
IHandle<MediaCoversUpdatedEvent>
{
private readonly IArtistService _artistService;
private readonly IAlbumService _albumService;
@ -57,8 +54,7 @@ namespace Lidarr.Api.V1.Artist
ArtistAncestorValidator artistAncestorValidator,
SystemFolderValidator systemFolderValidator,
ProfileExistsValidator profileExistsValidator,
MetadataProfileExistsValidator metadataProfileExistsValidator
)
MetadataProfileExistsValidator metadataProfileExistsValidator)
: base(signalRBroadcaster)
{
_artistService = artistService;
@ -108,12 +104,16 @@ namespace Lidarr.Api.V1.Artist
private ArtistResource GetArtistResource(NzbDrone.Core.Music.Artist artist)
{
if (artist == null) return null;
if (artist == null)
{
return null;
}
var resource = artist.ToResource();
MapCoversToLocal(resource);
FetchAndLinkArtistStatistics(resource);
LinkNextPreviousAlbums(resource);
//PopulateAlternateTitles(resource);
LinkRootFolderPath(resource);
@ -128,8 +128,8 @@ namespace Lidarr.Api.V1.Artist
MapCoversToLocal(artistsResources.ToArray());
LinkNextPreviousAlbums(artistsResources.ToArray());
LinkArtistStatistics(artistsResources, artistStats);
//PopulateAlternateTitles(seriesResources);
//PopulateAlternateTitles(seriesResources);
return artistsResources;
}
@ -204,7 +204,10 @@ namespace Lidarr.Api.V1.Artist
foreach (var artist in resources)
{
var stats = artistStatistics.SingleOrDefault(ss => ss.ArtistId == artist.Id);
if (stats == null) continue;
if (stats == null)
{
continue;
}
LinkArtistStatistics(artist, stats);
}
@ -231,7 +234,6 @@ namespace Lidarr.Api.V1.Artist
// resource.AlternateTitles = mappings.Select(v => new AlternateTitleResource { Title = v.Title, SeasonNumber = v.SeasonNumber, SceneSeasonNumber = v.SceneSeasonNumber }).ToList();
//}
private void LinkRootFolderPath(ArtistResource resource)
{
resource.RootFolderPath = _rootFolderService.GetBestRootFolderPath(resource.Path);
@ -249,7 +251,10 @@ namespace Lidarr.Api.V1.Artist
public void Handle(TrackFileDeletedEvent message)
{
if (message.Reason == DeleteMediaFileReason.Upgrade) return;
if (message.Reason == DeleteMediaFileReason.Upgrade)
{
return;
}
BroadcastResourceChange(ModelAction.Updated, GetArtistResource(message.TrackFile.Artist.Value));
}

View File

@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Lidarr.Http.REST;
using Newtonsoft.Json;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.Music;
using Lidarr.Http.REST;
using Newtonsoft.Json;
namespace Lidarr.Api.V1.Artist
{
@ -14,7 +14,6 @@ namespace Lidarr.Api.V1.Artist
//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
[JsonIgnore]
public int ArtistMetadataId { get; set; }
public ArtistStatusType Status { get; set; }
@ -33,7 +32,7 @@ namespace Lidarr.Api.V1.Artist
public string ArtistType { get; set; }
public string Disambiguation { get; set; }
public List<Links> Links { get; set; }
public Album NextAlbum { get; set; }
public Album LastAlbum { get; set; }
@ -42,7 +41,6 @@ namespace Lidarr.Api.V1.Artist
public string RemotePoster { get; set; }
//View & Edit
public string Path { get; set; }
public int QualityProfileId { get; set; }
@ -68,7 +66,10 @@ namespace Lidarr.Api.V1.Artist
{
public static ArtistResource ToResource(this NzbDrone.Core.Music.Artist model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new ArtistResource
{
@ -76,6 +77,7 @@ namespace Lidarr.Api.V1.Artist
ArtistMetadataId = model.ArtistMetadataId,
ArtistName = model.Name,
//AlternateTitles
SortName = model.SortName,
@ -98,6 +100,7 @@ namespace Lidarr.Api.V1.Artist
CleanName = model.CleanName,
ForeignArtistId = model.Metadata.Value.ForeignArtistId,
// Root folder path is now calculated from the artist path
// RootFolderPath = model.RootFolderPath,
Genres = model.Metadata.Value.Genres,
@ -112,7 +115,10 @@ namespace Lidarr.Api.V1.Artist
public static NzbDrone.Core.Music.Artist ToModel(this ArtistResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new NzbDrone.Core.Music.Artist
{
@ -130,14 +136,13 @@ namespace Lidarr.Api.V1.Artist
Ratings = resource.Ratings,
Type = resource.ArtistType
},
//AlternateTitles
SortName = resource.SortName,
Path = resource.Path,
QualityProfileId = resource.QualityProfileId,
MetadataProfileId = resource.MetadataProfileId,
AlbumFolder = resource.AlbumFolder,
Monitored = resource.Monitored,
@ -148,7 +153,6 @@ namespace Lidarr.Api.V1.Artist
Tags = resource.Tags,
Added = resource.Added,
AddOptions = resource.AddOptions,
};
}

View File

@ -1,4 +1,3 @@
using System;
using NzbDrone.Core.ArtistStats;
namespace Lidarr.Api.V1.Artist
@ -15,9 +14,12 @@ namespace Lidarr.Api.V1.Artist
{
get
{
if (TrackCount == 0) return 0;
if (TrackCount == 0)
{
return 0;
}
return (decimal)TrackFileCount / (decimal)TrackCount * 100;
return TrackFileCount / (decimal)TrackCount * 100;
}
}
}
@ -26,7 +28,10 @@ namespace Lidarr.Api.V1.Artist
{
public static ArtistStatisticsResource ToResource(this ArtistStatistics model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new ArtistStatisticsResource
{

View File

@ -1,6 +1,6 @@
using Lidarr.Http;
using NzbDrone.Core.Blacklisting;
using NzbDrone.Core.Datastore;
using Lidarr.Http;
namespace Lidarr.Api.V1.Blacklist
{

View File

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

View File

@ -2,15 +2,15 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Ical.Net;
using Ical.Net.CalendarComponents;
using Ical.Net.DataTypes;
using Ical.Net.Serialization;
using Lidarr.Http.Extensions;
using Nancy;
using Nancy.Responses;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Tags;
using NzbDrone.Core.Music;
using Lidarr.Http.Extensions;
using Ical.Net.CalendarComponents;
using NzbDrone.Core.Tags;
namespace Lidarr.Api.V1.Calendar
{
@ -27,13 +27,13 @@ namespace Lidarr.Api.V1.Calendar
_artistService = artistService;
_tagService = tagService;
Get("/Lidarr.ics", options => GetCalendarFeed());
Get("/Lidarr.ics", options => GetCalendarFeed());
}
private object GetCalendarFeed()
{
var pastDays = 7;
var futureDays = 28;
var futureDays = 28;
var start = DateTime.Today.AddDays(-pastDays);
var end = DateTime.Today.AddDays(futureDays);
var unmonitored = Request.GetBooleanQueryParameter("unmonitored");
@ -82,6 +82,7 @@ namespace Lidarr.Api.V1.Calendar
var occurrence = calendar.Create<CalendarEvent>();
occurrence.Uid = "Lidarr_album_" + album.Id;
//occurrence.Status = album.HasFile ? EventStatus.Confirmed : EventStatus.Tentative;
occurrence.Description = album.Overview;
occurrence.Categories = album.Genres;

View File

@ -1,13 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Music;
using NzbDrone.Core.ArtistStats;
using NzbDrone.SignalR;
using Lidarr.Api.V1.Albums;
using Lidarr.Http.Extensions;
using NzbDrone.Core.ArtistStats;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.Music;
using NzbDrone.SignalR;
namespace Lidarr.Api.V1.Calendar
{
@ -36,8 +36,15 @@ namespace Lidarr.Api.V1.Calendar
var queryStart = Request.Query.Start;
var queryEnd = Request.Query.End;
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);
}
var resources = MapToResource(_albumService.AlbumsBetweenDates(start, end, includeUnmonitored), includeArtist);

View File

@ -1,6 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Lidarr.Http;
using Lidarr.Http.Extensions;
using Lidarr.Http.Validation;
using NzbDrone.Common;
using NzbDrone.Common.TPL;
using NzbDrone.Core.Datastore.Events;
@ -8,9 +11,6 @@ using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.ProgressMessaging;
using NzbDrone.SignalR;
using Lidarr.Http;
using Lidarr.Http.Extensions;
using Lidarr.Http.Validation;
namespace Lidarr.Api.V1.Commands
{
@ -48,7 +48,7 @@ namespace Lidarr.Api.V1.Commands
private int StartCommand(CommandResource commandResource)
{
var commandType =
_serviceFactory.GetImplementations(typeof (Command))
_serviceFactory.GetImplementations(typeof(Command))
.Single(c => c.Name.Replace("Command", "")
.Equals(commandResource.Name, StringComparison.InvariantCultureIgnoreCase));

View File

@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Lidarr.Http.REST;
using Newtonsoft.Json;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Messaging.Commands;
using Lidarr.Http.REST;
namespace Lidarr.Api.V1.Commands
{
@ -30,37 +30,51 @@ namespace Lidarr.Api.V1.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.SendUpdatesToClient;
if (Body != null)
{
return Body.SendUpdatesToClient;
}
return false;
}
set { }
set
{
}
}
public bool UpdateScheduledTask
{
get
{
if (Body != null) return Body.UpdateScheduledTask;
if (Body != null)
{
return Body.UpdateScheduledTask;
}
return false;
}
set { }
set
{
}
}
public DateTime? LastExecutionTime { get; set; }
@ -70,7 +84,10 @@ namespace Lidarr.Api.V1.Commands
{
public static CommandResource ToResource(this CommandModel model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new CommandResource
{

View File

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

View File

@ -2,13 +2,13 @@ using System.IO;
using System.Linq;
using System.Reflection;
using FluentValidation;
using Lidarr.Http;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Authentication;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Update;
using NzbDrone.Core.Validation;
using NzbDrone.Core.Validation.Paths;
using Lidarr.Http;
namespace Lidarr.Api.V1.Config
{
@ -51,7 +51,6 @@ namespace Lidarr.Api.V1.Config
SharedValidator.RuleFor(c => c.BackupFolder).IsValidPath().When(c => Path.IsPathRooted(c.BackupFolder));
SharedValidator.RuleFor(c => c.BackupInterval).InclusiveBetween(1, 7);
SharedValidator.RuleFor(c => c.BackupRetention).InclusiveBetween(1, 90);
}
private HostConfigResource GetHostConfig()

View File

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

View File

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

View File

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

View File

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

View File

@ -21,4 +21,4 @@ namespace Lidarr.Api.V1.Config
return MediaManagementConfigResourceMapper.ToResource(model);
}
}
}
}

View File

@ -1,6 +1,6 @@
using Lidarr.Http.REST;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles;
using Lidarr.Http.REST;
using NzbDrone.Core.Qualities;
namespace Lidarr.Api.V1.Config

View File

@ -1,10 +1,6 @@
using System;
using System.Linq;
using System.Reflection;
using FluentValidation;
using NzbDrone.Core.Configuration;
using Lidarr.Http;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Validation;
namespace Lidarr.Api.V1.Config

View File

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

View File

@ -2,13 +2,10 @@ using System.Collections.Generic;
using System.Linq;
using FluentValidation;
using FluentValidation.Results;
using Lidarr.Http;
using Nancy.ModelBinding;
using Nancy.Responses;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Organizer;
using Lidarr.Http;
using Lidarr.Http.Extensions;
using Lidarr.Http.Mapping;
namespace Lidarr.Api.V1.Config
{
@ -33,8 +30,7 @@ namespace Lidarr.Api.V1.Config
GetResourceById = GetNamingConfig;
UpdateResource = UpdateNamingConfig;
Get("/examples", x => GetExamples(this.Bind<NamingConfigResource>()));
Get("/examples", x => GetExamples(this.Bind<NamingConfigResource>()));
SharedValidator.RuleFor(c => c.StandardTrackFormat).ValidTrackFormat();
SharedValidator.RuleFor(c => c.MultiDiscTrackFormat).ValidTrackFormat();
@ -84,7 +80,7 @@ namespace Lidarr.Api.V1.Config
var nameSpec = config.ToModel();
var sampleResource = new NamingExampleResource();
var singleTrackSampleResult = _filenameSampleService.GetStandardTrackSample(nameSpec);
var multiDiscTrackSampleResult = _filenameSampleService.GetMultiDiscTrackSample(nameSpec);

View File

@ -1,7 +1,4 @@
using System.Linq;
using System.Reflection;
using NzbDrone.Core.Configuration;
using Lidarr.Http;
using NzbDrone.Core.Configuration;
namespace Lidarr.Api.V1.Config
{
@ -10,7 +7,6 @@ namespace Lidarr.Api.V1.Config
public UiConfigModule(IConfigService configService)
: base(configService)
{
}
protected override UiConfigResource ToResource(IConfigService model)
@ -18,4 +14,4 @@ namespace Lidarr.Api.V1.Config
return UiConfigResourceMapper.ToResource(model);
}
}
}
}

View File

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

View File

@ -1,6 +1,6 @@
using System.Collections.Generic;
using NzbDrone.Core.CustomFilters;
using Lidarr.Http;
using NzbDrone.Core.CustomFilters;
namespace Lidarr.Api.V1.CustomFilters
{

View File

@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using Lidarr.Http.REST;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.CustomFilters;
using Lidarr.Http.REST;
namespace Lidarr.Api.V1.CustomFilters
{
@ -17,28 +17,34 @@ namespace Lidarr.Api.V1.CustomFilters
{
public static CustomFilterResource ToResource(this CustomFilter model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new CustomFilterResource
{
Id = model.Id,
Type = model.Type,
Label = model.Label,
Filters = Json.Deserialize<List<dynamic>>(model.Filters)
};
{
Id = model.Id,
Type = model.Type,
Label = model.Label,
Filters = Json.Deserialize<List<dynamic>>(model.Filters)
};
}
public static CustomFilter ToModel(this CustomFilterResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new CustomFilter
{
Id = resource.Id,
Type = resource.Type,
Label = resource.Label,
Filters = Json.ToJson(resource.Filters)
};
{
Id = resource.Id,
Type = resource.Type,
Label = resource.Label,
Filters = Json.ToJson(resource.Filters)
};
}
public static List<CustomFilterResource> ToResource(this IEnumerable<CustomFilter> filters)

View File

@ -1,15 +1,15 @@
using System.Collections.Generic;
using NzbDrone.Core.DiskSpace;
using Lidarr.Http;
using NzbDrone.Core.DiskSpace;
namespace Lidarr.Api.V1.DiskSpace
{
public class DiskSpaceModule :LidarrRestModule<DiskSpaceResource>
public class DiskSpaceModule : LidarrRestModule<DiskSpaceResource>
{
private readonly IDiskSpaceService _diskSpaceService;
public DiskSpaceModule(IDiskSpaceService diskSpaceService)
:base("diskspace")
: base("diskspace")
{
_diskSpaceService = diskSpaceService;
GetResourceAll = GetFreeSpace;

View File

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

View File

@ -13,8 +13,12 @@ namespace Lidarr.Api.V1.DownloadClient
protected override void Validate(DownloadClientDefinition definition, bool includeWarnings)
{
if (!definition.Enable) return;
if (!definition.Enable)
{
return;
}
base.Validate(definition, includeWarnings);
}
}
}
}

View File

@ -14,7 +14,10 @@ namespace Lidarr.Api.V1.DownloadClient
{
public override DownloadClientResource ToResource(DownloadClientDefinition definition)
{
if (definition == null) return null;
if (definition == null)
{
return null;
}
var resource = base.ToResource(definition);
@ -27,7 +30,10 @@ namespace Lidarr.Api.V1.DownloadClient
public override DownloadClientDefinition ToModel(DownloadClientResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
var definition = base.ToModel(resource);
@ -38,4 +44,4 @@ namespace Lidarr.Api.V1.DownloadClient
return definition;
}
}
}
}

View File

@ -1,12 +1,9 @@
using System;
using System.IO;
using System.IO.Abstractions;
using System.Linq;
using Lidarr.Http.Extensions;
using Nancy;
using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.MediaFiles;
using Lidarr.Http.Extensions;
namespace Lidarr.Api.V1.FileSystem
{
@ -24,9 +21,9 @@ namespace Lidarr.Api.V1.FileSystem
_fileSystemLookupService = fileSystemLookupService;
_diskProvider = diskProvider;
_diskScanService = diskScanService;
Get("/", x => GetContents());
Get("/type", x => GetEntityType());
Get("/mediafiles", x => GetMediaFiles());
Get("/", x => GetContents());
Get("/type", x => GetEntityType());
Get("/mediafiles", x => GetMediaFiles());
}
private object GetContents()
@ -62,7 +59,8 @@ namespace Lidarr.Api.V1.FileSystem
return new string[0];
}
return _diskScanService.GetAudioFiles(path).Select(f => new {
return _diskScanService.GetAudioFiles(path).Select(f => new
{
Path = f.FullName,
RelativePath = path.GetRelativePath(f.FullName),
Name = f.Name

View File

@ -1,9 +1,9 @@
using System.Collections.Generic;
using Lidarr.Http;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.HealthCheck;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.SignalR;
using Lidarr.Http;
namespace Lidarr.Api.V1.Health
{
@ -29,4 +29,4 @@ namespace Lidarr.Api.V1.Health
BroadcastResourceChange(ModelAction.Sync);
}
}
}
}

View File

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

View File

@ -1,17 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Nancy;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Download;
using NzbDrone.Core.History;
using Lidarr.Api.V1.Albums;
using Lidarr.Api.V1.Artist;
using Lidarr.Api.V1.Tracks;
using Lidarr.Http;
using Lidarr.Http.Extensions;
using Lidarr.Http.REST;
using Nancy;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Download;
using NzbDrone.Core.History;
namespace Lidarr.Api.V1.History
{
@ -30,9 +30,9 @@ namespace Lidarr.Api.V1.History
_failedDownloadService = failedDownloadService;
GetResourcePaged = GetHistory;
Get("/since", x => GetHistorySince());
Get("/artist", x => GetArtistHistory());
Post("/failed", x => MarkAsFailed());
Get("/since", x => GetHistorySince());
Get("/artist", x => GetArtistHistory());
Post("/failed", x => MarkAsFailed());
}
protected HistoryResource MapToResource(NzbDrone.Core.History.History model, bool includeArtist, bool includeAlbum, bool includeTrack)
@ -43,15 +43,16 @@ namespace Lidarr.Api.V1.History
{
resource.Artist = model.Artist.ToResource();
}
if (includeAlbum)
{
resource.Album = model.Album.ToResource();
}
if (includeTrack)
{
resource.Track = model.Track.ToResource();
}
if (model.Artist != null)
{
@ -90,7 +91,6 @@ namespace Lidarr.Api.V1.History
pagingSpec.FilterExpressions.Add(h => h.DownloadId == downloadId);
}
return ApplyToPage(_historyService.Paged, pagingSpec, h => MapToResource(h, includeArtist, includeAlbum, includeTrack));
}

View File

@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using NzbDrone.Core.History;
using NzbDrone.Core.Qualities;
using Lidarr.Api.V1.Albums;
using Lidarr.Api.V1.Artist;
using Lidarr.Api.V1.Tracks;
using Lidarr.Http.REST;
using NzbDrone.Core.History;
using NzbDrone.Core.Qualities;
namespace Lidarr.Api.V1.History
{
@ -33,7 +33,10 @@ namespace Lidarr.Api.V1.History
{
public static HistoryResource ToResource(this NzbDrone.Core.History.History model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new HistoryResource
{
@ -44,6 +47,7 @@ namespace Lidarr.Api.V1.History
TrackId = model.TrackId,
SourceTitle = model.SourceTitle,
Quality = model.Quality,
//QualityCutoffNotMet
Date = model.Date,
DownloadId = model.DownloadId,
@ -51,6 +55,7 @@ namespace Lidarr.Api.V1.History
EventType = model.EventType,
Data = model.Data
//Episode
//Series
};

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using NzbDrone.Core.ImportLists.Exclusions;
using Lidarr.Http;
using FluentValidation;
using Lidarr.Http;
using NzbDrone.Core.ImportLists.Exclusions;
using NzbDrone.Core.Validation;
namespace Lidarr.Api.V1.ImportLists

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.ImportLists.Exclusions;
using Lidarr.Http.REST;
using NzbDrone.Core.ImportLists.Exclusions;
namespace Lidarr.Api.V1.ImportLists
{
@ -15,7 +15,10 @@ namespace Lidarr.Api.V1.ImportLists
{
public static ImportListExclusionResource ToResource(this ImportListExclusion model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new ImportListExclusionResource
{
@ -27,7 +30,10 @@ namespace Lidarr.Api.V1.ImportLists
public static ImportListExclusion ToModel(this ImportListExclusionResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new ImportListExclusion
{

View File

@ -10,8 +10,7 @@ namespace Lidarr.Api.V1.ImportLists
public ImportListModule(ImportListFactory importListFactory,
ProfileExistsValidator profileExistsValidator,
MetadataProfileExistsValidator metadataProfileExistsValidator
)
MetadataProfileExistsValidator metadataProfileExistsValidator)
: base(importListFactory, "importlist", ResourceMapper)
{
Http.Validation.RuleBuilderExtensions.ValidId(SharedValidator.RuleFor(s => s.QualityProfileId));
@ -28,6 +27,7 @@ namespace Lidarr.Api.V1.ImportLists
{
return;
}
base.Validate(definition, includeWarnings);
}
}

View File

@ -23,14 +23,14 @@ namespace Lidarr.Api.V1.ImportLists
}
var resource = base.ToResource(definition);
resource.EnableAutomaticAdd = definition.EnableAutomaticAdd;
resource.ShouldMonitor = definition.ShouldMonitor;
resource.RootFolderPath = definition.RootFolderPath;
resource.QualityProfileId = definition.ProfileId;
resource.MetadataProfileId = definition.MetadataProfileId;
resource.ListType = definition.ListType;
resource.ListOrder = (int) definition.ListType;
resource.ListOrder = (int)definition.ListType;
return resource;
}
@ -43,7 +43,7 @@ namespace Lidarr.Api.V1.ImportLists
}
var definition = base.ToModel(resource);
definition.EnableAutomaticAdd = resource.EnableAutomaticAdd;
definition.ShouldMonitor = resource.ShouldMonitor;
definition.RootFolderPath = resource.RootFolderPath;

View File

@ -13,8 +13,12 @@ namespace Lidarr.Api.V1.Indexers
protected override void Validate(IndexerDefinition definition, bool includeWarnings)
{
if (!definition.Enable) return;
if (!definition.Enable)
{
return;
}
base.Validate(definition, includeWarnings);
}
}
}
}

View File

@ -16,7 +16,10 @@ namespace Lidarr.Api.V1.Indexers
{
public override IndexerResource ToResource(IndexerDefinition definition)
{
if (definition == null) return null;
if (definition == null)
{
return null;
}
var resource = base.ToResource(definition);
@ -32,7 +35,10 @@ namespace Lidarr.Api.V1.Indexers
public override IndexerDefinition ToModel(IndexerResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
var definition = base.ToModel(resource);

View File

@ -11,7 +11,6 @@ using NzbDrone.Core.Indexers;
using NzbDrone.Core.IndexerSearch;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Validation;
using Lidarr.Http.Extensions;
using HttpStatusCode = System.Net.HttpStatusCode;
namespace Lidarr.Api.V1.Indexers
@ -43,7 +42,7 @@ namespace Lidarr.Api.V1.Indexers
_logger = logger;
GetResourceAll = GetReleases;
Post("/", x => DownloadRelease(ReadResourceFromRequest()));
Post("/", x => DownloadRelease(ReadResourceFromRequest()));
PostValidator.RuleFor(s => s.IndexerId).ValidId();
PostValidator.RuleFor(s => s.Guid).NotEmpty();

View File

@ -1,6 +1,6 @@
using System.Collections.Generic;
using NzbDrone.Core.DecisionEngine;
using Lidarr.Http;
using NzbDrone.Core.DecisionEngine;
namespace Lidarr.Api.V1.Indexers
{

View File

@ -2,19 +2,17 @@ using System.Collections.Generic;
using System.Linq;
using FluentValidation;
using FluentValidation.Results;
using Nancy;
using NLog;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.Parser.Model;
using Lidarr.Http.Extensions;
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 Lidarr.Api.V1.Indexers
{
class ReleasePushModule : ReleaseModuleBase
internal class ReleasePushModule : ReleaseModuleBase
{
private readonly IMakeDownloadDecision _downloadDecisionMaker;
private readonly IProcessDownloadDecisions _downloadDecisionProcessor;
@ -31,7 +29,7 @@ namespace Lidarr.Api.V1.Indexers
_indexerFactory = indexerFactory;
_logger = logger;
Post("/push", x => ProcessRelease(ReadResourceFromRequest()));
Post("/push", x => ProcessRelease(ReadResourceFromRequest()));
PostValidator.RuleFor(s => s.Title).NotEmpty();
PostValidator.RuleFor(s => s.DownloadUrl).NotEmpty();

View File

@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Lidarr.Http.REST;
using Newtonsoft.Json;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities;
using Lidarr.Http.REST;
namespace Lidarr.Api.V1.Indexers
{
@ -49,12 +49,13 @@ namespace Lidarr.Api.V1.Indexers
public DownloadProtocol Protocol { get; set; }
// Sent when queuing an unknown release
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
// [JsonIgnore]
public int? ArtistId { get; set; }
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
// [JsonIgnore]
public int? AlbumId { get; set; }
}
@ -73,6 +74,7 @@ namespace Lidarr.Api.V1.Indexers
{
Guid = releaseInfo.Guid,
Quality = parsedAlbumInfo.Quality,
//QualityWeight
Age = releaseInfo.Age,
AgeHours = releaseInfo.AgeHours,
@ -95,17 +97,16 @@ namespace Lidarr.Api.V1.Indexers
DownloadUrl = releaseInfo.DownloadUrl,
InfoUrl = releaseInfo.InfoUrl,
DownloadAllowed = remoteAlbum.DownloadAllowed,
//ReleaseWeight
PreferredWordScore = remoteAlbum.PreferredWordScore,
MagnetUrl = torrentInfo.MagnetUrl,
InfoHash = torrentInfo.InfoHash,
Seeders = torrentInfo.Seeders,
Leechers = (torrentInfo.Peers.HasValue && torrentInfo.Seeders.HasValue) ? (torrentInfo.Peers.Value - torrentInfo.Seeders.Value) : (int?)null,
Protocol = releaseInfo.DownloadProtocol,
};
};
}
public static ReleaseInfo ToModel(this ReleaseResource resource)

View File

@ -38,6 +38,5 @@ namespace Lidarr.Api.V1.Logs
return "logfile";
}
}
}
}
}

View File

@ -1,12 +1,12 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Lidarr.Http;
using Nancy;
using Nancy.Responses;
using NLog;
using NzbDrone.Common.Disk;
using NzbDrone.Core.Configuration;
using Lidarr.Http;
using NLog;
namespace Lidarr.Api.V1.Logs
{
@ -26,7 +26,7 @@ namespace Lidarr.Api.V1.Logs
_configFileProvider = configFileProvider;
GetResourceAll = GetLogFilesResponse;
Get(LOGFILE_ROUTE, options => GetLogFileResponse(options.filename));
Get(LOGFILE_ROUTE, options => GetLogFileResponse(options.filename));
}
private List<LogFileResource> GetLogFilesResponse()
@ -39,7 +39,7 @@ namespace Lidarr.Api.V1.Logs
{
var file = files[i];
var filename = Path.GetFileName(file);
result.Add(new LogFileResource
{
Id = i + 1,
@ -60,10 +60,12 @@ namespace Lidarr.Api.V1.Logs
var filePath = GetLogFilePath(filename);
if (!_diskProvider.FileExists(filePath))
{
return new NotFoundResponse();
}
var data = _diskProvider.ReadAllText(filePath);
return new TextResponse(data);
}

View File

@ -1,6 +1,6 @@
using System.Linq;
using NzbDrone.Core.Instrumentation;
using Lidarr.Http;
using NzbDrone.Core.Instrumentation;
namespace Lidarr.Api.V1.Logs
{

View File

@ -1,6 +1,6 @@
using System;
using NzbDrone.Core.Instrumentation;
using Lidarr.Http.REST;
using NzbDrone.Core.Instrumentation;
namespace Lidarr.Api.V1.Logs
{
@ -19,7 +19,10 @@ namespace Lidarr.Api.V1.Logs
{
public static LogResource ToResource(this Log model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new LogResource
{

View File

@ -25,7 +25,10 @@ namespace Lidarr.Api.V1.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))
@ -45,4 +48,4 @@ namespace Lidarr.Api.V1.Logs
}
}
}
}
}

View File

@ -1,13 +1,13 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.MediaFiles.TrackImport.Manual;
using NzbDrone.Core.Qualities;
using Lidarr.Http.Extensions;
using NzbDrone.Core.Music;
using NLog;
using Nancy;
using Lidarr.Http;
using Lidarr.Http.Extensions;
using Nancy;
using NLog;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.TrackImport.Manual;
using NzbDrone.Core.Music;
using NzbDrone.Core.Qualities;
namespace Lidarr.Api.V1.ManualImport
{
@ -32,7 +32,7 @@ namespace Lidarr.Api.V1.ManualImport
_logger = logger;
GetResourceAll = GetMediaFiles;
Put("/", options =>
{
var resource = Request.Body.FromJson<List<ManualImportResource>>();
@ -58,7 +58,7 @@ namespace Lidarr.Api.V1.ManualImport
item.QualityWeight += item.Quality.Revision.Real * 10;
item.QualityWeight += item.Quality.Revision.Version;
}
return item;
}
@ -67,23 +67,24 @@ namespace Lidarr.Api.V1.ManualImport
var items = new List<ManualImportItem>();
foreach (var resource in resources)
{
items.Add(new ManualImportItem {
Id = resource.Id,
Path = resource.Path,
RelativePath = resource.RelativePath,
Name = resource.Name,
Size = resource.Size,
Artist = resource.Artist == null ? null : _artistService.GetArtist(resource.Artist.Id),
Album = resource.Album == null ? null : _albumService.GetAlbum(resource.Album.Id),
Release = resource.AlbumReleaseId == 0 ? null : _releaseService.GetRelease(resource.AlbumReleaseId),
Quality = resource.Quality,
DownloadId = resource.DownloadId,
AdditionalFile = resource.AdditionalFile,
ReplaceExistingFiles = resource.ReplaceExistingFiles,
DisableReleaseSwitching = resource.DisableReleaseSwitching
});
items.Add(new ManualImportItem
{
Id = resource.Id,
Path = resource.Path,
RelativePath = resource.RelativePath,
Name = resource.Name,
Size = resource.Size,
Artist = resource.Artist == null ? null : _artistService.GetArtist(resource.Artist.Id),
Album = resource.Album == null ? null : _albumService.GetAlbum(resource.Album.Id),
Release = resource.AlbumReleaseId == 0 ? null : _releaseService.GetRelease(resource.AlbumReleaseId),
Quality = resource.Quality,
DownloadId = resource.DownloadId,
AdditionalFile = resource.AdditionalFile,
ReplaceExistingFiles = resource.ReplaceExistingFiles,
DisableReleaseSwitching = resource.DisableReleaseSwitching
});
}
return _manualImportService.UpdateItems(items).Select(x => x.ToResource()).ToList();
}
}

View File

@ -1,13 +1,13 @@
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.MediaFiles.TrackImport.Manual;
using NzbDrone.Core.Qualities;
using Lidarr.Api.V1.Artist;
using Lidarr.Api.V1.Albums;
using Lidarr.Api.V1.Tracks;
using Lidarr.Http.REST;
using System.Collections.Generic;
using System.Linq;
using Lidarr.Api.V1.Albums;
using Lidarr.Api.V1.Artist;
using Lidarr.Api.V1.Tracks;
using Lidarr.Http.REST;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.MediaFiles.TrackImport.Manual;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities;
namespace Lidarr.Api.V1.ManualImport
{
@ -35,7 +35,10 @@ namespace Lidarr.Api.V1.ManualImport
{
public static ManualImportResource ToResource(this ManualImportItem model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new ManualImportResource
{
@ -49,6 +52,7 @@ namespace Lidarr.Api.V1.ManualImport
AlbumReleaseId = model.Release?.Id ?? 0,
Tracks = model.Tracks.ToResource(),
Quality = model.Quality,
//QualityWeight
DownloadId = model.DownloadId,
Rejections = model.Rejections,

View File

@ -10,21 +10,22 @@ namespace Lidarr.Api.V1.MediaCovers
{
public class MediaCoverModule : LidarrV1Module
{
private static readonly Regex RegexResizedImage = new Regex(@"-\d+(?=\.(jpg|png|gif)$)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private const string MEDIA_COVER_ARTIST_ROUTE = @"/Artist/(?<artistId>\d+)/(?<filename>(.+)\.(jpg|png|gif))";
private const string MEDIA_COVER_ALBUM_ROUTE = @"/Album/(?<artistId>\d+)/(?<filename>(.+)\.(jpg|png|gif))";
private static readonly Regex RegexResizedImage = new Regex(@"-\d+(?=\.(jpg|png|gif)$)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
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;
Get(MEDIA_COVER_ARTIST_ROUTE, options => GetArtistMediaCover(options.artistId, options.filename));
Get(MEDIA_COVER_ALBUM_ROUTE, options => GetAlbumMediaCover(options.artistId, options.filename));
Get(MEDIA_COVER_ARTIST_ROUTE, options => GetArtistMediaCover(options.artistId, options.filename));
Get(MEDIA_COVER_ALBUM_ROUTE, options => GetAlbumMediaCover(options.artistId, options.filename));
}
private object GetArtistMediaCover(int artistId, string filename)
@ -40,6 +41,7 @@ namespace Lidarr.Api.V1.MediaCovers
{
return new NotFoundResponse();
}
filePath = basefilePath;
}
@ -59,6 +61,7 @@ namespace Lidarr.Api.V1.MediaCovers
{
return new NotFoundResponse();
}
filePath = basefilePath;
}

View File

@ -13,8 +13,12 @@ namespace Lidarr.Api.V1.Metadata
protected override void Validate(MetadataDefinition definition, bool includeWarnings)
{
if (!definition.Enable) return;
if (!definition.Enable)
{
return;
}
base.Validate(definition, includeWarnings);
}
}
}
}

View File

@ -11,7 +11,10 @@ namespace Lidarr.Api.V1.Metadata
{
public override MetadataResource ToResource(MetadataDefinition definition)
{
if (definition == null) return null;
if (definition == null)
{
return null;
}
var resource = base.ToResource(definition);
@ -22,7 +25,10 @@ namespace Lidarr.Api.V1.Metadata
public override MetadataDefinition ToModel(MetadataResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
var definition = base.ToModel(resource);
@ -31,4 +37,4 @@ namespace Lidarr.Api.V1.Metadata
return definition;
}
}
}
}

View File

@ -13,7 +13,11 @@ namespace Lidarr.Api.V1.Notifications
protected override void Validate(NotificationDefinition definition, bool includeWarnings)
{
if (!definition.Enable) return;
if (!definition.Enable)
{
return;
}
base.Validate(definition, includeWarnings);
}
}

View File

@ -29,7 +29,10 @@ namespace Lidarr.Api.V1.Notifications
{
public override NotificationResource ToResource(NotificationDefinition definition)
{
if (definition == null) return default(NotificationResource);
if (definition == null)
{
return default(NotificationResource);
}
var resource = base.ToResource(definition);
@ -56,7 +59,10 @@ namespace Lidarr.Api.V1.Notifications
public override NotificationDefinition ToModel(NotificationResource resource)
{
if (resource == null) return default(NotificationDefinition);
if (resource == null)
{
return default(NotificationDefinition);
}
var definition = base.ToModel(resource);

View File

@ -1,8 +1,7 @@
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Parser;
using Lidarr.Api.V1.Albums;
using Lidarr.Api.V1.Artist;
using Lidarr.Http;
using NzbDrone.Core.Parser;
namespace Lidarr.Api.V1.Parse
{

View File

@ -1,8 +1,8 @@
using System.Collections.Generic;
using NzbDrone.Core.Parser.Model;
using Lidarr.Api.V1.Albums;
using Lidarr.Api.V1.Artist;
using Lidarr.Http.REST;
using NzbDrone.Core.Parser.Model;
namespace Lidarr.Api.V1.Parse
{

View File

@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
using FluentValidation;
using FluentValidation.Results;
using Nancy;
using NzbDrone.Core.Profiles.Delay;
using Lidarr.Http;
using Lidarr.Http.Extensions;
using Lidarr.Http.REST;
using Lidarr.Http.Validation;
using Nancy;
using NzbDrone.Core.Profiles.Delay;
namespace Lidarr.Api.V1.Profiles.Delay
{
@ -24,7 +22,7 @@ namespace Lidarr.Api.V1.Profiles.Delay
UpdateResource = Update;
CreateResource = Create;
DeleteResource = DeleteProfile;
Put(@"/reorder/(?<id>[\d]{1,10})", options => Reorder(options.Id));
Put(@"/reorder/(?<id>[\d]{1,10})", options => Reorder(options.Id));
SharedValidator.RuleFor(d => d.Tags).NotEmpty().When(d => d.Id != 1);
SharedValidator.RuleFor(d => d.Tags).EmptyCollection<DelayProfileResource, int>().When(d => d.Id == 1);
@ -85,4 +83,4 @@ namespace Lidarr.Api.V1.Profiles.Delay
return _delayProfileService.Reorder(id, afterId).ToResource();
}
}
}
}

View File

@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using Lidarr.Http.REST;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Profiles.Delay;
using Lidarr.Http.REST;
namespace Lidarr.Api.V1.Profiles.Delay
{
@ -21,7 +21,10 @@ namespace Lidarr.Api.V1.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 Lidarr.Api.V1.Profiles.Delay
public static DelayProfile ToModel(this DelayProfileResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new DelayProfile
{

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using FluentValidation;
using NzbDrone.Core.Profiles.Metadata;
using Lidarr.Http;
using NzbDrone.Core.Profiles.Metadata;
namespace Lidarr.Api.V1.Profiles.Metadata
{

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Profiles.Metadata;
using Lidarr.Http.REST;
using NzbDrone.Core.Profiles.Metadata;
namespace Lidarr.Api.V1.Profiles.Metadata
{
@ -35,7 +35,10 @@ namespace Lidarr.Api.V1.Profiles.Metadata
{
public static MetadataProfileResource ToResource(this MetadataProfile model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new MetadataProfileResource
{
@ -49,7 +52,10 @@ namespace Lidarr.Api.V1.Profiles.Metadata
public static ProfilePrimaryAlbumTypeItemResource ToResource(this ProfilePrimaryAlbumTypeItem model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new ProfilePrimaryAlbumTypeItemResource
{
@ -105,7 +111,10 @@ namespace Lidarr.Api.V1.Profiles.Metadata
public static ProfilePrimaryAlbumTypeItem ToModel(this ProfilePrimaryAlbumTypeItemResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new ProfilePrimaryAlbumTypeItem
{
@ -116,10 +125,13 @@ namespace Lidarr.Api.V1.Profiles.Metadata
public static ProfileSecondaryAlbumTypeItem ToModel(this ProfileSecondaryAlbumTypeItemResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new ProfileSecondaryAlbumTypeItem
{
{
SecondaryAlbumType = (NzbDrone.Core.Music.SecondaryAlbumType)resource.AlbumType.Id,
Allowed = resource.Allowed
};
@ -127,7 +139,10 @@ namespace Lidarr.Api.V1.Profiles.Metadata
public static ProfileReleaseStatusItem ToModel(this ProfileReleaseStatusItemResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new ProfileReleaseStatusItem
{
@ -136,7 +151,7 @@ namespace Lidarr.Api.V1.Profiles.Metadata
};
}
public static List<MetadataProfileResource> ToResource(this IEnumerable<MetadataProfile> models)
public static List<MetadataProfileResource> ToResource(this IEnumerable<MetadataProfile> models)
{
return models.Select(ToResource).ToList();
}

View File

@ -1,12 +1,11 @@
using System.Linq;
using NzbDrone.Core.Profiles.Metadata;
using Lidarr.Http;
using NzbDrone.Core.Profiles.Metadata;
namespace Lidarr.Api.V1.Profiles.Metadata
{
public class MetadataProfileSchemaModule : LidarrRestModule<MetadataProfileResource>
{
public MetadataProfileSchemaModule()
: base("/metadataprofile/schema")
{
@ -28,23 +27,23 @@ namespace Lidarr.Api.V1.Profiles.Metadata
.ToList();
var primTypes = orderedPrimTypes
.Select(v => new ProfilePrimaryAlbumTypeItem {PrimaryAlbumType = v, Allowed = false})
.Select(v => new ProfilePrimaryAlbumTypeItem { PrimaryAlbumType = v, Allowed = false })
.ToList();
var secTypes = orderedSecTypes
.Select(v => new ProfileSecondaryAlbumTypeItem {SecondaryAlbumType = v, Allowed = false})
.Select(v => new ProfileSecondaryAlbumTypeItem { SecondaryAlbumType = v, Allowed = false })
.ToList();
var relStatuses = orderedRelStatuses
.Select(v => new ProfileReleaseStatusItem {ReleaseStatus = v, Allowed = false})
.Select(v => new ProfileReleaseStatusItem { ReleaseStatus = v, Allowed = false })
.ToList();
var profile = new MetadataProfile
{
PrimaryAlbumTypes = primTypes,
SecondaryAlbumTypes = secTypes,
ReleaseStatuses = relStatuses
};
{
PrimaryAlbumTypes = primTypes,
SecondaryAlbumTypes = secTypes,
ReleaseStatuses = relStatuses
};
return profile.ToResource();
}

View File

@ -29,7 +29,6 @@ namespace Lidarr.Api.V1.Profiles.Metadata
}
}
public class PrimaryTypeValidator<T> : PropertyValidator
{
public PrimaryTypeValidator()

View File

@ -18,7 +18,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
public ValidCutoffValidator()
: base("Cutoff must be an allowed quality or group")
{
}
protected override bool IsValid(PropertyValidatorContext context)

View File

@ -26,7 +26,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
public AllowedValidator()
: base("Must contain at least one allowed quality")
{
}
protected override bool IsValid(PropertyValidatorContext context)
@ -52,7 +51,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
public GroupItemValidator()
: base("Groups must contain multiple qualities")
{
}
protected override bool IsValid(PropertyValidatorContext context)
@ -73,7 +71,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
public QualityNameValidator()
: base("Individual qualities should not be named")
{
}
protected override bool IsValid(PropertyValidatorContext context)
@ -94,7 +91,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
public ItemGroupNameValidator()
: base("Groups must have a name")
{
}
protected override bool IsValid(PropertyValidatorContext context)
@ -115,7 +111,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
public ItemGroupIdValidator()
: base("Groups must have an ID")
{
}
protected override bool IsValid(PropertyValidatorContext context)
@ -136,7 +131,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
public UniqueIdValidator()
: base("Groups must have a unique ID")
{
}
protected override bool IsValid(PropertyValidatorContext context)
@ -157,7 +151,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
public UniqueQualityIdValidator()
: base("Qualities can only be used once")
{
}
protected override bool IsValid(PropertyValidatorContext context)
@ -179,7 +172,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
qualityIds.Add(quality.Quality.Id);
}
}
else
{
if (qualityIds.Contains(item.Quality.Id))

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using FluentValidation;
using NzbDrone.Core.Profiles.Qualities;
using Lidarr.Http;
using NzbDrone.Core.Profiles.Qualities;
namespace Lidarr.Api.V1.Profiles.Quality
{

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Profiles.Qualities;
using Lidarr.Http.REST;
using NzbDrone.Core.Profiles.Qualities;
namespace Lidarr.Api.V1.Profiles.Quality
{
@ -30,7 +30,10 @@ namespace Lidarr.Api.V1.Profiles.Quality
{
public static QualityProfileResource ToResource(this QualityProfile model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new QualityProfileResource
{
@ -44,7 +47,10 @@ namespace Lidarr.Api.V1.Profiles.Quality
public static QualityProfileQualityItemResource ToResource(this QualityProfileQualityItem model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new QualityProfileQualityItemResource
{
@ -58,7 +64,10 @@ namespace Lidarr.Api.V1.Profiles.Quality
public static QualityProfile ToModel(this QualityProfileResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new QualityProfile
{
@ -72,7 +81,10 @@ namespace Lidarr.Api.V1.Profiles.Quality
public static QualityProfileQualityItem ToModel(this QualityProfileQualityItemResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new QualityProfileQualityItem
{

View File

@ -1,5 +1,5 @@
using NzbDrone.Core.Profiles.Qualities;
using Lidarr.Http;
using NzbDrone.Core.Profiles.Qualities;
namespace Lidarr.Api.V1.Profiles.Quality
{
@ -18,7 +18,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
{
QualityProfile qualityProfile = _profileService.GetDefaultProfile(string.Empty);
return qualityProfile.ToResource();
}
}

View File

@ -1,8 +1,8 @@
using System.Collections.Generic;
using FluentValidation;
using Lidarr.Http;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Profiles.Releases;
using Lidarr.Http;
namespace Lidarr.Api.V1.Profiles.Release
{
@ -10,7 +10,6 @@ namespace Lidarr.Api.V1.Profiles.Release
{
private readonly IReleaseProfileService _releaseProfileService;
public ReleaseProfileModule(IReleaseProfileService releaseProfileService)
{
_releaseProfileService = releaseProfileService;

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Profiles.Releases;
using Lidarr.Http.REST;
using NzbDrone.Core.Profiles.Releases;
namespace Lidarr.Api.V1.Profiles.Release
{
@ -23,7 +23,10 @@ namespace Lidarr.Api.V1.Profiles.Release
{
public static ReleaseProfileResource ToResource(this ReleaseProfile model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new ReleaseProfileResource
{
@ -39,7 +42,10 @@ namespace Lidarr.Api.V1.Profiles.Release
public static ReleaseProfile ToModel(this ReleaseProfileResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new ReleaseProfile
{

View File

@ -2,13 +2,11 @@ using System.Collections.Generic;
using System.Linq;
using FluentValidation;
using FluentValidation.Results;
using Lidarr.Http;
using Nancy;
using Newtonsoft.Json;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
using Lidarr.Http;
using Lidarr.Http.Extensions;
namespace Lidarr.Api.V1
{
@ -26,10 +24,10 @@ namespace Lidarr.Api.V1
_providerFactory = providerFactory;
_resourceMapper = resourceMapper;
Get("schema", x => GetTemplates());
Post("test", x => Test(ReadResourceFromRequest(true)));
Post("testall", x => TestAll());
Post("action/{action}", x => RequestAction(x.action, ReadResourceFromRequest(true)));
Get("schema", x => GetTemplates());
Post("test", x => Test(ReadResourceFromRequest(true)));
Post("testall", x => TestAll());
Post("action/{action}", x => RequestAction(x.action, ReadResourceFromRequest(true)));
GetResourceAll = GetAll;
GetResourceById = GetProviderById;
@ -38,7 +36,7 @@ namespace Lidarr.Api.V1
DeleteResource = DeleteProvider;
SharedValidator.RuleFor(c => c.Name).NotEmpty();
SharedValidator.RuleFor(c => c.Name).Must((v,c) => !_providerFactory.All().Any(p => p.Name == c && p.Id != v.Id)).WithMessage("Should be unique");
SharedValidator.RuleFor(c => c.Name).Must((v, c) => !_providerFactory.All().Any(p => p.Name == c && p.Id != v.Id)).WithMessage("Should be unique");
SharedValidator.RuleFor(c => c.Implementation).NotEmpty();
SharedValidator.RuleFor(c => c.ConfigContract).NotEmpty();

View File

@ -1,8 +1,8 @@
using System.Collections.Generic;
using NzbDrone.Common.Reflection;
using NzbDrone.Core.ThingiProvider;
using Lidarr.Http.ClientSchema;
using Lidarr.Http.REST;
using NzbDrone.Common.Reflection;
using NzbDrone.Core.ThingiProvider;
namespace Lidarr.Api.V1
{
@ -25,7 +25,6 @@ namespace Lidarr.Api.V1
where TProviderDefinition : ProviderDefinition, new()
{
public virtual TProviderResource ToResource(TProviderDefinition definition)
{
return new TProviderResource
{
@ -47,7 +46,10 @@ namespace Lidarr.Api.V1
public virtual TProviderDefinition ToModel(TProviderResource resource)
{
if (resource == null) return default(TProviderDefinition);
if (resource == null)
{
return default(TProviderDefinition);
}
var definition = new TProviderDefinition
{

View File

@ -1,9 +1,9 @@
using System.Collections.Generic;
using System.Linq;
using Nancy;
using NzbDrone.Core.Qualities;
using Lidarr.Http;
using Lidarr.Http.Extensions;
using Nancy;
using NzbDrone.Core.Qualities;
namespace Lidarr.Api.V1.Qualities
{
@ -18,7 +18,7 @@ namespace Lidarr.Api.V1.Qualities
GetResourceAll = GetAll;
GetResourceById = GetById;
UpdateResource = Update;
Put("/update", d => UpdateMany());
Put("/update", d => UpdateMany());
}
private void Update(QualityDefinitionResource resource)
@ -47,8 +47,8 @@ namespace Lidarr.Api.V1.Qualities
_qualityDefinitionService.UpdateMany(qualityDefinitions);
return ResponseWithCode(_qualityDefinitionService.All()
.ToResource()
, HttpStatusCode.Accepted);
.ToResource(),
HttpStatusCode.Accepted);
}
}
}
}

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Qualities;
using Lidarr.Http.REST;
using NzbDrone.Core.Qualities;
namespace Lidarr.Api.V1.Qualities
{
@ -21,7 +21,10 @@ namespace Lidarr.Api.V1.Qualities
{
public static QualityDefinitionResource ToResource(this QualityDefinition model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new QualityDefinitionResource
{
@ -36,7 +39,10 @@ namespace Lidarr.Api.V1.Qualities
public static QualityDefinition ToModel(this QualityDefinitionResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new QualityDefinition
{
@ -59,4 +65,4 @@ namespace Lidarr.Api.V1.Qualities
return resources.Select(ToModel).ToList();
}
}
}
}

View File

@ -1,13 +1,12 @@
using System;
using System.Collections.Generic;
using Lidarr.Http;
using Lidarr.Http.Extensions;
using Lidarr.Http.REST;
using Nancy;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Pending;
using NzbDrone.Core.Download.TrackedDownloads;
using NzbDrone.Core.Queue;
using Lidarr.Http;
using Lidarr.Http.Extensions;
using Lidarr.Http.REST;
namespace Lidarr.Api.V1.Queue
{
@ -34,11 +33,11 @@ namespace Lidarr.Api.V1.Queue
_pendingReleaseService = pendingReleaseService;
_downloadService = downloadService;
Post(@"/grab/(?<id>[\d]{1,10})", x => Grab((int)x.Id));
Post("/grab/bulk", x => Grab());
Post(@"/grab/(?<id>[\d]{1,10})", x => Grab((int)x.Id));
Post("/grab/bulk", x => Grab());
Delete(@"/(?<id>[\d]{1,10})", x => Remove((int)x.Id));
Delete("/bulk", x => Remove());
Delete(@"/(?<id>[\d]{1,10})", x => Remove((int)x.Id));
Delete("/bulk", x => Remove());
}
private object Grab(int id)

View File

@ -1,13 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Lidarr.Http;
using Lidarr.Http.Extensions;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.Download.Pending;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Queue;
using NzbDrone.SignalR;
using Lidarr.Http;
using Lidarr.Http.Extensions;
namespace Lidarr.Api.V1.Queue
{

View File

@ -1,7 +1,8 @@
using System;
using System.Linq;
using Lidarr.Http;
using Lidarr.Http.Extensions;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.Download.Pending;
@ -10,8 +11,6 @@ using NzbDrone.Core.Profiles.Qualities;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Queue;
using NzbDrone.SignalR;
using Lidarr.Http;
using Lidarr.Http.Extensions;
namespace Lidarr.Api.V1.Queue
{
@ -21,7 +20,7 @@ namespace Lidarr.Api.V1.Queue
private readonly IQueueService _queueService;
private readonly IPendingReleaseService _pendingReleaseService;
private readonly QualityModelComparer QUALITY_COMPARER;
private readonly QualityModelComparer _qualityComparer;
public QueueModule(IBroadcastSignalRMessage broadcastSignalRMessage,
IQueueService queueService,
@ -33,7 +32,7 @@ namespace Lidarr.Api.V1.Queue
_pendingReleaseService = pendingReleaseService;
GetResourcePaged = GetQueue;
QUALITY_COMPARER = new QualityModelComparer(qualityProfileService.GetDefaultProfile(string.Empty));
_qualityComparer = new QualityModelComparer(qualityProfileService.GetDefaultProfile(string.Empty));
}
private PagingResource<QueueResource> GetQueue(PagingResource<QueueResource> pagingResource)
@ -63,7 +62,6 @@ namespace Lidarr.Api.V1.Queue
? fullQueue.OrderBy(q => q.Timeleft, new TimeleftComparer())
: fullQueue.OrderByDescending(q => q.Timeleft, new TimeleftComparer());
}
else if (pagingSpec.SortKey == "estimatedCompletionTime")
{
ordered = ascending
@ -71,41 +69,36 @@ namespace Lidarr.Api.V1.Queue
: fullQueue.OrderByDescending(q => q.EstimatedCompletionTime,
new EstimatedCompletionTimeComparer());
}
else if (pagingSpec.SortKey == "protocol")
{
ordered = ascending
? fullQueue.OrderBy(q => q.Protocol)
: fullQueue.OrderByDescending(q => q.Protocol);
}
else if (pagingSpec.SortKey == "indexer")
{
ordered = ascending
? fullQueue.OrderBy(q => q.Indexer, StringComparer.InvariantCultureIgnoreCase)
: fullQueue.OrderByDescending(q => q.Indexer, StringComparer.InvariantCultureIgnoreCase);
}
else if (pagingSpec.SortKey == "downloadClient")
{
ordered = ascending
? fullQueue.OrderBy(q => q.DownloadClient, StringComparer.InvariantCultureIgnoreCase)
: fullQueue.OrderByDescending(q => q.DownloadClient, StringComparer.InvariantCultureIgnoreCase);
}
else if (pagingSpec.SortKey == "quality")
{
ordered = ascending
? fullQueue.OrderBy(q => q.Quality, QUALITY_COMPARER)
: fullQueue.OrderByDescending(q => q.Quality, QUALITY_COMPARER);
? fullQueue.OrderBy(q => q.Quality, _qualityComparer)
: fullQueue.OrderByDescending(q => q.Quality, _qualityComparer);
}
else
{
ordered = ascending ? fullQueue.OrderBy(orderByFunc) : fullQueue.OrderByDescending(orderByFunc);
}
ordered = ordered.ThenByDescending(q => q.Size == 0 ? 0 : 100 - q.Sizeleft / q.Size * 100);
ordered = ordered.ThenByDescending(q => q.Size == 0 ? 0 : 100 - (q.Sizeleft / q.Size * 100));
pagingSpec.Records = ordered.Skip((pagingSpec.Page - 1) * pagingSpec.PageSize).Take(pagingSpec.PageSize).ToList();
pagingSpec.TotalRecords = fullQueue.Count;
@ -119,7 +112,7 @@ namespace Lidarr.Api.V1.Queue
return pagingSpec;
}
private Func<NzbDrone.Core.Queue.Queue, Object> GetOrderByFunc(PagingSpec<NzbDrone.Core.Queue.Queue> pagingSpec)
private Func<NzbDrone.Core.Queue.Queue, object> GetOrderByFunc(PagingSpec<NzbDrone.Core.Queue.Queue> pagingSpec)
{
switch (pagingSpec.SortKey)
{
@ -139,7 +132,7 @@ namespace Lidarr.Api.V1.Queue
return q => q.Quality;
case "progress":
// Avoid exploding if a download's size is 0
return q => 100 - q.Sizeleft / Math.Max(q.Size * 100, 1);
return q => 100 - (q.Sizeleft / Math.Max(q.Size * 100, 1));
default:
return q => q.Timeleft;
}

View File

@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Download.TrackedDownloads;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Qualities;
using Lidarr.Api.V1.Albums;
using Lidarr.Api.V1.Artist;
using Lidarr.Http.REST;
using NzbDrone.Core.Download.TrackedDownloads;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Qualities;
namespace Lidarr.Api.V1.Queue
{
@ -38,7 +38,10 @@ namespace Lidarr.Api.V1.Queue
{
public static QueueResource ToResource(this NzbDrone.Core.Queue.Queue model, bool includeArtist, bool includeAlbum)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new QueueResource
{

View File

@ -1,12 +1,12 @@
using System;
using System.Linq;
using Lidarr.Http;
using NzbDrone.Common.TPL;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.Download.Pending;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Queue;
using NzbDrone.SignalR;
using Lidarr.Http;
namespace Lidarr.Api.V1.Queue
{
@ -17,7 +17,6 @@ namespace Lidarr.Api.V1.Queue
private readonly IPendingReleaseService _pendingReleaseService;
private readonly Debouncer _broadcastDebounce;
public QueueStatusModule(IBroadcastSignalRMessage broadcastSignalRMessage, IQueueService queueService, IPendingReleaseService pendingReleaseService)
: base(broadcastSignalRMessage, "queue/status")
{
@ -26,8 +25,7 @@ namespace Lidarr.Api.V1.Queue
_broadcastDebounce = new Debouncer(BroadcastChange, TimeSpan.FromSeconds(5));
Get("/", x => GetQueueStatusResponse());
Get("/", x => GetQueueStatusResponse());
}
private object GetQueueStatusResponse()
@ -67,12 +65,10 @@ namespace Lidarr.Api.V1.Queue
{
_broadcastDebounce.Execute();
}
public void Handle(PendingReleasesUpdatedEvent message)
{
_broadcastDebounce.Execute();
}
}
}

View File

@ -1,8 +1,8 @@
using System.Collections.Generic;
using FluentValidation;
using Lidarr.Http;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.Validation.Paths;
using Lidarr.Http;
namespace Lidarr.Api.V1.RemotePathMappings
{
@ -65,4 +65,4 @@ namespace Lidarr.Api.V1.RemotePathMappings
_remotePathMappingService.Update(mapping);
}
}
}
}

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.RemotePathMappings;
using Lidarr.Http.REST;
using NzbDrone.Core.RemotePathMappings;
namespace Lidarr.Api.V1.RemotePathMappings
{
@ -16,7 +16,10 @@ namespace Lidarr.Api.V1.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 Lidarr.Api.V1.RemotePathMappings
public static RemotePathMapping ToModel(this RemotePathMappingResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new RemotePathMapping
{

View File

@ -1,9 +1,9 @@
using System.Collections.Generic;
using FluentValidation;
using Lidarr.Http;
using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Validation.Paths;
using NzbDrone.SignalR;
using Lidarr.Http;
namespace Lidarr.Api.V1.RootFolders
{
@ -18,8 +18,7 @@ namespace Lidarr.Api.V1.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 NzbDrone.Core.RootFolders;
using Lidarr.Http.REST;
using NzbDrone.Core.RootFolders;
namespace Lidarr.Api.V1.RootFolders
{
@ -19,7 +19,10 @@ namespace Lidarr.Api.V1.RootFolders
{
public static RootFolderResource ToResource(this RootFolder model)
{
if (model == null) return null;
if (model == null)
{
return null;
}
return new RootFolderResource
{
@ -35,13 +38,17 @@ namespace Lidarr.Api.V1.RootFolders
public static RootFolder ToModel(this RootFolderResource resource)
{
if (resource == null) return null;
if (resource == null)
{
return null;
}
return new RootFolder
{
Id = resource.Id,
Path = resource.Path,
//Accessible
//FreeSpace
//UnmappedFolders

View File

@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Lidarr.Api.V1.Albums;
using Lidarr.Api.V1.Artist;
using Lidarr.Http;
using Nancy;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource;
using Lidarr.Http;
using Lidarr.Api.V1.Artist;
using Lidarr.Api.V1.Albums;
using System;
namespace Lidarr.Api.V1.Search
{
@ -27,7 +27,7 @@ namespace Lidarr.Api.V1.Search
return MapToResource(searchResults).ToList();
}
private static IEnumerable<SearchResource> MapToResource(IEnumerable<Object> results)
private static IEnumerable<SearchResource> MapToResource(IEnumerable<object> results)
{
int id = 1;
foreach (var result in results)
@ -37,7 +37,7 @@ namespace Lidarr.Api.V1.Search
if (result is NzbDrone.Core.Music.Artist)
{
var artist = (NzbDrone.Core.Music.Artist) result;
var artist = (NzbDrone.Core.Music.Artist)result;
resource.Artist = artist.ToResource();
resource.ForeignId = artist.ForeignArtistId;
@ -49,7 +49,7 @@ namespace Lidarr.Api.V1.Search
}
else if (result is NzbDrone.Core.Music.Album)
{
var album = (NzbDrone.Core.Music.Album) result;
var album = (NzbDrone.Core.Music.Album)result;
resource.Album = album.ToResource();
resource.ForeignId = album.ForeignAlbumId;

View File

@ -1,6 +1,6 @@
using Lidarr.Http.REST;
using Lidarr.Api.V1.Artist;
using Lidarr.Api.V1.Albums;
using Lidarr.Api.V1.Artist;
using Lidarr.Http.REST;
namespace Lidarr.Api.V1.Search
{

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