mirror of https://github.com/lidarr/Lidarr
parent
a602611a5f
commit
a4b78b44ce
|
@ -9,6 +9,35 @@ insert_final_newline = true
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 4
|
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}]
|
[*.{js,html,js,hbs,less,css}]
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
|
|
@ -84,7 +84,6 @@ TestResults
|
||||||
[Tt]est[Rr]esult*
|
[Tt]est[Rr]esult*
|
||||||
*.Cache
|
*.Cache
|
||||||
ClientBin
|
ClientBin
|
||||||
[Ss]tyle[Cc]op.*
|
|
||||||
~$*
|
~$*
|
||||||
*.dbmdl
|
*.dbmdl
|
||||||
Generated_Code #added for RIA/Silverlight projects
|
Generated_Code #added for RIA/Silverlight projects
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<Project>
|
<Project>
|
||||||
<!-- Common to all Lidarr Projects -->
|
<!-- Common to all Lidarr Projects -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
<CodeAnalysisRuleSet>$(SolutionDir)Stylecop.ruleset</CodeAnalysisRuleSet>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
|
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
@ -92,6 +93,16 @@
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</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
|
Set runtime identifier to local system type if not specified
|
||||||
-->
|
-->
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Lidarr.Http.Extensions;
|
||||||
using Nancy;
|
using Nancy;
|
||||||
using NzbDrone.Core.Music;
|
using NzbDrone.Core.Music;
|
||||||
using Lidarr.Http.Extensions;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.AlbumStudio
|
namespace Lidarr.Api.V1.AlbumStudio
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@ namespace Lidarr.Api.V1.AlbumStudio
|
||||||
{
|
{
|
||||||
_artistService = artistService;
|
_artistService = artistService;
|
||||||
_albumMonitoredService = albumMonitoredService;
|
_albumMonitoredService = albumMonitoredService;
|
||||||
Post("/", artist => UpdateAll());
|
Post("/", artist => UpdateAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
private object UpdateAll()
|
private object UpdateAll()
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Lidarr.Http;
|
||||||
using Nancy;
|
using Nancy;
|
||||||
using NzbDrone.Core.MediaCover;
|
using NzbDrone.Core.MediaCover;
|
||||||
using NzbDrone.Core.MetadataSource;
|
using NzbDrone.Core.MetadataSource;
|
||||||
using Lidarr.Http;
|
|
||||||
using Lidarr.Http.Extensions;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Albums
|
namespace Lidarr.Api.V1.Albums
|
||||||
{
|
{
|
||||||
|
@ -17,7 +15,7 @@ namespace Lidarr.Api.V1.Albums
|
||||||
: base("/album/lookup")
|
: base("/album/lookup")
|
||||||
{
|
{
|
||||||
_searchProxy = searchProxy;
|
_searchProxy = searchProxy;
|
||||||
Get("/", x => Search());
|
Get("/", x => Search());
|
||||||
}
|
}
|
||||||
|
|
||||||
private object Search()
|
private object Search()
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using FluentValidation;
|
||||||
|
using Lidarr.Http.Extensions;
|
||||||
using Nancy;
|
using Nancy;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
|
using NzbDrone.Core.ArtistStats;
|
||||||
using NzbDrone.Core.Datastore.Events;
|
using NzbDrone.Core.Datastore.Events;
|
||||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
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.Download;
|
||||||
using NzbDrone.Core.Music.Events;
|
|
||||||
using NzbDrone.Core.MediaFiles.Events;
|
|
||||||
using NzbDrone.Core.MediaCover;
|
using NzbDrone.Core.MediaCover;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.Validation.Paths;
|
using NzbDrone.Core.MediaFiles.Events;
|
||||||
using FluentValidation;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Core.Music;
|
||||||
|
using NzbDrone.Core.Music.Events;
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
|
using NzbDrone.Core.Validation.Paths;
|
||||||
|
using NzbDrone.SignalR;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Albums
|
namespace Lidarr.Api.V1.Albums
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,6 @@ namespace Lidarr.Api.V1.Albums
|
||||||
IHandle<AlbumImportedEvent>,
|
IHandle<AlbumImportedEvent>,
|
||||||
IHandle<TrackImportedEvent>,
|
IHandle<TrackImportedEvent>,
|
||||||
IHandle<TrackFileDeletedEvent>
|
IHandle<TrackFileDeletedEvent>
|
||||||
|
|
||||||
{
|
{
|
||||||
protected readonly IReleaseService _releaseService;
|
protected readonly IReleaseService _releaseService;
|
||||||
protected readonly IAddAlbumService _addAlbumService;
|
protected readonly IAddAlbumService _addAlbumService;
|
||||||
|
@ -52,7 +51,7 @@ namespace Lidarr.Api.V1.Albums
|
||||||
CreateResource = AddAlbum;
|
CreateResource = AddAlbum;
|
||||||
UpdateResource = UpdateAlbum;
|
UpdateResource = UpdateAlbum;
|
||||||
DeleteResource = DeleteAlbum;
|
DeleteResource = DeleteAlbum;
|
||||||
Put("/monitor", x => SetAlbumsMonitored());
|
Put("/monitor", x => SetAlbumsMonitored());
|
||||||
|
|
||||||
PostValidator.RuleFor(s => s.ForeignAlbumId).NotEmpty();
|
PostValidator.RuleFor(s => s.ForeignAlbumId).NotEmpty();
|
||||||
PostValidator.RuleFor(s => s.Artist.QualityProfileId).SetValidator(profileExistsValidator);
|
PostValidator.RuleFor(s => s.Artist.QualityProfileId).SetValidator(profileExistsValidator);
|
||||||
|
@ -156,7 +155,7 @@ namespace Lidarr.Api.V1.Albums
|
||||||
BroadcastResourceChange(ModelAction.Updated, resource);
|
BroadcastResourceChange(ModelAction.Updated, resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Handle(AlbumEditedEvent message)
|
public void Handle(AlbumEditedEvent message)
|
||||||
{
|
{
|
||||||
BroadcastResourceChange(ModelAction.Updated, MapToResource(message.Album, true));
|
BroadcastResourceChange(ModelAction.Updated, MapToResource(message.Album, true));
|
||||||
|
@ -184,7 +183,10 @@ namespace Lidarr.Api.V1.Albums
|
||||||
|
|
||||||
public void Handle(TrackFileDeletedEvent message)
|
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));
|
BroadcastResourceChange(ModelAction.Updated, MapToResource(message.TrackFile.Album.Value, true));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Common.Extensions;
|
|
||||||
using Lidarr.Api.V1.Artist;
|
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 Lidarr.Http;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
|
using NzbDrone.Core.ArtistStats;
|
||||||
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||||
using NzbDrone.Core.MediaCover;
|
using NzbDrone.Core.MediaCover;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
|
using NzbDrone.SignalR;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Albums
|
namespace Lidarr.Api.V1.Albums
|
||||||
{
|
{
|
||||||
|
@ -90,7 +90,7 @@ namespace Lidarr.Api.V1.Albums
|
||||||
resource.Artist = artist.ToResource();
|
resource.Artist = artist.ToResource();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var artistStats = _artistStatisticsService.ArtistStatistics();
|
var artistStats = _artistStatisticsService.ArtistStatistics();
|
||||||
LinkArtistStatistics(result, artistStats);
|
LinkArtistStatistics(result, artistStats);
|
||||||
MapCoversToLocal(result.ToArray());
|
MapCoversToLocal(result.ToArray());
|
||||||
|
@ -119,7 +119,6 @@ namespace Lidarr.Api.V1.Albums
|
||||||
var dictAlbumStats = artistStatistics.AlbumStatistics.ToDictionary(v => v.AlbumId);
|
var dictAlbumStats = artistStatistics.AlbumStatistics.ToDictionary(v => v.AlbumId);
|
||||||
|
|
||||||
resource.Statistics = dictAlbumStats.GetValueOrDefault(resource.Id).ToResource();
|
resource.Statistics = dictAlbumStats.GetValueOrDefault(resource.Id).ToResource();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Core.Music;
|
using NzbDrone.Core.Music;
|
||||||
|
@ -27,6 +26,7 @@ namespace Lidarr.Api.V1.Albums
|
||||||
return Media.Where(s => s.MediumNumber > 0).Count();
|
return Media.Where(s => s.MediumNumber > 0).Count();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Disambiguation { get; set; }
|
public string Disambiguation { get; set; }
|
||||||
public List<string> Country { get; set; }
|
public List<string> Country { get; set; }
|
||||||
public List<string> Label { get; set; }
|
public List<string> Label { get; set; }
|
||||||
|
@ -62,7 +62,6 @@ namespace Lidarr.Api.V1.Albums
|
||||||
.GroupBy(x => x.Format)
|
.GroupBy(x => x.Format)
|
||||||
.Select(g => MediaFormatHelper(g.Key, g.Count()))
|
.Select(g => MediaFormatHelper(g.Key, g.Count()))
|
||||||
.ToList())
|
.ToList())
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +91,7 @@ namespace Lidarr.Api.V1.Albums
|
||||||
|
|
||||||
private static string MediaFormatHelper(string name, int count)
|
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)
|
public static List<AlbumReleaseResource> ToResource(this IEnumerable<AlbumRelease> models)
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using NzbDrone.Core.Music;
|
|
||||||
using Lidarr.Api.V1.Artist;
|
using Lidarr.Api.V1.Artist;
|
||||||
using Lidarr.Http.REST;
|
using Lidarr.Http.REST;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using NzbDrone.Core.MediaCover;
|
using NzbDrone.Core.MediaCover;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Albums
|
namespace Lidarr.Api.V1.Albums
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,7 @@ namespace Lidarr.Api.V1.Albums
|
||||||
return Media.Where(s => s.MediumNumber > 0).Count();
|
return Media.Where(s => s.MediumNumber > 0).Count();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ratings Ratings { get; set; }
|
public Ratings Ratings { get; set; }
|
||||||
public DateTime? ReleaseDate { get; set; }
|
public DateTime? ReleaseDate { get; set; }
|
||||||
public List<AlbumReleaseResource> Releases { get; set; }
|
public List<AlbumReleaseResource> Releases { get; set; }
|
||||||
|
@ -55,7 +56,10 @@ namespace Lidarr.Api.V1.Albums
|
||||||
{
|
{
|
||||||
public static AlbumResource ToResource(this Album model)
|
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();
|
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)
|
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();
|
var artist = resource.Artist?.ToModel() ?? new NzbDrone.Core.Music.Artist();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System;
|
|
||||||
using NzbDrone.Core.ArtistStats;
|
using NzbDrone.Core.ArtistStats;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Albums
|
namespace Lidarr.Api.V1.Albums
|
||||||
|
@ -14,9 +13,12 @@ namespace Lidarr.Api.V1.Albums
|
||||||
{
|
{
|
||||||
get
|
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)
|
public static AlbumStatisticsResource ToResource(this AlbumStatistics model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new AlbumStatisticsResource
|
return new AlbumStatisticsResource
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Albums
|
namespace Lidarr.Api.V1.Albums
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Lidarr.Http.Extensions;
|
||||||
using Nancy;
|
using Nancy;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Messaging.Commands;
|
using NzbDrone.Core.Messaging.Commands;
|
||||||
using NzbDrone.Core.Music;
|
using NzbDrone.Core.Music;
|
||||||
using NzbDrone.Core.Music.Commands;
|
using NzbDrone.Core.Music.Commands;
|
||||||
using Lidarr.Http.Extensions;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Artist
|
namespace Lidarr.Api.V1.Artist
|
||||||
{
|
{
|
||||||
|
@ -19,8 +19,8 @@ namespace Lidarr.Api.V1.Artist
|
||||||
{
|
{
|
||||||
_artistService = artistService;
|
_artistService = artistService;
|
||||||
_commandQueueManager = commandQueueManager;
|
_commandQueueManager = commandQueueManager;
|
||||||
Put("/", artist => SaveAll());
|
Put("/", artist => SaveAll());
|
||||||
Delete("/", artist => DeleteArtist());
|
Delete("/", artist => DeleteArtist());
|
||||||
}
|
}
|
||||||
|
|
||||||
private object SaveAll()
|
private object SaveAll()
|
||||||
|
@ -59,7 +59,6 @@ namespace Lidarr.Api.V1.Artist
|
||||||
ArtistId = artist.Id,
|
ArtistId = artist.Id,
|
||||||
SourcePath = artist.Path
|
SourcePath = artist.Path
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resource.Tags != null)
|
if (resource.Tags != null)
|
||||||
|
@ -92,8 +91,8 @@ namespace Lidarr.Api.V1.Artist
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResponseWithCode(_artistService.UpdateArtists(artistToUpdate, !resource.MoveFiles)
|
return ResponseWithCode(_artistService.UpdateArtists(artistToUpdate, !resource.MoveFiles)
|
||||||
.ToResource()
|
.ToResource(),
|
||||||
, HttpStatusCode.Accepted);
|
HttpStatusCode.Accepted);
|
||||||
}
|
}
|
||||||
|
|
||||||
private object DeleteArtist()
|
private object DeleteArtist()
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NzbDrone.Core.Music;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Artist
|
namespace Lidarr.Api.V1.Artist
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Nancy;
|
|
||||||
using NzbDrone.Core.Music;
|
|
||||||
using Lidarr.Http;
|
using Lidarr.Http;
|
||||||
using Lidarr.Http.Extensions;
|
using Lidarr.Http.Extensions;
|
||||||
|
using Nancy;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Artist
|
namespace Lidarr.Api.V1.Artist
|
||||||
{
|
{
|
||||||
|
@ -14,10 +14,9 @@ namespace Lidarr.Api.V1.Artist
|
||||||
: base("/artist/import")
|
: base("/artist/import")
|
||||||
{
|
{
|
||||||
_addArtistService = addArtistService;
|
_addArtistService = addArtistService;
|
||||||
Post("/", x => Import());
|
Post("/", x => Import());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private object Import()
|
private object Import()
|
||||||
{
|
{
|
||||||
var resource = Request.Body.FromJson<List<ArtistResource>>();
|
var resource = Request.Body.FromJson<List<ArtistResource>>();
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Lidarr.Http;
|
||||||
using Nancy;
|
using Nancy;
|
||||||
using NzbDrone.Core.MediaCover;
|
using NzbDrone.Core.MediaCover;
|
||||||
using NzbDrone.Core.MetadataSource;
|
using NzbDrone.Core.MetadataSource;
|
||||||
using Lidarr.Http;
|
|
||||||
using Lidarr.Http.Extensions;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Artist
|
namespace Lidarr.Api.V1.Artist
|
||||||
{
|
{
|
||||||
|
@ -16,7 +15,7 @@ namespace Lidarr.Api.V1.Artist
|
||||||
: base("/artist/lookup")
|
: base("/artist/lookup")
|
||||||
{
|
{
|
||||||
_searchProxy = searchProxy;
|
_searchProxy = searchProxy;
|
||||||
Get("/", x => Search());
|
Get("/", x => Search());
|
||||||
}
|
}
|
||||||
|
|
||||||
private object Search()
|
private object Search()
|
||||||
|
|
|
@ -1,38 +1,35 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
using Lidarr.Http;
|
||||||
|
using Lidarr.Http.Extensions;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
|
using NzbDrone.Core.ArtistStats;
|
||||||
using NzbDrone.Core.Datastore.Events;
|
using NzbDrone.Core.Datastore.Events;
|
||||||
using NzbDrone.Core.MediaCover;
|
using NzbDrone.Core.MediaCover;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.MediaFiles.Events;
|
using NzbDrone.Core.MediaFiles.Events;
|
||||||
using NzbDrone.Core.Messaging.Commands;
|
using NzbDrone.Core.Messaging.Commands;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
using NzbDrone.Core.RootFolders;
|
|
||||||
using NzbDrone.Core.ArtistStats;
|
|
||||||
using NzbDrone.Core.Music;
|
using NzbDrone.Core.Music;
|
||||||
using NzbDrone.Core.Music.Commands;
|
using NzbDrone.Core.Music.Commands;
|
||||||
using NzbDrone.Core.Music.Events;
|
using NzbDrone.Core.Music.Events;
|
||||||
|
using NzbDrone.Core.RootFolders;
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
using NzbDrone.Core.Validation.Paths;
|
using NzbDrone.Core.Validation.Paths;
|
||||||
using Lidarr.Api.V1.Albums;
|
|
||||||
using NzbDrone.SignalR;
|
using NzbDrone.SignalR;
|
||||||
using Lidarr.Http;
|
|
||||||
using Lidarr.Http.Extensions;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Artist
|
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<AlbumImportedEvent>,
|
||||||
IHandle<AlbumEditedEvent>,
|
IHandle<AlbumEditedEvent>,
|
||||||
IHandle<TrackFileDeletedEvent>,
|
IHandle<TrackFileDeletedEvent>,
|
||||||
IHandle<ArtistUpdatedEvent>,
|
IHandle<ArtistUpdatedEvent>,
|
||||||
IHandle<ArtistEditedEvent>,
|
IHandle<ArtistEditedEvent>,
|
||||||
IHandle<ArtistDeletedEvent>,
|
IHandle<ArtistDeletedEvent>,
|
||||||
IHandle<ArtistRenamedEvent>,
|
IHandle<ArtistRenamedEvent>,
|
||||||
IHandle<MediaCoversUpdatedEvent>
|
IHandle<MediaCoversUpdatedEvent>
|
||||||
|
|
||||||
{
|
{
|
||||||
private readonly IArtistService _artistService;
|
private readonly IArtistService _artistService;
|
||||||
private readonly IAlbumService _albumService;
|
private readonly IAlbumService _albumService;
|
||||||
|
@ -57,8 +54,7 @@ namespace Lidarr.Api.V1.Artist
|
||||||
ArtistAncestorValidator artistAncestorValidator,
|
ArtistAncestorValidator artistAncestorValidator,
|
||||||
SystemFolderValidator systemFolderValidator,
|
SystemFolderValidator systemFolderValidator,
|
||||||
ProfileExistsValidator profileExistsValidator,
|
ProfileExistsValidator profileExistsValidator,
|
||||||
MetadataProfileExistsValidator metadataProfileExistsValidator
|
MetadataProfileExistsValidator metadataProfileExistsValidator)
|
||||||
)
|
|
||||||
: base(signalRBroadcaster)
|
: base(signalRBroadcaster)
|
||||||
{
|
{
|
||||||
_artistService = artistService;
|
_artistService = artistService;
|
||||||
|
@ -108,12 +104,16 @@ namespace Lidarr.Api.V1.Artist
|
||||||
|
|
||||||
private ArtistResource GetArtistResource(NzbDrone.Core.Music.Artist artist)
|
private ArtistResource GetArtistResource(NzbDrone.Core.Music.Artist artist)
|
||||||
{
|
{
|
||||||
if (artist == null) return null;
|
if (artist == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var resource = artist.ToResource();
|
var resource = artist.ToResource();
|
||||||
MapCoversToLocal(resource);
|
MapCoversToLocal(resource);
|
||||||
FetchAndLinkArtistStatistics(resource);
|
FetchAndLinkArtistStatistics(resource);
|
||||||
LinkNextPreviousAlbums(resource);
|
LinkNextPreviousAlbums(resource);
|
||||||
|
|
||||||
//PopulateAlternateTitles(resource);
|
//PopulateAlternateTitles(resource);
|
||||||
LinkRootFolderPath(resource);
|
LinkRootFolderPath(resource);
|
||||||
|
|
||||||
|
@ -128,8 +128,8 @@ namespace Lidarr.Api.V1.Artist
|
||||||
MapCoversToLocal(artistsResources.ToArray());
|
MapCoversToLocal(artistsResources.ToArray());
|
||||||
LinkNextPreviousAlbums(artistsResources.ToArray());
|
LinkNextPreviousAlbums(artistsResources.ToArray());
|
||||||
LinkArtistStatistics(artistsResources, artistStats);
|
LinkArtistStatistics(artistsResources, artistStats);
|
||||||
//PopulateAlternateTitles(seriesResources);
|
|
||||||
|
|
||||||
|
//PopulateAlternateTitles(seriesResources);
|
||||||
return artistsResources;
|
return artistsResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +204,10 @@ namespace Lidarr.Api.V1.Artist
|
||||||
foreach (var artist in resources)
|
foreach (var artist in resources)
|
||||||
{
|
{
|
||||||
var stats = artistStatistics.SingleOrDefault(ss => ss.ArtistId == artist.Id);
|
var stats = artistStatistics.SingleOrDefault(ss => ss.ArtistId == artist.Id);
|
||||||
if (stats == null) continue;
|
if (stats == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
LinkArtistStatistics(artist, stats);
|
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();
|
// resource.AlternateTitles = mappings.Select(v => new AlternateTitleResource { Title = v.Title, SeasonNumber = v.SeasonNumber, SceneSeasonNumber = v.SceneSeasonNumber }).ToList();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
private void LinkRootFolderPath(ArtistResource resource)
|
private void LinkRootFolderPath(ArtistResource resource)
|
||||||
{
|
{
|
||||||
resource.RootFolderPath = _rootFolderService.GetBestRootFolderPath(resource.Path);
|
resource.RootFolderPath = _rootFolderService.GetBestRootFolderPath(resource.Path);
|
||||||
|
@ -249,7 +251,10 @@ namespace Lidarr.Api.V1.Artist
|
||||||
|
|
||||||
public void Handle(TrackFileDeletedEvent message)
|
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));
|
BroadcastResourceChange(ModelAction.Updated, GetArtistResource(message.TrackFile.Artist.Value));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Lidarr.Http.REST;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.MediaCover;
|
using NzbDrone.Core.MediaCover;
|
||||||
using NzbDrone.Core.Music;
|
using NzbDrone.Core.Music;
|
||||||
using Lidarr.Http.REST;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Artist
|
namespace Lidarr.Api.V1.Artist
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,6 @@ namespace Lidarr.Api.V1.Artist
|
||||||
//Todo: Sorters should be done completely on the client
|
//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: 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
|
//Todo: We should get the entire Profile instead of ID and Name separately
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public int ArtistMetadataId { get; set; }
|
public int ArtistMetadataId { get; set; }
|
||||||
public ArtistStatusType Status { get; set; }
|
public ArtistStatusType Status { get; set; }
|
||||||
|
@ -33,7 +32,7 @@ namespace Lidarr.Api.V1.Artist
|
||||||
public string ArtistType { get; set; }
|
public string ArtistType { get; set; }
|
||||||
public string Disambiguation { get; set; }
|
public string Disambiguation { get; set; }
|
||||||
public List<Links> Links { get; set; }
|
public List<Links> Links { get; set; }
|
||||||
|
|
||||||
public Album NextAlbum { get; set; }
|
public Album NextAlbum { get; set; }
|
||||||
public Album LastAlbum { get; set; }
|
public Album LastAlbum { get; set; }
|
||||||
|
|
||||||
|
@ -42,7 +41,6 @@ namespace Lidarr.Api.V1.Artist
|
||||||
|
|
||||||
public string RemotePoster { get; set; }
|
public string RemotePoster { get; set; }
|
||||||
|
|
||||||
|
|
||||||
//View & Edit
|
//View & Edit
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
public int QualityProfileId { 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)
|
public static ArtistResource ToResource(this NzbDrone.Core.Music.Artist model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new ArtistResource
|
return new ArtistResource
|
||||||
{
|
{
|
||||||
|
@ -76,6 +77,7 @@ namespace Lidarr.Api.V1.Artist
|
||||||
ArtistMetadataId = model.ArtistMetadataId,
|
ArtistMetadataId = model.ArtistMetadataId,
|
||||||
|
|
||||||
ArtistName = model.Name,
|
ArtistName = model.Name,
|
||||||
|
|
||||||
//AlternateTitles
|
//AlternateTitles
|
||||||
SortName = model.SortName,
|
SortName = model.SortName,
|
||||||
|
|
||||||
|
@ -98,6 +100,7 @@ namespace Lidarr.Api.V1.Artist
|
||||||
|
|
||||||
CleanName = model.CleanName,
|
CleanName = model.CleanName,
|
||||||
ForeignArtistId = model.Metadata.Value.ForeignArtistId,
|
ForeignArtistId = model.Metadata.Value.ForeignArtistId,
|
||||||
|
|
||||||
// Root folder path is now calculated from the artist path
|
// Root folder path is now calculated from the artist path
|
||||||
// RootFolderPath = model.RootFolderPath,
|
// RootFolderPath = model.RootFolderPath,
|
||||||
Genres = model.Metadata.Value.Genres,
|
Genres = model.Metadata.Value.Genres,
|
||||||
|
@ -112,7 +115,10 @@ namespace Lidarr.Api.V1.Artist
|
||||||
|
|
||||||
public static NzbDrone.Core.Music.Artist ToModel(this ArtistResource resource)
|
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
|
return new NzbDrone.Core.Music.Artist
|
||||||
{
|
{
|
||||||
|
@ -130,14 +136,13 @@ namespace Lidarr.Api.V1.Artist
|
||||||
Ratings = resource.Ratings,
|
Ratings = resource.Ratings,
|
||||||
Type = resource.ArtistType
|
Type = resource.ArtistType
|
||||||
},
|
},
|
||||||
|
|
||||||
//AlternateTitles
|
//AlternateTitles
|
||||||
SortName = resource.SortName,
|
SortName = resource.SortName,
|
||||||
Path = resource.Path,
|
Path = resource.Path,
|
||||||
QualityProfileId = resource.QualityProfileId,
|
QualityProfileId = resource.QualityProfileId,
|
||||||
MetadataProfileId = resource.MetadataProfileId,
|
MetadataProfileId = resource.MetadataProfileId,
|
||||||
|
|
||||||
|
|
||||||
AlbumFolder = resource.AlbumFolder,
|
AlbumFolder = resource.AlbumFolder,
|
||||||
Monitored = resource.Monitored,
|
Monitored = resource.Monitored,
|
||||||
|
|
||||||
|
@ -148,7 +153,6 @@ namespace Lidarr.Api.V1.Artist
|
||||||
Tags = resource.Tags,
|
Tags = resource.Tags,
|
||||||
Added = resource.Added,
|
Added = resource.Added,
|
||||||
AddOptions = resource.AddOptions,
|
AddOptions = resource.AddOptions,
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System;
|
|
||||||
using NzbDrone.Core.ArtistStats;
|
using NzbDrone.Core.ArtistStats;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Artist
|
namespace Lidarr.Api.V1.Artist
|
||||||
|
@ -15,9 +14,12 @@ namespace Lidarr.Api.V1.Artist
|
||||||
{
|
{
|
||||||
get
|
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)
|
public static ArtistStatisticsResource ToResource(this ArtistStatistics model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new ArtistStatisticsResource
|
return new ArtistStatisticsResource
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
using Lidarr.Http;
|
||||||
using NzbDrone.Core.Blacklisting;
|
using NzbDrone.Core.Blacklisting;
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
using Lidarr.Http;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Blacklist
|
namespace Lidarr.Api.V1.Blacklist
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NzbDrone.Core.Indexers;
|
|
||||||
using NzbDrone.Core.Qualities;
|
|
||||||
using Lidarr.Api.V1.Artist;
|
using Lidarr.Api.V1.Artist;
|
||||||
using Lidarr.Http.REST;
|
using Lidarr.Http.REST;
|
||||||
|
using NzbDrone.Core.Indexers;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Blacklist
|
namespace Lidarr.Api.V1.Blacklist
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,10 @@ namespace Lidarr.Api.V1.Blacklist
|
||||||
{
|
{
|
||||||
public static BlacklistResource MapToResource(this NzbDrone.Core.Blacklisting.Blacklist model)
|
public static BlacklistResource MapToResource(this NzbDrone.Core.Blacklisting.Blacklist model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new BlacklistResource
|
return new BlacklistResource
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,15 +2,15 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Ical.Net;
|
using Ical.Net;
|
||||||
|
using Ical.Net.CalendarComponents;
|
||||||
using Ical.Net.DataTypes;
|
using Ical.Net.DataTypes;
|
||||||
using Ical.Net.Serialization;
|
using Ical.Net.Serialization;
|
||||||
|
using Lidarr.Http.Extensions;
|
||||||
using Nancy;
|
using Nancy;
|
||||||
using Nancy.Responses;
|
using Nancy.Responses;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Tags;
|
|
||||||
using NzbDrone.Core.Music;
|
using NzbDrone.Core.Music;
|
||||||
using Lidarr.Http.Extensions;
|
using NzbDrone.Core.Tags;
|
||||||
using Ical.Net.CalendarComponents;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Calendar
|
namespace Lidarr.Api.V1.Calendar
|
||||||
{
|
{
|
||||||
|
@ -27,13 +27,13 @@ namespace Lidarr.Api.V1.Calendar
|
||||||
_artistService = artistService;
|
_artistService = artistService;
|
||||||
_tagService = tagService;
|
_tagService = tagService;
|
||||||
|
|
||||||
Get("/Lidarr.ics", options => GetCalendarFeed());
|
Get("/Lidarr.ics", options => GetCalendarFeed());
|
||||||
}
|
}
|
||||||
|
|
||||||
private object GetCalendarFeed()
|
private object GetCalendarFeed()
|
||||||
{
|
{
|
||||||
var pastDays = 7;
|
var pastDays = 7;
|
||||||
var futureDays = 28;
|
var futureDays = 28;
|
||||||
var start = DateTime.Today.AddDays(-pastDays);
|
var start = DateTime.Today.AddDays(-pastDays);
|
||||||
var end = DateTime.Today.AddDays(futureDays);
|
var end = DateTime.Today.AddDays(futureDays);
|
||||||
var unmonitored = Request.GetBooleanQueryParameter("unmonitored");
|
var unmonitored = Request.GetBooleanQueryParameter("unmonitored");
|
||||||
|
@ -82,6 +82,7 @@ namespace Lidarr.Api.V1.Calendar
|
||||||
|
|
||||||
var occurrence = calendar.Create<CalendarEvent>();
|
var occurrence = calendar.Create<CalendarEvent>();
|
||||||
occurrence.Uid = "Lidarr_album_" + album.Id;
|
occurrence.Uid = "Lidarr_album_" + album.Id;
|
||||||
|
|
||||||
//occurrence.Status = album.HasFile ? EventStatus.Confirmed : EventStatus.Tentative;
|
//occurrence.Status = album.HasFile ? EventStatus.Confirmed : EventStatus.Tentative;
|
||||||
occurrence.Description = album.Overview;
|
occurrence.Description = album.Overview;
|
||||||
occurrence.Categories = album.Genres;
|
occurrence.Categories = album.Genres;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
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.Api.V1.Albums;
|
||||||
using Lidarr.Http.Extensions;
|
using Lidarr.Http.Extensions;
|
||||||
|
using NzbDrone.Core.ArtistStats;
|
||||||
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||||
using NzbDrone.Core.MediaCover;
|
using NzbDrone.Core.MediaCover;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
|
using NzbDrone.SignalR;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Calendar
|
namespace Lidarr.Api.V1.Calendar
|
||||||
{
|
{
|
||||||
|
@ -36,8 +36,15 @@ namespace Lidarr.Api.V1.Calendar
|
||||||
var queryStart = Request.Query.Start;
|
var queryStart = Request.Query.Start;
|
||||||
var queryEnd = Request.Query.End;
|
var queryEnd = Request.Query.End;
|
||||||
|
|
||||||
if (queryStart.HasValue) start = DateTime.Parse(queryStart.Value);
|
if (queryStart.HasValue)
|
||||||
if (queryEnd.HasValue) end = DateTime.Parse(queryEnd.Value);
|
{
|
||||||
|
start = DateTime.Parse(queryStart.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (queryEnd.HasValue)
|
||||||
|
{
|
||||||
|
end = DateTime.Parse(queryEnd.Value);
|
||||||
|
}
|
||||||
|
|
||||||
var resources = MapToResource(_albumService.AlbumsBetweenDates(start, end, includeUnmonitored), includeArtist);
|
var resources = MapToResource(_albumService.AlbumsBetweenDates(start, end, includeUnmonitored), includeArtist);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Lidarr.Http;
|
||||||
|
using Lidarr.Http.Extensions;
|
||||||
|
using Lidarr.Http.Validation;
|
||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Common.TPL;
|
using NzbDrone.Common.TPL;
|
||||||
using NzbDrone.Core.Datastore.Events;
|
using NzbDrone.Core.Datastore.Events;
|
||||||
|
@ -8,9 +11,6 @@ using NzbDrone.Core.Messaging.Commands;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
using NzbDrone.Core.ProgressMessaging;
|
using NzbDrone.Core.ProgressMessaging;
|
||||||
using NzbDrone.SignalR;
|
using NzbDrone.SignalR;
|
||||||
using Lidarr.Http;
|
|
||||||
using Lidarr.Http.Extensions;
|
|
||||||
using Lidarr.Http.Validation;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Commands
|
namespace Lidarr.Api.V1.Commands
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,7 @@ namespace Lidarr.Api.V1.Commands
|
||||||
private int StartCommand(CommandResource commandResource)
|
private int StartCommand(CommandResource commandResource)
|
||||||
{
|
{
|
||||||
var commandType =
|
var commandType =
|
||||||
_serviceFactory.GetImplementations(typeof (Command))
|
_serviceFactory.GetImplementations(typeof(Command))
|
||||||
.Single(c => c.Name.Replace("Command", "")
|
.Single(c => c.Name.Replace("Command", "")
|
||||||
.Equals(commandResource.Name, StringComparison.InvariantCultureIgnoreCase));
|
.Equals(commandResource.Name, StringComparison.InvariantCultureIgnoreCase));
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Lidarr.Http.REST;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Messaging.Commands;
|
using NzbDrone.Core.Messaging.Commands;
|
||||||
using Lidarr.Http.REST;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Commands
|
namespace Lidarr.Api.V1.Commands
|
||||||
{
|
{
|
||||||
|
@ -30,37 +30,51 @@ namespace Lidarr.Api.V1.Commands
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
if (Started.HasValue)
|
||||||
if (Started.HasValue) return Started.Value;
|
{
|
||||||
|
return Started.Value;
|
||||||
|
}
|
||||||
|
|
||||||
return Ended;
|
return Ended;
|
||||||
}
|
}
|
||||||
|
|
||||||
set { }
|
set
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SendUpdatesToClient
|
public bool SendUpdatesToClient
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (Body != null) return Body.SendUpdatesToClient;
|
if (Body != null)
|
||||||
|
{
|
||||||
|
return Body.SendUpdatesToClient;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
set { }
|
set
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool UpdateScheduledTask
|
public bool UpdateScheduledTask
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (Body != null) return Body.UpdateScheduledTask;
|
if (Body != null)
|
||||||
|
{
|
||||||
|
return Body.UpdateScheduledTask;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
set { }
|
set
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime? LastExecutionTime { get; set; }
|
public DateTime? LastExecutionTime { get; set; }
|
||||||
|
@ -70,7 +84,10 @@ namespace Lidarr.Api.V1.Commands
|
||||||
{
|
{
|
||||||
public static CommandResource ToResource(this CommandModel model)
|
public static CommandResource ToResource(this CommandModel model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new CommandResource
|
return new CommandResource
|
||||||
{
|
{
|
||||||
|
|
|
@ -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
|
namespace Lidarr.Api.V1.Config
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,13 +2,13 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
using Lidarr.Http;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Authentication;
|
using NzbDrone.Core.Authentication;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.Update;
|
using NzbDrone.Core.Update;
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
using NzbDrone.Core.Validation.Paths;
|
using NzbDrone.Core.Validation.Paths;
|
||||||
using Lidarr.Http;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Config
|
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.BackupFolder).IsValidPath().When(c => Path.IsPathRooted(c.BackupFolder));
|
||||||
SharedValidator.RuleFor(c => c.BackupInterval).InclusiveBetween(1, 7);
|
SharedValidator.RuleFor(c => c.BackupInterval).InclusiveBetween(1, 7);
|
||||||
SharedValidator.RuleFor(c => c.BackupRetention).InclusiveBetween(1, 90);
|
SharedValidator.RuleFor(c => c.BackupRetention).InclusiveBetween(1, 90);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private HostConfigResource GetHostConfig()
|
private HostConfigResource GetHostConfig()
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
|
using Lidarr.Http.REST;
|
||||||
using NzbDrone.Common.Http.Proxy;
|
using NzbDrone.Common.Http.Proxy;
|
||||||
using NzbDrone.Core.Authentication;
|
using NzbDrone.Core.Authentication;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.Security;
|
using NzbDrone.Core.Security;
|
||||||
using NzbDrone.Core.Update;
|
using NzbDrone.Core.Update;
|
||||||
using Lidarr.Http.REST;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Config
|
namespace Lidarr.Api.V1.Config
|
||||||
{
|
{
|
||||||
|
@ -56,6 +56,7 @@ namespace Lidarr.Api.V1.Config
|
||||||
LaunchBrowser = model.LaunchBrowser,
|
LaunchBrowser = model.LaunchBrowser,
|
||||||
AuthenticationMethod = model.AuthenticationMethod,
|
AuthenticationMethod = model.AuthenticationMethod,
|
||||||
AnalyticsEnabled = model.AnalyticsEnabled,
|
AnalyticsEnabled = model.AnalyticsEnabled,
|
||||||
|
|
||||||
//Username
|
//Username
|
||||||
//Password
|
//Password
|
||||||
LogLevel = model.LogLevel,
|
LogLevel = model.LogLevel,
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using NzbDrone.Core.Configuration;
|
|
||||||
using Lidarr.Http.Validation;
|
using Lidarr.Http.Validation;
|
||||||
|
using NzbDrone.Core.Configuration;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Config
|
namespace Lidarr.Api.V1.Config
|
||||||
{
|
{
|
||||||
public class IndexerConfigModule : LidarrConfigModule<IndexerConfigResource>
|
public class IndexerConfigModule : LidarrConfigModule<IndexerConfigResource>
|
||||||
{
|
{
|
||||||
|
|
||||||
public IndexerConfigModule(IConfigService configService)
|
public IndexerConfigModule(IConfigService configService)
|
||||||
: base(configService)
|
: base(configService)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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
|
namespace Lidarr.Api.V1.Config
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using NzbDrone.Core.Configuration;
|
|
||||||
using Lidarr.Http;
|
using Lidarr.Http;
|
||||||
using Lidarr.Http.REST;
|
using Lidarr.Http.REST;
|
||||||
|
using NzbDrone.Core.Configuration;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Config
|
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;
|
private readonly IConfigService _configService;
|
||||||
|
|
||||||
|
@ -15,8 +16,8 @@ namespace Lidarr.Api.V1.Config
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LidarrConfigModule(string resource, IConfigService configService) :
|
protected LidarrConfigModule(string resource, IConfigService configService)
|
||||||
base("config/" + resource.Trim('/'))
|
: base("config/" + resource.Trim('/'))
|
||||||
{
|
{
|
||||||
_configService = configService;
|
_configService = configService;
|
||||||
|
|
||||||
|
|
|
@ -21,4 +21,4 @@ namespace Lidarr.Api.V1.Config
|
||||||
return MediaManagementConfigResourceMapper.ToResource(model);
|
return MediaManagementConfigResourceMapper.ToResource(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
using Lidarr.Http.REST;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using Lidarr.Http.REST;
|
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Config
|
namespace Lidarr.Api.V1.Config
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using NzbDrone.Core.Configuration;
|
|
||||||
using Lidarr.Http;
|
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Config
|
namespace Lidarr.Api.V1.Config
|
||||||
|
|
|
@ -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
|
namespace Lidarr.Api.V1.Config
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,13 +2,10 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using FluentValidation.Results;
|
using FluentValidation.Results;
|
||||||
|
using Lidarr.Http;
|
||||||
using Nancy.ModelBinding;
|
using Nancy.ModelBinding;
|
||||||
using Nancy.Responses;
|
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Organizer;
|
using NzbDrone.Core.Organizer;
|
||||||
using Lidarr.Http;
|
|
||||||
using Lidarr.Http.Extensions;
|
|
||||||
using Lidarr.Http.Mapping;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Config
|
namespace Lidarr.Api.V1.Config
|
||||||
{
|
{
|
||||||
|
@ -33,8 +30,7 @@ namespace Lidarr.Api.V1.Config
|
||||||
GetResourceById = GetNamingConfig;
|
GetResourceById = GetNamingConfig;
|
||||||
UpdateResource = UpdateNamingConfig;
|
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.StandardTrackFormat).ValidTrackFormat();
|
||||||
SharedValidator.RuleFor(c => c.MultiDiscTrackFormat).ValidTrackFormat();
|
SharedValidator.RuleFor(c => c.MultiDiscTrackFormat).ValidTrackFormat();
|
||||||
|
@ -84,7 +80,7 @@ namespace Lidarr.Api.V1.Config
|
||||||
|
|
||||||
var nameSpec = config.ToModel();
|
var nameSpec = config.ToModel();
|
||||||
var sampleResource = new NamingExampleResource();
|
var sampleResource = new NamingExampleResource();
|
||||||
|
|
||||||
var singleTrackSampleResult = _filenameSampleService.GetStandardTrackSample(nameSpec);
|
var singleTrackSampleResult = _filenameSampleService.GetStandardTrackSample(nameSpec);
|
||||||
var multiDiscTrackSampleResult = _filenameSampleService.GetMultiDiscTrackSample(nameSpec);
|
var multiDiscTrackSampleResult = _filenameSampleService.GetMultiDiscTrackSample(nameSpec);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
using System.Linq;
|
using NzbDrone.Core.Configuration;
|
||||||
using System.Reflection;
|
|
||||||
using NzbDrone.Core.Configuration;
|
|
||||||
using Lidarr.Http;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Config
|
namespace Lidarr.Api.V1.Config
|
||||||
{
|
{
|
||||||
|
@ -10,7 +7,6 @@ namespace Lidarr.Api.V1.Config
|
||||||
public UiConfigModule(IConfigService configService)
|
public UiConfigModule(IConfigService configService)
|
||||||
: base(configService)
|
: base(configService)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override UiConfigResource ToResource(IConfigService model)
|
protected override UiConfigResource ToResource(IConfigService model)
|
||||||
|
@ -18,4 +14,4 @@ namespace Lidarr.Api.V1.Config
|
||||||
return UiConfigResourceMapper.ToResource(model);
|
return UiConfigResourceMapper.ToResource(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
namespace Lidarr.Api.V1.Config
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NzbDrone.Core.CustomFilters;
|
|
||||||
using Lidarr.Http;
|
using Lidarr.Http;
|
||||||
|
using NzbDrone.Core.CustomFilters;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.CustomFilters
|
namespace Lidarr.Api.V1.CustomFilters
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Lidarr.Http.REST;
|
||||||
using NzbDrone.Common.Serializer;
|
using NzbDrone.Common.Serializer;
|
||||||
using NzbDrone.Core.CustomFilters;
|
using NzbDrone.Core.CustomFilters;
|
||||||
using Lidarr.Http.REST;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.CustomFilters
|
namespace Lidarr.Api.V1.CustomFilters
|
||||||
{
|
{
|
||||||
|
@ -17,28 +17,34 @@ namespace Lidarr.Api.V1.CustomFilters
|
||||||
{
|
{
|
||||||
public static CustomFilterResource ToResource(this CustomFilter model)
|
public static CustomFilterResource ToResource(this CustomFilter model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new CustomFilterResource
|
return new CustomFilterResource
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
Type = model.Type,
|
Type = model.Type,
|
||||||
Label = model.Label,
|
Label = model.Label,
|
||||||
Filters = Json.Deserialize<List<dynamic>>(model.Filters)
|
Filters = Json.Deserialize<List<dynamic>>(model.Filters)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CustomFilter ToModel(this CustomFilterResource resource)
|
public static CustomFilter ToModel(this CustomFilterResource resource)
|
||||||
{
|
{
|
||||||
if (resource == null) return null;
|
if (resource == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new CustomFilter
|
return new CustomFilter
|
||||||
{
|
{
|
||||||
Id = resource.Id,
|
Id = resource.Id,
|
||||||
Type = resource.Type,
|
Type = resource.Type,
|
||||||
Label = resource.Label,
|
Label = resource.Label,
|
||||||
Filters = Json.ToJson(resource.Filters)
|
Filters = Json.ToJson(resource.Filters)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<CustomFilterResource> ToResource(this IEnumerable<CustomFilter> filters)
|
public static List<CustomFilterResource> ToResource(this IEnumerable<CustomFilter> filters)
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NzbDrone.Core.DiskSpace;
|
|
||||||
using Lidarr.Http;
|
using Lidarr.Http;
|
||||||
|
using NzbDrone.Core.DiskSpace;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.DiskSpace
|
namespace Lidarr.Api.V1.DiskSpace
|
||||||
{
|
{
|
||||||
public class DiskSpaceModule :LidarrRestModule<DiskSpaceResource>
|
public class DiskSpaceModule : LidarrRestModule<DiskSpaceResource>
|
||||||
{
|
{
|
||||||
private readonly IDiskSpaceService _diskSpaceService;
|
private readonly IDiskSpaceService _diskSpaceService;
|
||||||
|
|
||||||
public DiskSpaceModule(IDiskSpaceService diskSpaceService)
|
public DiskSpaceModule(IDiskSpaceService diskSpaceService)
|
||||||
:base("diskspace")
|
: base("diskspace")
|
||||||
{
|
{
|
||||||
_diskSpaceService = diskSpaceService;
|
_diskSpaceService = diskSpaceService;
|
||||||
GetResourceAll = GetFreeSpace;
|
GetResourceAll = GetFreeSpace;
|
||||||
|
|
|
@ -14,7 +14,10 @@ namespace Lidarr.Api.V1.DiskSpace
|
||||||
{
|
{
|
||||||
public static DiskSpaceResource MapToResource(this NzbDrone.Core.DiskSpace.DiskSpace model)
|
public static DiskSpaceResource MapToResource(this NzbDrone.Core.DiskSpace.DiskSpace model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new DiskSpaceResource
|
return new DiskSpaceResource
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,8 +13,12 @@ namespace Lidarr.Api.V1.DownloadClient
|
||||||
|
|
||||||
protected override void Validate(DownloadClientDefinition definition, bool includeWarnings)
|
protected override void Validate(DownloadClientDefinition definition, bool includeWarnings)
|
||||||
{
|
{
|
||||||
if (!definition.Enable) return;
|
if (!definition.Enable)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
base.Validate(definition, includeWarnings);
|
base.Validate(definition, includeWarnings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,10 @@ namespace Lidarr.Api.V1.DownloadClient
|
||||||
{
|
{
|
||||||
public override DownloadClientResource ToResource(DownloadClientDefinition definition)
|
public override DownloadClientResource ToResource(DownloadClientDefinition definition)
|
||||||
{
|
{
|
||||||
if (definition == null) return null;
|
if (definition == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var resource = base.ToResource(definition);
|
var resource = base.ToResource(definition);
|
||||||
|
|
||||||
|
@ -27,7 +30,10 @@ namespace Lidarr.Api.V1.DownloadClient
|
||||||
|
|
||||||
public override DownloadClientDefinition ToModel(DownloadClientResource resource)
|
public override DownloadClientDefinition ToModel(DownloadClientResource resource)
|
||||||
{
|
{
|
||||||
if (resource == null) return null;
|
if (resource == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var definition = base.ToModel(resource);
|
var definition = base.ToModel(resource);
|
||||||
|
|
||||||
|
@ -38,4 +44,4 @@ namespace Lidarr.Api.V1.DownloadClient
|
||||||
return definition;
|
return definition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.IO.Abstractions;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Lidarr.Http.Extensions;
|
||||||
using Nancy;
|
using Nancy;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using Lidarr.Http.Extensions;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.FileSystem
|
namespace Lidarr.Api.V1.FileSystem
|
||||||
{
|
{
|
||||||
|
@ -24,9 +21,9 @@ namespace Lidarr.Api.V1.FileSystem
|
||||||
_fileSystemLookupService = fileSystemLookupService;
|
_fileSystemLookupService = fileSystemLookupService;
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
_diskScanService = diskScanService;
|
_diskScanService = diskScanService;
|
||||||
Get("/", x => GetContents());
|
Get("/", x => GetContents());
|
||||||
Get("/type", x => GetEntityType());
|
Get("/type", x => GetEntityType());
|
||||||
Get("/mediafiles", x => GetMediaFiles());
|
Get("/mediafiles", x => GetMediaFiles());
|
||||||
}
|
}
|
||||||
|
|
||||||
private object GetContents()
|
private object GetContents()
|
||||||
|
@ -62,7 +59,8 @@ namespace Lidarr.Api.V1.FileSystem
|
||||||
return new string[0];
|
return new string[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
return _diskScanService.GetAudioFiles(path).Select(f => new {
|
return _diskScanService.GetAudioFiles(path).Select(f => new
|
||||||
|
{
|
||||||
Path = f.FullName,
|
Path = f.FullName,
|
||||||
RelativePath = path.GetRelativePath(f.FullName),
|
RelativePath = path.GetRelativePath(f.FullName),
|
||||||
Name = f.Name
|
Name = f.Name
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Lidarr.Http;
|
||||||
using NzbDrone.Core.Datastore.Events;
|
using NzbDrone.Core.Datastore.Events;
|
||||||
using NzbDrone.Core.HealthCheck;
|
using NzbDrone.Core.HealthCheck;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
using NzbDrone.SignalR;
|
using NzbDrone.SignalR;
|
||||||
using Lidarr.Http;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Health
|
namespace Lidarr.Api.V1.Health
|
||||||
{
|
{
|
||||||
|
@ -29,4 +29,4 @@ namespace Lidarr.Api.V1.Health
|
||||||
BroadcastResourceChange(ModelAction.Sync);
|
BroadcastResourceChange(ModelAction.Sync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Lidarr.Http.REST;
|
||||||
using NzbDrone.Common.Http;
|
using NzbDrone.Common.Http;
|
||||||
using NzbDrone.Core.HealthCheck;
|
using NzbDrone.Core.HealthCheck;
|
||||||
using Lidarr.Http.REST;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Health
|
namespace Lidarr.Api.V1.Health
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,10 @@ namespace Lidarr.Api.V1.Health
|
||||||
{
|
{
|
||||||
public static HealthResource ToResource(this HealthCheck model)
|
public static HealthResource ToResource(this HealthCheck model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new HealthResource
|
return new HealthResource
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
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.Albums;
|
||||||
using Lidarr.Api.V1.Artist;
|
using Lidarr.Api.V1.Artist;
|
||||||
using Lidarr.Api.V1.Tracks;
|
using Lidarr.Api.V1.Tracks;
|
||||||
using Lidarr.Http;
|
using Lidarr.Http;
|
||||||
using Lidarr.Http.Extensions;
|
using Lidarr.Http.Extensions;
|
||||||
using Lidarr.Http.REST;
|
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
|
namespace Lidarr.Api.V1.History
|
||||||
{
|
{
|
||||||
|
@ -30,9 +30,9 @@ namespace Lidarr.Api.V1.History
|
||||||
_failedDownloadService = failedDownloadService;
|
_failedDownloadService = failedDownloadService;
|
||||||
GetResourcePaged = GetHistory;
|
GetResourcePaged = GetHistory;
|
||||||
|
|
||||||
Get("/since", x => GetHistorySince());
|
Get("/since", x => GetHistorySince());
|
||||||
Get("/artist", x => GetArtistHistory());
|
Get("/artist", x => GetArtistHistory());
|
||||||
Post("/failed", x => MarkAsFailed());
|
Post("/failed", x => MarkAsFailed());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected HistoryResource MapToResource(NzbDrone.Core.History.History model, bool includeArtist, bool includeAlbum, bool includeTrack)
|
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();
|
resource.Artist = model.Artist.ToResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includeAlbum)
|
if (includeAlbum)
|
||||||
{
|
{
|
||||||
resource.Album = model.Album.ToResource();
|
resource.Album = model.Album.ToResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includeTrack)
|
if (includeTrack)
|
||||||
{
|
{
|
||||||
resource.Track = model.Track.ToResource();
|
resource.Track = model.Track.ToResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (model.Artist != null)
|
if (model.Artist != null)
|
||||||
{
|
{
|
||||||
|
@ -90,7 +91,6 @@ namespace Lidarr.Api.V1.History
|
||||||
pagingSpec.FilterExpressions.Add(h => h.DownloadId == downloadId);
|
pagingSpec.FilterExpressions.Add(h => h.DownloadId == downloadId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return ApplyToPage(_historyService.Paged, pagingSpec, h => MapToResource(h, includeArtist, includeAlbum, includeTrack));
|
return ApplyToPage(_historyService.Paged, pagingSpec, h => MapToResource(h, includeArtist, includeAlbum, includeTrack));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NzbDrone.Core.History;
|
|
||||||
using NzbDrone.Core.Qualities;
|
|
||||||
using Lidarr.Api.V1.Albums;
|
using Lidarr.Api.V1.Albums;
|
||||||
using Lidarr.Api.V1.Artist;
|
using Lidarr.Api.V1.Artist;
|
||||||
using Lidarr.Api.V1.Tracks;
|
using Lidarr.Api.V1.Tracks;
|
||||||
using Lidarr.Http.REST;
|
using Lidarr.Http.REST;
|
||||||
|
using NzbDrone.Core.History;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.History
|
namespace Lidarr.Api.V1.History
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,10 @@ namespace Lidarr.Api.V1.History
|
||||||
{
|
{
|
||||||
public static HistoryResource ToResource(this NzbDrone.Core.History.History model)
|
public static HistoryResource ToResource(this NzbDrone.Core.History.History model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new HistoryResource
|
return new HistoryResource
|
||||||
{
|
{
|
||||||
|
@ -44,6 +47,7 @@ namespace Lidarr.Api.V1.History
|
||||||
TrackId = model.TrackId,
|
TrackId = model.TrackId,
|
||||||
SourceTitle = model.SourceTitle,
|
SourceTitle = model.SourceTitle,
|
||||||
Quality = model.Quality,
|
Quality = model.Quality,
|
||||||
|
|
||||||
//QualityCutoffNotMet
|
//QualityCutoffNotMet
|
||||||
Date = model.Date,
|
Date = model.Date,
|
||||||
DownloadId = model.DownloadId,
|
DownloadId = model.DownloadId,
|
||||||
|
@ -51,6 +55,7 @@ namespace Lidarr.Api.V1.History
|
||||||
EventType = model.EventType,
|
EventType = model.EventType,
|
||||||
|
|
||||||
Data = model.Data
|
Data = model.Data
|
||||||
|
|
||||||
//Episode
|
//Episode
|
||||||
//Series
|
//Series
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NzbDrone.Core.ImportLists.Exclusions;
|
|
||||||
using Lidarr.Http;
|
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
using Lidarr.Http;
|
||||||
|
using NzbDrone.Core.ImportLists.Exclusions;
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.ImportLists
|
namespace Lidarr.Api.V1.ImportLists
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Core.ImportLists.Exclusions;
|
|
||||||
using Lidarr.Http.REST;
|
using Lidarr.Http.REST;
|
||||||
|
using NzbDrone.Core.ImportLists.Exclusions;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.ImportLists
|
namespace Lidarr.Api.V1.ImportLists
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,10 @@ namespace Lidarr.Api.V1.ImportLists
|
||||||
{
|
{
|
||||||
public static ImportListExclusionResource ToResource(this ImportListExclusion model)
|
public static ImportListExclusionResource ToResource(this ImportListExclusion model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new ImportListExclusionResource
|
return new ImportListExclusionResource
|
||||||
{
|
{
|
||||||
|
@ -27,7 +30,10 @@ namespace Lidarr.Api.V1.ImportLists
|
||||||
|
|
||||||
public static ImportListExclusion ToModel(this ImportListExclusionResource resource)
|
public static ImportListExclusion ToModel(this ImportListExclusionResource resource)
|
||||||
{
|
{
|
||||||
if (resource == null) return null;
|
if (resource == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new ImportListExclusion
|
return new ImportListExclusion
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,8 +10,7 @@ namespace Lidarr.Api.V1.ImportLists
|
||||||
|
|
||||||
public ImportListModule(ImportListFactory importListFactory,
|
public ImportListModule(ImportListFactory importListFactory,
|
||||||
ProfileExistsValidator profileExistsValidator,
|
ProfileExistsValidator profileExistsValidator,
|
||||||
MetadataProfileExistsValidator metadataProfileExistsValidator
|
MetadataProfileExistsValidator metadataProfileExistsValidator)
|
||||||
)
|
|
||||||
: base(importListFactory, "importlist", ResourceMapper)
|
: base(importListFactory, "importlist", ResourceMapper)
|
||||||
{
|
{
|
||||||
Http.Validation.RuleBuilderExtensions.ValidId(SharedValidator.RuleFor(s => s.QualityProfileId));
|
Http.Validation.RuleBuilderExtensions.ValidId(SharedValidator.RuleFor(s => s.QualityProfileId));
|
||||||
|
@ -28,6 +27,7 @@ namespace Lidarr.Api.V1.ImportLists
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
base.Validate(definition, includeWarnings);
|
base.Validate(definition, includeWarnings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,14 +23,14 @@ namespace Lidarr.Api.V1.ImportLists
|
||||||
}
|
}
|
||||||
|
|
||||||
var resource = base.ToResource(definition);
|
var resource = base.ToResource(definition);
|
||||||
|
|
||||||
resource.EnableAutomaticAdd = definition.EnableAutomaticAdd;
|
resource.EnableAutomaticAdd = definition.EnableAutomaticAdd;
|
||||||
resource.ShouldMonitor = definition.ShouldMonitor;
|
resource.ShouldMonitor = definition.ShouldMonitor;
|
||||||
resource.RootFolderPath = definition.RootFolderPath;
|
resource.RootFolderPath = definition.RootFolderPath;
|
||||||
resource.QualityProfileId = definition.ProfileId;
|
resource.QualityProfileId = definition.ProfileId;
|
||||||
resource.MetadataProfileId = definition.MetadataProfileId;
|
resource.MetadataProfileId = definition.MetadataProfileId;
|
||||||
resource.ListType = definition.ListType;
|
resource.ListType = definition.ListType;
|
||||||
resource.ListOrder = (int) definition.ListType;
|
resource.ListOrder = (int)definition.ListType;
|
||||||
|
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ namespace Lidarr.Api.V1.ImportLists
|
||||||
}
|
}
|
||||||
|
|
||||||
var definition = base.ToModel(resource);
|
var definition = base.ToModel(resource);
|
||||||
|
|
||||||
definition.EnableAutomaticAdd = resource.EnableAutomaticAdd;
|
definition.EnableAutomaticAdd = resource.EnableAutomaticAdd;
|
||||||
definition.ShouldMonitor = resource.ShouldMonitor;
|
definition.ShouldMonitor = resource.ShouldMonitor;
|
||||||
definition.RootFolderPath = resource.RootFolderPath;
|
definition.RootFolderPath = resource.RootFolderPath;
|
||||||
|
|
|
@ -13,8 +13,12 @@ namespace Lidarr.Api.V1.Indexers
|
||||||
|
|
||||||
protected override void Validate(IndexerDefinition definition, bool includeWarnings)
|
protected override void Validate(IndexerDefinition definition, bool includeWarnings)
|
||||||
{
|
{
|
||||||
if (!definition.Enable) return;
|
if (!definition.Enable)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
base.Validate(definition, includeWarnings);
|
base.Validate(definition, includeWarnings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,10 @@ namespace Lidarr.Api.V1.Indexers
|
||||||
{
|
{
|
||||||
public override IndexerResource ToResource(IndexerDefinition definition)
|
public override IndexerResource ToResource(IndexerDefinition definition)
|
||||||
{
|
{
|
||||||
if (definition == null) return null;
|
if (definition == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var resource = base.ToResource(definition);
|
var resource = base.ToResource(definition);
|
||||||
|
|
||||||
|
@ -32,7 +35,10 @@ namespace Lidarr.Api.V1.Indexers
|
||||||
|
|
||||||
public override IndexerDefinition ToModel(IndexerResource resource)
|
public override IndexerDefinition ToModel(IndexerResource resource)
|
||||||
{
|
{
|
||||||
if (resource == null) return null;
|
if (resource == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var definition = base.ToModel(resource);
|
var definition = base.ToModel(resource);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ using NzbDrone.Core.Indexers;
|
||||||
using NzbDrone.Core.IndexerSearch;
|
using NzbDrone.Core.IndexerSearch;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
using Lidarr.Http.Extensions;
|
|
||||||
using HttpStatusCode = System.Net.HttpStatusCode;
|
using HttpStatusCode = System.Net.HttpStatusCode;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Indexers
|
namespace Lidarr.Api.V1.Indexers
|
||||||
|
@ -43,7 +42,7 @@ namespace Lidarr.Api.V1.Indexers
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
|
||||||
GetResourceAll = GetReleases;
|
GetResourceAll = GetReleases;
|
||||||
Post("/", x => DownloadRelease(ReadResourceFromRequest()));
|
Post("/", x => DownloadRelease(ReadResourceFromRequest()));
|
||||||
|
|
||||||
PostValidator.RuleFor(s => s.IndexerId).ValidId();
|
PostValidator.RuleFor(s => s.IndexerId).ValidId();
|
||||||
PostValidator.RuleFor(s => s.Guid).NotEmpty();
|
PostValidator.RuleFor(s => s.Guid).NotEmpty();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
|
||||||
using Lidarr.Http;
|
using Lidarr.Http;
|
||||||
|
using NzbDrone.Core.DecisionEngine;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Indexers
|
namespace Lidarr.Api.V1.Indexers
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,19 +2,17 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using FluentValidation.Results;
|
using FluentValidation.Results;
|
||||||
using Nancy;
|
|
||||||
using NLog;
|
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.Common.Extensions;
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
|
using NzbDrone.Core.DecisionEngine;
|
||||||
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Indexers;
|
using NzbDrone.Core.Indexers;
|
||||||
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Indexers
|
namespace Lidarr.Api.V1.Indexers
|
||||||
{
|
{
|
||||||
class ReleasePushModule : ReleaseModuleBase
|
internal class ReleasePushModule : ReleaseModuleBase
|
||||||
{
|
{
|
||||||
private readonly IMakeDownloadDecision _downloadDecisionMaker;
|
private readonly IMakeDownloadDecision _downloadDecisionMaker;
|
||||||
private readonly IProcessDownloadDecisions _downloadDecisionProcessor;
|
private readonly IProcessDownloadDecisions _downloadDecisionProcessor;
|
||||||
|
@ -31,7 +29,7 @@ namespace Lidarr.Api.V1.Indexers
|
||||||
_indexerFactory = indexerFactory;
|
_indexerFactory = indexerFactory;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
|
||||||
Post("/push", x => ProcessRelease(ReadResourceFromRequest()));
|
Post("/push", x => ProcessRelease(ReadResourceFromRequest()));
|
||||||
|
|
||||||
PostValidator.RuleFor(s => s.Title).NotEmpty();
|
PostValidator.RuleFor(s => s.Title).NotEmpty();
|
||||||
PostValidator.RuleFor(s => s.DownloadUrl).NotEmpty();
|
PostValidator.RuleFor(s => s.DownloadUrl).NotEmpty();
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Lidarr.Http.REST;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Indexers;
|
using NzbDrone.Core.Indexers;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
using Lidarr.Http.REST;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Indexers
|
namespace Lidarr.Api.V1.Indexers
|
||||||
{
|
{
|
||||||
|
@ -49,12 +49,13 @@ namespace Lidarr.Api.V1.Indexers
|
||||||
public DownloadProtocol Protocol { get; set; }
|
public DownloadProtocol Protocol { get; set; }
|
||||||
|
|
||||||
// Sent when queuing an unknown release
|
// Sent when queuing an unknown release
|
||||||
|
|
||||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
|
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
|
|
||||||
// [JsonIgnore]
|
// [JsonIgnore]
|
||||||
public int? ArtistId { get; set; }
|
public int? ArtistId { get; set; }
|
||||||
|
|
||||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
|
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
|
|
||||||
// [JsonIgnore]
|
// [JsonIgnore]
|
||||||
public int? AlbumId { get; set; }
|
public int? AlbumId { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -73,6 +74,7 @@ namespace Lidarr.Api.V1.Indexers
|
||||||
{
|
{
|
||||||
Guid = releaseInfo.Guid,
|
Guid = releaseInfo.Guid,
|
||||||
Quality = parsedAlbumInfo.Quality,
|
Quality = parsedAlbumInfo.Quality,
|
||||||
|
|
||||||
//QualityWeight
|
//QualityWeight
|
||||||
Age = releaseInfo.Age,
|
Age = releaseInfo.Age,
|
||||||
AgeHours = releaseInfo.AgeHours,
|
AgeHours = releaseInfo.AgeHours,
|
||||||
|
@ -95,17 +97,16 @@ namespace Lidarr.Api.V1.Indexers
|
||||||
DownloadUrl = releaseInfo.DownloadUrl,
|
DownloadUrl = releaseInfo.DownloadUrl,
|
||||||
InfoUrl = releaseInfo.InfoUrl,
|
InfoUrl = releaseInfo.InfoUrl,
|
||||||
DownloadAllowed = remoteAlbum.DownloadAllowed,
|
DownloadAllowed = remoteAlbum.DownloadAllowed,
|
||||||
|
|
||||||
//ReleaseWeight
|
//ReleaseWeight
|
||||||
PreferredWordScore = remoteAlbum.PreferredWordScore,
|
PreferredWordScore = remoteAlbum.PreferredWordScore,
|
||||||
|
|
||||||
|
|
||||||
MagnetUrl = torrentInfo.MagnetUrl,
|
MagnetUrl = torrentInfo.MagnetUrl,
|
||||||
InfoHash = torrentInfo.InfoHash,
|
InfoHash = torrentInfo.InfoHash,
|
||||||
Seeders = torrentInfo.Seeders,
|
Seeders = torrentInfo.Seeders,
|
||||||
Leechers = (torrentInfo.Peers.HasValue && torrentInfo.Seeders.HasValue) ? (torrentInfo.Peers.Value - torrentInfo.Seeders.Value) : (int?)null,
|
Leechers = (torrentInfo.Peers.HasValue && torrentInfo.Seeders.HasValue) ? (torrentInfo.Peers.Value - torrentInfo.Seeders.Value) : (int?)null,
|
||||||
Protocol = releaseInfo.DownloadProtocol,
|
Protocol = releaseInfo.DownloadProtocol,
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ReleaseInfo ToModel(this ReleaseResource resource)
|
public static ReleaseInfo ToModel(this ReleaseResource resource)
|
||||||
|
|
|
@ -38,6 +38,5 @@ namespace Lidarr.Api.V1.Logs
|
||||||
return "logfile";
|
return "logfile";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Lidarr.Http;
|
||||||
using Nancy;
|
using Nancy;
|
||||||
using Nancy.Responses;
|
using Nancy.Responses;
|
||||||
|
using NLog;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using Lidarr.Http;
|
|
||||||
using NLog;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Logs
|
namespace Lidarr.Api.V1.Logs
|
||||||
{
|
{
|
||||||
|
@ -26,7 +26,7 @@ namespace Lidarr.Api.V1.Logs
|
||||||
_configFileProvider = configFileProvider;
|
_configFileProvider = configFileProvider;
|
||||||
GetResourceAll = GetLogFilesResponse;
|
GetResourceAll = GetLogFilesResponse;
|
||||||
|
|
||||||
Get(LOGFILE_ROUTE, options => GetLogFileResponse(options.filename));
|
Get(LOGFILE_ROUTE, options => GetLogFileResponse(options.filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<LogFileResource> GetLogFilesResponse()
|
private List<LogFileResource> GetLogFilesResponse()
|
||||||
|
@ -39,7 +39,7 @@ namespace Lidarr.Api.V1.Logs
|
||||||
{
|
{
|
||||||
var file = files[i];
|
var file = files[i];
|
||||||
var filename = Path.GetFileName(file);
|
var filename = Path.GetFileName(file);
|
||||||
|
|
||||||
result.Add(new LogFileResource
|
result.Add(new LogFileResource
|
||||||
{
|
{
|
||||||
Id = i + 1,
|
Id = i + 1,
|
||||||
|
@ -60,10 +60,12 @@ namespace Lidarr.Api.V1.Logs
|
||||||
var filePath = GetLogFilePath(filename);
|
var filePath = GetLogFilePath(filename);
|
||||||
|
|
||||||
if (!_diskProvider.FileExists(filePath))
|
if (!_diskProvider.FileExists(filePath))
|
||||||
|
{
|
||||||
return new NotFoundResponse();
|
return new NotFoundResponse();
|
||||||
|
}
|
||||||
|
|
||||||
var data = _diskProvider.ReadAllText(filePath);
|
var data = _diskProvider.ReadAllText(filePath);
|
||||||
|
|
||||||
return new TextResponse(data);
|
return new TextResponse(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Core.Instrumentation;
|
|
||||||
using Lidarr.Http;
|
using Lidarr.Http;
|
||||||
|
using NzbDrone.Core.Instrumentation;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Logs
|
namespace Lidarr.Api.V1.Logs
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using NzbDrone.Core.Instrumentation;
|
|
||||||
using Lidarr.Http.REST;
|
using Lidarr.Http.REST;
|
||||||
|
using NzbDrone.Core.Instrumentation;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Logs
|
namespace Lidarr.Api.V1.Logs
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,10 @@ namespace Lidarr.Api.V1.Logs
|
||||||
{
|
{
|
||||||
public static LogResource ToResource(this Log model)
|
public static LogResource ToResource(this Log model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new LogResource
|
return new LogResource
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,10 @@ namespace Lidarr.Api.V1.Logs
|
||||||
|
|
||||||
protected override IEnumerable<string> GetLogFiles()
|
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)
|
return _diskProvider.GetFiles(_appFolderInfo.GetUpdateLogFolder(), SearchOption.TopDirectoryOnly)
|
||||||
.Where(f => Regex.IsMatch(Path.GetFileName(f), LOGFILE_ROUTE.TrimStart('/'), RegexOptions.IgnoreCase))
|
.Where(f => Regex.IsMatch(Path.GetFileName(f), LOGFILE_ROUTE.TrimStart('/'), RegexOptions.IgnoreCase))
|
||||||
|
@ -45,4 +48,4 @@ namespace Lidarr.Api.V1.Logs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
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;
|
||||||
|
using Lidarr.Http.Extensions;
|
||||||
|
using Nancy;
|
||||||
|
using NLog;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
|
using NzbDrone.Core.MediaFiles.TrackImport.Manual;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.ManualImport
|
namespace Lidarr.Api.V1.ManualImport
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,7 @@ namespace Lidarr.Api.V1.ManualImport
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
|
||||||
GetResourceAll = GetMediaFiles;
|
GetResourceAll = GetMediaFiles;
|
||||||
|
|
||||||
Put("/", options =>
|
Put("/", options =>
|
||||||
{
|
{
|
||||||
var resource = Request.Body.FromJson<List<ManualImportResource>>();
|
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.Real * 10;
|
||||||
item.QualityWeight += item.Quality.Revision.Version;
|
item.QualityWeight += item.Quality.Revision.Version;
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,23 +67,24 @@ namespace Lidarr.Api.V1.ManualImport
|
||||||
var items = new List<ManualImportItem>();
|
var items = new List<ManualImportItem>();
|
||||||
foreach (var resource in resources)
|
foreach (var resource in resources)
|
||||||
{
|
{
|
||||||
items.Add(new ManualImportItem {
|
items.Add(new ManualImportItem
|
||||||
Id = resource.Id,
|
{
|
||||||
Path = resource.Path,
|
Id = resource.Id,
|
||||||
RelativePath = resource.RelativePath,
|
Path = resource.Path,
|
||||||
Name = resource.Name,
|
RelativePath = resource.RelativePath,
|
||||||
Size = resource.Size,
|
Name = resource.Name,
|
||||||
Artist = resource.Artist == null ? null : _artistService.GetArtist(resource.Artist.Id),
|
Size = resource.Size,
|
||||||
Album = resource.Album == null ? null : _albumService.GetAlbum(resource.Album.Id),
|
Artist = resource.Artist == null ? null : _artistService.GetArtist(resource.Artist.Id),
|
||||||
Release = resource.AlbumReleaseId == 0 ? null : _releaseService.GetRelease(resource.AlbumReleaseId),
|
Album = resource.Album == null ? null : _albumService.GetAlbum(resource.Album.Id),
|
||||||
Quality = resource.Quality,
|
Release = resource.AlbumReleaseId == 0 ? null : _releaseService.GetRelease(resource.AlbumReleaseId),
|
||||||
DownloadId = resource.DownloadId,
|
Quality = resource.Quality,
|
||||||
AdditionalFile = resource.AdditionalFile,
|
DownloadId = resource.DownloadId,
|
||||||
ReplaceExistingFiles = resource.ReplaceExistingFiles,
|
AdditionalFile = resource.AdditionalFile,
|
||||||
DisableReleaseSwitching = resource.DisableReleaseSwitching
|
ReplaceExistingFiles = resource.ReplaceExistingFiles,
|
||||||
});
|
DisableReleaseSwitching = resource.DisableReleaseSwitching
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return _manualImportService.UpdateItems(items).Select(x => x.ToResource()).ToList();
|
return _manualImportService.UpdateItems(items).Select(x => x.ToResource()).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.Collections.Generic;
|
||||||
using System.Linq;
|
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.Parser.Model;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.ManualImport
|
namespace Lidarr.Api.V1.ManualImport
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,10 @@ namespace Lidarr.Api.V1.ManualImport
|
||||||
{
|
{
|
||||||
public static ManualImportResource ToResource(this ManualImportItem model)
|
public static ManualImportResource ToResource(this ManualImportItem model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new ManualImportResource
|
return new ManualImportResource
|
||||||
{
|
{
|
||||||
|
@ -49,6 +52,7 @@ namespace Lidarr.Api.V1.ManualImport
|
||||||
AlbumReleaseId = model.Release?.Id ?? 0,
|
AlbumReleaseId = model.Release?.Id ?? 0,
|
||||||
Tracks = model.Tracks.ToResource(),
|
Tracks = model.Tracks.ToResource(),
|
||||||
Quality = model.Quality,
|
Quality = model.Quality,
|
||||||
|
|
||||||
//QualityWeight
|
//QualityWeight
|
||||||
DownloadId = model.DownloadId,
|
DownloadId = model.DownloadId,
|
||||||
Rejections = model.Rejections,
|
Rejections = model.Rejections,
|
||||||
|
|
|
@ -10,21 +10,22 @@ namespace Lidarr.Api.V1.MediaCovers
|
||||||
{
|
{
|
||||||
public class MediaCoverModule : LidarrV1Module
|
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_ARTIST_ROUTE = @"/Artist/(?<artistId>\d+)/(?<filename>(.+)\.(jpg|png|gif))";
|
||||||
private const string MEDIA_COVER_ALBUM_ROUTE = @"/Album/(?<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 IAppFolderInfo _appFolderInfo;
|
||||||
private readonly IDiskProvider _diskProvider;
|
private readonly IDiskProvider _diskProvider;
|
||||||
|
|
||||||
public MediaCoverModule(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider) : base("MediaCover")
|
public MediaCoverModule(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider)
|
||||||
|
: base("MediaCover")
|
||||||
{
|
{
|
||||||
_appFolderInfo = appFolderInfo;
|
_appFolderInfo = appFolderInfo;
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
|
|
||||||
Get(MEDIA_COVER_ARTIST_ROUTE, options => GetArtistMediaCover(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));
|
Get(MEDIA_COVER_ALBUM_ROUTE, options => GetAlbumMediaCover(options.artistId, options.filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
private object GetArtistMediaCover(int artistId, string filename)
|
private object GetArtistMediaCover(int artistId, string filename)
|
||||||
|
@ -40,6 +41,7 @@ namespace Lidarr.Api.V1.MediaCovers
|
||||||
{
|
{
|
||||||
return new NotFoundResponse();
|
return new NotFoundResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
filePath = basefilePath;
|
filePath = basefilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +61,7 @@ namespace Lidarr.Api.V1.MediaCovers
|
||||||
{
|
{
|
||||||
return new NotFoundResponse();
|
return new NotFoundResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
filePath = basefilePath;
|
filePath = basefilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,12 @@ namespace Lidarr.Api.V1.Metadata
|
||||||
|
|
||||||
protected override void Validate(MetadataDefinition definition, bool includeWarnings)
|
protected override void Validate(MetadataDefinition definition, bool includeWarnings)
|
||||||
{
|
{
|
||||||
if (!definition.Enable) return;
|
if (!definition.Enable)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
base.Validate(definition, includeWarnings);
|
base.Validate(definition, includeWarnings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,10 @@ namespace Lidarr.Api.V1.Metadata
|
||||||
{
|
{
|
||||||
public override MetadataResource ToResource(MetadataDefinition definition)
|
public override MetadataResource ToResource(MetadataDefinition definition)
|
||||||
{
|
{
|
||||||
if (definition == null) return null;
|
if (definition == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var resource = base.ToResource(definition);
|
var resource = base.ToResource(definition);
|
||||||
|
|
||||||
|
@ -22,7 +25,10 @@ namespace Lidarr.Api.V1.Metadata
|
||||||
|
|
||||||
public override MetadataDefinition ToModel(MetadataResource resource)
|
public override MetadataDefinition ToModel(MetadataResource resource)
|
||||||
{
|
{
|
||||||
if (resource == null) return null;
|
if (resource == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var definition = base.ToModel(resource);
|
var definition = base.ToModel(resource);
|
||||||
|
|
||||||
|
@ -31,4 +37,4 @@ namespace Lidarr.Api.V1.Metadata
|
||||||
return definition;
|
return definition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,11 @@ namespace Lidarr.Api.V1.Notifications
|
||||||
|
|
||||||
protected override void Validate(NotificationDefinition definition, bool includeWarnings)
|
protected override void Validate(NotificationDefinition definition, bool includeWarnings)
|
||||||
{
|
{
|
||||||
if (!definition.Enable) return;
|
if (!definition.Enable)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
base.Validate(definition, includeWarnings);
|
base.Validate(definition, includeWarnings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,10 @@ namespace Lidarr.Api.V1.Notifications
|
||||||
{
|
{
|
||||||
public override NotificationResource ToResource(NotificationDefinition definition)
|
public override NotificationResource ToResource(NotificationDefinition definition)
|
||||||
{
|
{
|
||||||
if (definition == null) return default(NotificationResource);
|
if (definition == null)
|
||||||
|
{
|
||||||
|
return default(NotificationResource);
|
||||||
|
}
|
||||||
|
|
||||||
var resource = base.ToResource(definition);
|
var resource = base.ToResource(definition);
|
||||||
|
|
||||||
|
@ -56,7 +59,10 @@ namespace Lidarr.Api.V1.Notifications
|
||||||
|
|
||||||
public override NotificationDefinition ToModel(NotificationResource resource)
|
public override NotificationDefinition ToModel(NotificationResource resource)
|
||||||
{
|
{
|
||||||
if (resource == null) return default(NotificationDefinition);
|
if (resource == null)
|
||||||
|
{
|
||||||
|
return default(NotificationDefinition);
|
||||||
|
}
|
||||||
|
|
||||||
var definition = base.ToModel(resource);
|
var definition = base.ToModel(resource);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
using NzbDrone.Common.Extensions;
|
|
||||||
using NzbDrone.Core.Parser;
|
|
||||||
using Lidarr.Api.V1.Albums;
|
using Lidarr.Api.V1.Albums;
|
||||||
using Lidarr.Api.V1.Artist;
|
using Lidarr.Api.V1.Artist;
|
||||||
using Lidarr.Http;
|
using Lidarr.Http;
|
||||||
|
using NzbDrone.Core.Parser;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Parse
|
namespace Lidarr.Api.V1.Parse
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NzbDrone.Core.Parser.Model;
|
|
||||||
using Lidarr.Api.V1.Albums;
|
using Lidarr.Api.V1.Albums;
|
||||||
using Lidarr.Api.V1.Artist;
|
using Lidarr.Api.V1.Artist;
|
||||||
using Lidarr.Http.REST;
|
using Lidarr.Http.REST;
|
||||||
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Parse
|
namespace Lidarr.Api.V1.Parse
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using FluentValidation.Results;
|
|
||||||
using Nancy;
|
|
||||||
using NzbDrone.Core.Profiles.Delay;
|
|
||||||
using Lidarr.Http;
|
using Lidarr.Http;
|
||||||
using Lidarr.Http.Extensions;
|
|
||||||
using Lidarr.Http.REST;
|
using Lidarr.Http.REST;
|
||||||
using Lidarr.Http.Validation;
|
using Lidarr.Http.Validation;
|
||||||
|
using Nancy;
|
||||||
|
using NzbDrone.Core.Profiles.Delay;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Profiles.Delay
|
namespace Lidarr.Api.V1.Profiles.Delay
|
||||||
{
|
{
|
||||||
|
@ -24,7 +22,7 @@ namespace Lidarr.Api.V1.Profiles.Delay
|
||||||
UpdateResource = Update;
|
UpdateResource = Update;
|
||||||
CreateResource = Create;
|
CreateResource = Create;
|
||||||
DeleteResource = DeleteProfile;
|
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).NotEmpty().When(d => d.Id != 1);
|
||||||
SharedValidator.RuleFor(d => d.Tags).EmptyCollection<DelayProfileResource, int>().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();
|
return _delayProfileService.Reorder(id, afterId).ToResource();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Lidarr.Http.REST;
|
||||||
using NzbDrone.Core.Indexers;
|
using NzbDrone.Core.Indexers;
|
||||||
using NzbDrone.Core.Profiles.Delay;
|
using NzbDrone.Core.Profiles.Delay;
|
||||||
using Lidarr.Http.REST;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Profiles.Delay
|
namespace Lidarr.Api.V1.Profiles.Delay
|
||||||
{
|
{
|
||||||
|
@ -21,7 +21,10 @@ namespace Lidarr.Api.V1.Profiles.Delay
|
||||||
{
|
{
|
||||||
public static DelayProfileResource ToResource(this DelayProfile model)
|
public static DelayProfileResource ToResource(this DelayProfile model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new DelayProfileResource
|
return new DelayProfileResource
|
||||||
{
|
{
|
||||||
|
@ -39,7 +42,10 @@ namespace Lidarr.Api.V1.Profiles.Delay
|
||||||
|
|
||||||
public static DelayProfile ToModel(this DelayProfileResource resource)
|
public static DelayProfile ToModel(this DelayProfileResource resource)
|
||||||
{
|
{
|
||||||
if (resource == null) return null;
|
if (resource == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new DelayProfile
|
return new DelayProfile
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using NzbDrone.Core.Profiles.Metadata;
|
|
||||||
using Lidarr.Http;
|
using Lidarr.Http;
|
||||||
|
using NzbDrone.Core.Profiles.Metadata;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Profiles.Metadata
|
namespace Lidarr.Api.V1.Profiles.Metadata
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Core.Profiles.Metadata;
|
|
||||||
using Lidarr.Http.REST;
|
using Lidarr.Http.REST;
|
||||||
|
using NzbDrone.Core.Profiles.Metadata;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.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)
|
public static MetadataProfileResource ToResource(this MetadataProfile model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new MetadataProfileResource
|
return new MetadataProfileResource
|
||||||
{
|
{
|
||||||
|
@ -49,7 +52,10 @@ namespace Lidarr.Api.V1.Profiles.Metadata
|
||||||
|
|
||||||
public static ProfilePrimaryAlbumTypeItemResource ToResource(this ProfilePrimaryAlbumTypeItem model)
|
public static ProfilePrimaryAlbumTypeItemResource ToResource(this ProfilePrimaryAlbumTypeItem model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new ProfilePrimaryAlbumTypeItemResource
|
return new ProfilePrimaryAlbumTypeItemResource
|
||||||
{
|
{
|
||||||
|
@ -105,7 +111,10 @@ namespace Lidarr.Api.V1.Profiles.Metadata
|
||||||
|
|
||||||
public static ProfilePrimaryAlbumTypeItem ToModel(this ProfilePrimaryAlbumTypeItemResource resource)
|
public static ProfilePrimaryAlbumTypeItem ToModel(this ProfilePrimaryAlbumTypeItemResource resource)
|
||||||
{
|
{
|
||||||
if (resource == null) return null;
|
if (resource == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new ProfilePrimaryAlbumTypeItem
|
return new ProfilePrimaryAlbumTypeItem
|
||||||
{
|
{
|
||||||
|
@ -116,10 +125,13 @@ namespace Lidarr.Api.V1.Profiles.Metadata
|
||||||
|
|
||||||
public static ProfileSecondaryAlbumTypeItem ToModel(this ProfileSecondaryAlbumTypeItemResource resource)
|
public static ProfileSecondaryAlbumTypeItem ToModel(this ProfileSecondaryAlbumTypeItemResource resource)
|
||||||
{
|
{
|
||||||
if (resource == null) return null;
|
if (resource == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new ProfileSecondaryAlbumTypeItem
|
return new ProfileSecondaryAlbumTypeItem
|
||||||
{
|
{
|
||||||
SecondaryAlbumType = (NzbDrone.Core.Music.SecondaryAlbumType)resource.AlbumType.Id,
|
SecondaryAlbumType = (NzbDrone.Core.Music.SecondaryAlbumType)resource.AlbumType.Id,
|
||||||
Allowed = resource.Allowed
|
Allowed = resource.Allowed
|
||||||
};
|
};
|
||||||
|
@ -127,7 +139,10 @@ namespace Lidarr.Api.V1.Profiles.Metadata
|
||||||
|
|
||||||
public static ProfileReleaseStatusItem ToModel(this ProfileReleaseStatusItemResource resource)
|
public static ProfileReleaseStatusItem ToModel(this ProfileReleaseStatusItemResource resource)
|
||||||
{
|
{
|
||||||
if (resource == null) return null;
|
if (resource == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new ProfileReleaseStatusItem
|
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();
|
return models.Select(ToResource).ToList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Core.Profiles.Metadata;
|
|
||||||
using Lidarr.Http;
|
using Lidarr.Http;
|
||||||
|
using NzbDrone.Core.Profiles.Metadata;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Profiles.Metadata
|
namespace Lidarr.Api.V1.Profiles.Metadata
|
||||||
{
|
{
|
||||||
public class MetadataProfileSchemaModule : LidarrRestModule<MetadataProfileResource>
|
public class MetadataProfileSchemaModule : LidarrRestModule<MetadataProfileResource>
|
||||||
{
|
{
|
||||||
|
|
||||||
public MetadataProfileSchemaModule()
|
public MetadataProfileSchemaModule()
|
||||||
: base("/metadataprofile/schema")
|
: base("/metadataprofile/schema")
|
||||||
{
|
{
|
||||||
|
@ -28,23 +27,23 @@ namespace Lidarr.Api.V1.Profiles.Metadata
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var primTypes = orderedPrimTypes
|
var primTypes = orderedPrimTypes
|
||||||
.Select(v => new ProfilePrimaryAlbumTypeItem {PrimaryAlbumType = v, Allowed = false})
|
.Select(v => new ProfilePrimaryAlbumTypeItem { PrimaryAlbumType = v, Allowed = false })
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var secTypes = orderedSecTypes
|
var secTypes = orderedSecTypes
|
||||||
.Select(v => new ProfileSecondaryAlbumTypeItem {SecondaryAlbumType = v, Allowed = false})
|
.Select(v => new ProfileSecondaryAlbumTypeItem { SecondaryAlbumType = v, Allowed = false })
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var relStatuses = orderedRelStatuses
|
var relStatuses = orderedRelStatuses
|
||||||
.Select(v => new ProfileReleaseStatusItem {ReleaseStatus = v, Allowed = false})
|
.Select(v => new ProfileReleaseStatusItem { ReleaseStatus = v, Allowed = false })
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var profile = new MetadataProfile
|
var profile = new MetadataProfile
|
||||||
{
|
{
|
||||||
PrimaryAlbumTypes = primTypes,
|
PrimaryAlbumTypes = primTypes,
|
||||||
SecondaryAlbumTypes = secTypes,
|
SecondaryAlbumTypes = secTypes,
|
||||||
ReleaseStatuses = relStatuses
|
ReleaseStatuses = relStatuses
|
||||||
};
|
};
|
||||||
|
|
||||||
return profile.ToResource();
|
return profile.ToResource();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ namespace Lidarr.Api.V1.Profiles.Metadata
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class PrimaryTypeValidator<T> : PropertyValidator
|
public class PrimaryTypeValidator<T> : PropertyValidator
|
||||||
{
|
{
|
||||||
public PrimaryTypeValidator()
|
public PrimaryTypeValidator()
|
||||||
|
|
|
@ -18,7 +18,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
|
||||||
public ValidCutoffValidator()
|
public ValidCutoffValidator()
|
||||||
: base("Cutoff must be an allowed quality or group")
|
: base("Cutoff must be an allowed quality or group")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool IsValid(PropertyValidatorContext context)
|
protected override bool IsValid(PropertyValidatorContext context)
|
||||||
|
|
|
@ -26,7 +26,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
|
||||||
public AllowedValidator()
|
public AllowedValidator()
|
||||||
: base("Must contain at least one allowed quality")
|
: base("Must contain at least one allowed quality")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool IsValid(PropertyValidatorContext context)
|
protected override bool IsValid(PropertyValidatorContext context)
|
||||||
|
@ -52,7 +51,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
|
||||||
public GroupItemValidator()
|
public GroupItemValidator()
|
||||||
: base("Groups must contain multiple qualities")
|
: base("Groups must contain multiple qualities")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool IsValid(PropertyValidatorContext context)
|
protected override bool IsValid(PropertyValidatorContext context)
|
||||||
|
@ -73,7 +71,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
|
||||||
public QualityNameValidator()
|
public QualityNameValidator()
|
||||||
: base("Individual qualities should not be named")
|
: base("Individual qualities should not be named")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool IsValid(PropertyValidatorContext context)
|
protected override bool IsValid(PropertyValidatorContext context)
|
||||||
|
@ -94,7 +91,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
|
||||||
public ItemGroupNameValidator()
|
public ItemGroupNameValidator()
|
||||||
: base("Groups must have a name")
|
: base("Groups must have a name")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool IsValid(PropertyValidatorContext context)
|
protected override bool IsValid(PropertyValidatorContext context)
|
||||||
|
@ -115,7 +111,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
|
||||||
public ItemGroupIdValidator()
|
public ItemGroupIdValidator()
|
||||||
: base("Groups must have an ID")
|
: base("Groups must have an ID")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool IsValid(PropertyValidatorContext context)
|
protected override bool IsValid(PropertyValidatorContext context)
|
||||||
|
@ -136,7 +131,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
|
||||||
public UniqueIdValidator()
|
public UniqueIdValidator()
|
||||||
: base("Groups must have a unique ID")
|
: base("Groups must have a unique ID")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool IsValid(PropertyValidatorContext context)
|
protected override bool IsValid(PropertyValidatorContext context)
|
||||||
|
@ -157,7 +151,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
|
||||||
public UniqueQualityIdValidator()
|
public UniqueQualityIdValidator()
|
||||||
: base("Qualities can only be used once")
|
: base("Qualities can only be used once")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool IsValid(PropertyValidatorContext context)
|
protected override bool IsValid(PropertyValidatorContext context)
|
||||||
|
@ -179,7 +172,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
|
||||||
qualityIds.Add(quality.Quality.Id);
|
qualityIds.Add(quality.Quality.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (qualityIds.Contains(item.Quality.Id))
|
if (qualityIds.Contains(item.Quality.Id))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using NzbDrone.Core.Profiles.Qualities;
|
|
||||||
using Lidarr.Http;
|
using Lidarr.Http;
|
||||||
|
using NzbDrone.Core.Profiles.Qualities;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Profiles.Quality
|
namespace Lidarr.Api.V1.Profiles.Quality
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Core.Profiles.Qualities;
|
|
||||||
using Lidarr.Http.REST;
|
using Lidarr.Http.REST;
|
||||||
|
using NzbDrone.Core.Profiles.Qualities;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Profiles.Quality
|
namespace Lidarr.Api.V1.Profiles.Quality
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,10 @@ namespace Lidarr.Api.V1.Profiles.Quality
|
||||||
{
|
{
|
||||||
public static QualityProfileResource ToResource(this QualityProfile model)
|
public static QualityProfileResource ToResource(this QualityProfile model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new QualityProfileResource
|
return new QualityProfileResource
|
||||||
{
|
{
|
||||||
|
@ -44,7 +47,10 @@ namespace Lidarr.Api.V1.Profiles.Quality
|
||||||
|
|
||||||
public static QualityProfileQualityItemResource ToResource(this QualityProfileQualityItem model)
|
public static QualityProfileQualityItemResource ToResource(this QualityProfileQualityItem model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new QualityProfileQualityItemResource
|
return new QualityProfileQualityItemResource
|
||||||
{
|
{
|
||||||
|
@ -58,7 +64,10 @@ namespace Lidarr.Api.V1.Profiles.Quality
|
||||||
|
|
||||||
public static QualityProfile ToModel(this QualityProfileResource resource)
|
public static QualityProfile ToModel(this QualityProfileResource resource)
|
||||||
{
|
{
|
||||||
if (resource == null) return null;
|
if (resource == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new QualityProfile
|
return new QualityProfile
|
||||||
{
|
{
|
||||||
|
@ -72,7 +81,10 @@ namespace Lidarr.Api.V1.Profiles.Quality
|
||||||
|
|
||||||
public static QualityProfileQualityItem ToModel(this QualityProfileQualityItemResource resource)
|
public static QualityProfileQualityItem ToModel(this QualityProfileQualityItemResource resource)
|
||||||
{
|
{
|
||||||
if (resource == null) return null;
|
if (resource == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new QualityProfileQualityItem
|
return new QualityProfileQualityItem
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using NzbDrone.Core.Profiles.Qualities;
|
|
||||||
using Lidarr.Http;
|
using Lidarr.Http;
|
||||||
|
using NzbDrone.Core.Profiles.Qualities;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Profiles.Quality
|
namespace Lidarr.Api.V1.Profiles.Quality
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,6 @@ namespace Lidarr.Api.V1.Profiles.Quality
|
||||||
{
|
{
|
||||||
QualityProfile qualityProfile = _profileService.GetDefaultProfile(string.Empty);
|
QualityProfile qualityProfile = _profileService.GetDefaultProfile(string.Empty);
|
||||||
|
|
||||||
|
|
||||||
return qualityProfile.ToResource();
|
return qualityProfile.ToResource();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
using Lidarr.Http;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Profiles.Releases;
|
using NzbDrone.Core.Profiles.Releases;
|
||||||
using Lidarr.Http;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Profiles.Release
|
namespace Lidarr.Api.V1.Profiles.Release
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,6 @@ namespace Lidarr.Api.V1.Profiles.Release
|
||||||
{
|
{
|
||||||
private readonly IReleaseProfileService _releaseProfileService;
|
private readonly IReleaseProfileService _releaseProfileService;
|
||||||
|
|
||||||
|
|
||||||
public ReleaseProfileModule(IReleaseProfileService releaseProfileService)
|
public ReleaseProfileModule(IReleaseProfileService releaseProfileService)
|
||||||
{
|
{
|
||||||
_releaseProfileService = releaseProfileService;
|
_releaseProfileService = releaseProfileService;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Core.Profiles.Releases;
|
|
||||||
using Lidarr.Http.REST;
|
using Lidarr.Http.REST;
|
||||||
|
using NzbDrone.Core.Profiles.Releases;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Profiles.Release
|
namespace Lidarr.Api.V1.Profiles.Release
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,10 @@ namespace Lidarr.Api.V1.Profiles.Release
|
||||||
{
|
{
|
||||||
public static ReleaseProfileResource ToResource(this ReleaseProfile model)
|
public static ReleaseProfileResource ToResource(this ReleaseProfile model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new ReleaseProfileResource
|
return new ReleaseProfileResource
|
||||||
{
|
{
|
||||||
|
@ -39,7 +42,10 @@ namespace Lidarr.Api.V1.Profiles.Release
|
||||||
|
|
||||||
public static ReleaseProfile ToModel(this ReleaseProfileResource resource)
|
public static ReleaseProfile ToModel(this ReleaseProfileResource resource)
|
||||||
{
|
{
|
||||||
if (resource == null) return null;
|
if (resource == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new ReleaseProfile
|
return new ReleaseProfile
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,13 +2,11 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using FluentValidation.Results;
|
using FluentValidation.Results;
|
||||||
|
using Lidarr.Http;
|
||||||
using Nancy;
|
using Nancy;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using NzbDrone.Common.Serializer;
|
using NzbDrone.Common.Serializer;
|
||||||
using NzbDrone.Core.ThingiProvider;
|
using NzbDrone.Core.ThingiProvider;
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
using Lidarr.Http;
|
|
||||||
using Lidarr.Http.Extensions;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1
|
namespace Lidarr.Api.V1
|
||||||
{
|
{
|
||||||
|
@ -26,10 +24,10 @@ namespace Lidarr.Api.V1
|
||||||
_providerFactory = providerFactory;
|
_providerFactory = providerFactory;
|
||||||
_resourceMapper = resourceMapper;
|
_resourceMapper = resourceMapper;
|
||||||
|
|
||||||
Get("schema", x => GetTemplates());
|
Get("schema", x => GetTemplates());
|
||||||
Post("test", x => Test(ReadResourceFromRequest(true)));
|
Post("test", x => Test(ReadResourceFromRequest(true)));
|
||||||
Post("testall", x => TestAll());
|
Post("testall", x => TestAll());
|
||||||
Post("action/{action}", x => RequestAction(x.action, ReadResourceFromRequest(true)));
|
Post("action/{action}", x => RequestAction(x.action, ReadResourceFromRequest(true)));
|
||||||
|
|
||||||
GetResourceAll = GetAll;
|
GetResourceAll = GetAll;
|
||||||
GetResourceById = GetProviderById;
|
GetResourceById = GetProviderById;
|
||||||
|
@ -38,7 +36,7 @@ namespace Lidarr.Api.V1
|
||||||
DeleteResource = DeleteProvider;
|
DeleteResource = DeleteProvider;
|
||||||
|
|
||||||
SharedValidator.RuleFor(c => c.Name).NotEmpty();
|
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.Implementation).NotEmpty();
|
||||||
SharedValidator.RuleFor(c => c.ConfigContract).NotEmpty();
|
SharedValidator.RuleFor(c => c.ConfigContract).NotEmpty();
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NzbDrone.Common.Reflection;
|
|
||||||
using NzbDrone.Core.ThingiProvider;
|
|
||||||
using Lidarr.Http.ClientSchema;
|
using Lidarr.Http.ClientSchema;
|
||||||
using Lidarr.Http.REST;
|
using Lidarr.Http.REST;
|
||||||
|
using NzbDrone.Common.Reflection;
|
||||||
|
using NzbDrone.Core.ThingiProvider;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1
|
namespace Lidarr.Api.V1
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,6 @@ namespace Lidarr.Api.V1
|
||||||
where TProviderDefinition : ProviderDefinition, new()
|
where TProviderDefinition : ProviderDefinition, new()
|
||||||
{
|
{
|
||||||
public virtual TProviderResource ToResource(TProviderDefinition definition)
|
public virtual TProviderResource ToResource(TProviderDefinition definition)
|
||||||
|
|
||||||
{
|
{
|
||||||
return new TProviderResource
|
return new TProviderResource
|
||||||
{
|
{
|
||||||
|
@ -47,7 +46,10 @@ namespace Lidarr.Api.V1
|
||||||
|
|
||||||
public virtual TProviderDefinition ToModel(TProviderResource resource)
|
public virtual TProviderDefinition ToModel(TProviderResource resource)
|
||||||
{
|
{
|
||||||
if (resource == null) return default(TProviderDefinition);
|
if (resource == null)
|
||||||
|
{
|
||||||
|
return default(TProviderDefinition);
|
||||||
|
}
|
||||||
|
|
||||||
var definition = new TProviderDefinition
|
var definition = new TProviderDefinition
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Nancy;
|
|
||||||
using NzbDrone.Core.Qualities;
|
|
||||||
using Lidarr.Http;
|
using Lidarr.Http;
|
||||||
using Lidarr.Http.Extensions;
|
using Lidarr.Http.Extensions;
|
||||||
|
using Nancy;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Qualities
|
namespace Lidarr.Api.V1.Qualities
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,7 @@ namespace Lidarr.Api.V1.Qualities
|
||||||
GetResourceAll = GetAll;
|
GetResourceAll = GetAll;
|
||||||
GetResourceById = GetById;
|
GetResourceById = GetById;
|
||||||
UpdateResource = Update;
|
UpdateResource = Update;
|
||||||
Put("/update", d => UpdateMany());
|
Put("/update", d => UpdateMany());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update(QualityDefinitionResource resource)
|
private void Update(QualityDefinitionResource resource)
|
||||||
|
@ -47,8 +47,8 @@ namespace Lidarr.Api.V1.Qualities
|
||||||
_qualityDefinitionService.UpdateMany(qualityDefinitions);
|
_qualityDefinitionService.UpdateMany(qualityDefinitions);
|
||||||
|
|
||||||
return ResponseWithCode(_qualityDefinitionService.All()
|
return ResponseWithCode(_qualityDefinitionService.All()
|
||||||
.ToResource()
|
.ToResource(),
|
||||||
, HttpStatusCode.Accepted);
|
HttpStatusCode.Accepted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Core.Qualities;
|
|
||||||
using Lidarr.Http.REST;
|
using Lidarr.Http.REST;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Qualities
|
namespace Lidarr.Api.V1.Qualities
|
||||||
{
|
{
|
||||||
|
@ -21,7 +21,10 @@ namespace Lidarr.Api.V1.Qualities
|
||||||
{
|
{
|
||||||
public static QualityDefinitionResource ToResource(this QualityDefinition model)
|
public static QualityDefinitionResource ToResource(this QualityDefinition model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new QualityDefinitionResource
|
return new QualityDefinitionResource
|
||||||
{
|
{
|
||||||
|
@ -36,7 +39,10 @@ namespace Lidarr.Api.V1.Qualities
|
||||||
|
|
||||||
public static QualityDefinition ToModel(this QualityDefinitionResource resource)
|
public static QualityDefinition ToModel(this QualityDefinitionResource resource)
|
||||||
{
|
{
|
||||||
if (resource == null) return null;
|
if (resource == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new QualityDefinition
|
return new QualityDefinition
|
||||||
{
|
{
|
||||||
|
@ -59,4 +65,4 @@ namespace Lidarr.Api.V1.Qualities
|
||||||
return resources.Select(ToModel).ToList();
|
return resources.Select(ToModel).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Lidarr.Http;
|
||||||
|
using Lidarr.Http.Extensions;
|
||||||
|
using Lidarr.Http.REST;
|
||||||
using Nancy;
|
using Nancy;
|
||||||
using NzbDrone.Core.Download;
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Download.Pending;
|
using NzbDrone.Core.Download.Pending;
|
||||||
using NzbDrone.Core.Download.TrackedDownloads;
|
using NzbDrone.Core.Download.TrackedDownloads;
|
||||||
using NzbDrone.Core.Queue;
|
using NzbDrone.Core.Queue;
|
||||||
using Lidarr.Http;
|
|
||||||
using Lidarr.Http.Extensions;
|
|
||||||
using Lidarr.Http.REST;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Queue
|
namespace Lidarr.Api.V1.Queue
|
||||||
{
|
{
|
||||||
|
@ -34,11 +33,11 @@ namespace Lidarr.Api.V1.Queue
|
||||||
_pendingReleaseService = pendingReleaseService;
|
_pendingReleaseService = pendingReleaseService;
|
||||||
_downloadService = downloadService;
|
_downloadService = downloadService;
|
||||||
|
|
||||||
Post(@"/grab/(?<id>[\d]{1,10})", x => Grab((int)x.Id));
|
Post(@"/grab/(?<id>[\d]{1,10})", x => Grab((int)x.Id));
|
||||||
Post("/grab/bulk", x => Grab());
|
Post("/grab/bulk", x => Grab());
|
||||||
|
|
||||||
Delete(@"/(?<id>[\d]{1,10})", x => Remove((int)x.Id));
|
Delete(@"/(?<id>[\d]{1,10})", x => Remove((int)x.Id));
|
||||||
Delete("/bulk", x => Remove());
|
Delete("/bulk", x => Remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
private object Grab(int id)
|
private object Grab(int id)
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Lidarr.Http;
|
||||||
|
using Lidarr.Http.Extensions;
|
||||||
using NzbDrone.Core.Datastore.Events;
|
using NzbDrone.Core.Datastore.Events;
|
||||||
using NzbDrone.Core.Download.Pending;
|
using NzbDrone.Core.Download.Pending;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
using NzbDrone.Core.Queue;
|
using NzbDrone.Core.Queue;
|
||||||
using NzbDrone.SignalR;
|
using NzbDrone.SignalR;
|
||||||
using Lidarr.Http;
|
|
||||||
using Lidarr.Http.Extensions;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Queue
|
namespace Lidarr.Api.V1.Queue
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Lidarr.Http;
|
||||||
|
using Lidarr.Http.Extensions;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Configuration;
|
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.Datastore.Events;
|
using NzbDrone.Core.Datastore.Events;
|
||||||
using NzbDrone.Core.Download.Pending;
|
using NzbDrone.Core.Download.Pending;
|
||||||
|
@ -10,8 +11,6 @@ using NzbDrone.Core.Profiles.Qualities;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
using NzbDrone.Core.Queue;
|
using NzbDrone.Core.Queue;
|
||||||
using NzbDrone.SignalR;
|
using NzbDrone.SignalR;
|
||||||
using Lidarr.Http;
|
|
||||||
using Lidarr.Http.Extensions;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Queue
|
namespace Lidarr.Api.V1.Queue
|
||||||
{
|
{
|
||||||
|
@ -21,7 +20,7 @@ namespace Lidarr.Api.V1.Queue
|
||||||
private readonly IQueueService _queueService;
|
private readonly IQueueService _queueService;
|
||||||
private readonly IPendingReleaseService _pendingReleaseService;
|
private readonly IPendingReleaseService _pendingReleaseService;
|
||||||
|
|
||||||
private readonly QualityModelComparer QUALITY_COMPARER;
|
private readonly QualityModelComparer _qualityComparer;
|
||||||
|
|
||||||
public QueueModule(IBroadcastSignalRMessage broadcastSignalRMessage,
|
public QueueModule(IBroadcastSignalRMessage broadcastSignalRMessage,
|
||||||
IQueueService queueService,
|
IQueueService queueService,
|
||||||
|
@ -33,7 +32,7 @@ namespace Lidarr.Api.V1.Queue
|
||||||
_pendingReleaseService = pendingReleaseService;
|
_pendingReleaseService = pendingReleaseService;
|
||||||
GetResourcePaged = GetQueue;
|
GetResourcePaged = GetQueue;
|
||||||
|
|
||||||
QUALITY_COMPARER = new QualityModelComparer(qualityProfileService.GetDefaultProfile(string.Empty));
|
_qualityComparer = new QualityModelComparer(qualityProfileService.GetDefaultProfile(string.Empty));
|
||||||
}
|
}
|
||||||
|
|
||||||
private PagingResource<QueueResource> GetQueue(PagingResource<QueueResource> pagingResource)
|
private PagingResource<QueueResource> GetQueue(PagingResource<QueueResource> pagingResource)
|
||||||
|
@ -63,7 +62,6 @@ namespace Lidarr.Api.V1.Queue
|
||||||
? fullQueue.OrderBy(q => q.Timeleft, new TimeleftComparer())
|
? fullQueue.OrderBy(q => q.Timeleft, new TimeleftComparer())
|
||||||
: fullQueue.OrderByDescending(q => q.Timeleft, new TimeleftComparer());
|
: fullQueue.OrderByDescending(q => q.Timeleft, new TimeleftComparer());
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (pagingSpec.SortKey == "estimatedCompletionTime")
|
else if (pagingSpec.SortKey == "estimatedCompletionTime")
|
||||||
{
|
{
|
||||||
ordered = ascending
|
ordered = ascending
|
||||||
|
@ -71,41 +69,36 @@ namespace Lidarr.Api.V1.Queue
|
||||||
: fullQueue.OrderByDescending(q => q.EstimatedCompletionTime,
|
: fullQueue.OrderByDescending(q => q.EstimatedCompletionTime,
|
||||||
new EstimatedCompletionTimeComparer());
|
new EstimatedCompletionTimeComparer());
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (pagingSpec.SortKey == "protocol")
|
else if (pagingSpec.SortKey == "protocol")
|
||||||
{
|
{
|
||||||
ordered = ascending
|
ordered = ascending
|
||||||
? fullQueue.OrderBy(q => q.Protocol)
|
? fullQueue.OrderBy(q => q.Protocol)
|
||||||
: fullQueue.OrderByDescending(q => q.Protocol);
|
: fullQueue.OrderByDescending(q => q.Protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (pagingSpec.SortKey == "indexer")
|
else if (pagingSpec.SortKey == "indexer")
|
||||||
{
|
{
|
||||||
ordered = ascending
|
ordered = ascending
|
||||||
? fullQueue.OrderBy(q => q.Indexer, StringComparer.InvariantCultureIgnoreCase)
|
? fullQueue.OrderBy(q => q.Indexer, StringComparer.InvariantCultureIgnoreCase)
|
||||||
: fullQueue.OrderByDescending(q => q.Indexer, StringComparer.InvariantCultureIgnoreCase);
|
: fullQueue.OrderByDescending(q => q.Indexer, StringComparer.InvariantCultureIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (pagingSpec.SortKey == "downloadClient")
|
else if (pagingSpec.SortKey == "downloadClient")
|
||||||
{
|
{
|
||||||
ordered = ascending
|
ordered = ascending
|
||||||
? fullQueue.OrderBy(q => q.DownloadClient, StringComparer.InvariantCultureIgnoreCase)
|
? fullQueue.OrderBy(q => q.DownloadClient, StringComparer.InvariantCultureIgnoreCase)
|
||||||
: fullQueue.OrderByDescending(q => q.DownloadClient, StringComparer.InvariantCultureIgnoreCase);
|
: fullQueue.OrderByDescending(q => q.DownloadClient, StringComparer.InvariantCultureIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (pagingSpec.SortKey == "quality")
|
else if (pagingSpec.SortKey == "quality")
|
||||||
{
|
{
|
||||||
ordered = ascending
|
ordered = ascending
|
||||||
? fullQueue.OrderBy(q => q.Quality, QUALITY_COMPARER)
|
? fullQueue.OrderBy(q => q.Quality, _qualityComparer)
|
||||||
: fullQueue.OrderByDescending(q => q.Quality, QUALITY_COMPARER);
|
: fullQueue.OrderByDescending(q => q.Quality, _qualityComparer);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ordered = ascending ? fullQueue.OrderBy(orderByFunc) : fullQueue.OrderByDescending(orderByFunc);
|
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.Records = ordered.Skip((pagingSpec.Page - 1) * pagingSpec.PageSize).Take(pagingSpec.PageSize).ToList();
|
||||||
pagingSpec.TotalRecords = fullQueue.Count;
|
pagingSpec.TotalRecords = fullQueue.Count;
|
||||||
|
@ -119,7 +112,7 @@ namespace Lidarr.Api.V1.Queue
|
||||||
return pagingSpec;
|
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)
|
switch (pagingSpec.SortKey)
|
||||||
{
|
{
|
||||||
|
@ -139,7 +132,7 @@ namespace Lidarr.Api.V1.Queue
|
||||||
return q => q.Quality;
|
return q => q.Quality;
|
||||||
case "progress":
|
case "progress":
|
||||||
// Avoid exploding if a download's size is 0
|
// 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:
|
default:
|
||||||
return q => q.Timeleft;
|
return q => q.Timeleft;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
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.Albums;
|
||||||
using Lidarr.Api.V1.Artist;
|
using Lidarr.Api.V1.Artist;
|
||||||
using Lidarr.Http.REST;
|
using Lidarr.Http.REST;
|
||||||
|
using NzbDrone.Core.Download.TrackedDownloads;
|
||||||
|
using NzbDrone.Core.Indexers;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Queue
|
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)
|
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
|
return new QueueResource
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Lidarr.Http;
|
||||||
using NzbDrone.Common.TPL;
|
using NzbDrone.Common.TPL;
|
||||||
using NzbDrone.Core.Datastore.Events;
|
using NzbDrone.Core.Datastore.Events;
|
||||||
using NzbDrone.Core.Download.Pending;
|
using NzbDrone.Core.Download.Pending;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
using NzbDrone.Core.Queue;
|
using NzbDrone.Core.Queue;
|
||||||
using NzbDrone.SignalR;
|
using NzbDrone.SignalR;
|
||||||
using Lidarr.Http;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Queue
|
namespace Lidarr.Api.V1.Queue
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,6 @@ namespace Lidarr.Api.V1.Queue
|
||||||
private readonly IPendingReleaseService _pendingReleaseService;
|
private readonly IPendingReleaseService _pendingReleaseService;
|
||||||
private readonly Debouncer _broadcastDebounce;
|
private readonly Debouncer _broadcastDebounce;
|
||||||
|
|
||||||
|
|
||||||
public QueueStatusModule(IBroadcastSignalRMessage broadcastSignalRMessage, IQueueService queueService, IPendingReleaseService pendingReleaseService)
|
public QueueStatusModule(IBroadcastSignalRMessage broadcastSignalRMessage, IQueueService queueService, IPendingReleaseService pendingReleaseService)
|
||||||
: base(broadcastSignalRMessage, "queue/status")
|
: base(broadcastSignalRMessage, "queue/status")
|
||||||
{
|
{
|
||||||
|
@ -26,8 +25,7 @@ namespace Lidarr.Api.V1.Queue
|
||||||
|
|
||||||
_broadcastDebounce = new Debouncer(BroadcastChange, TimeSpan.FromSeconds(5));
|
_broadcastDebounce = new Debouncer(BroadcastChange, TimeSpan.FromSeconds(5));
|
||||||
|
|
||||||
|
Get("/", x => GetQueueStatusResponse());
|
||||||
Get("/", x => GetQueueStatusResponse());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private object GetQueueStatusResponse()
|
private object GetQueueStatusResponse()
|
||||||
|
@ -67,12 +65,10 @@ namespace Lidarr.Api.V1.Queue
|
||||||
{
|
{
|
||||||
_broadcastDebounce.Execute();
|
_broadcastDebounce.Execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Handle(PendingReleasesUpdatedEvent message)
|
public void Handle(PendingReleasesUpdatedEvent message)
|
||||||
{
|
{
|
||||||
_broadcastDebounce.Execute();
|
_broadcastDebounce.Execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
using Lidarr.Http;
|
||||||
using NzbDrone.Core.RemotePathMappings;
|
using NzbDrone.Core.RemotePathMappings;
|
||||||
using NzbDrone.Core.Validation.Paths;
|
using NzbDrone.Core.Validation.Paths;
|
||||||
using Lidarr.Http;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.RemotePathMappings
|
namespace Lidarr.Api.V1.RemotePathMappings
|
||||||
{
|
{
|
||||||
|
@ -65,4 +65,4 @@ namespace Lidarr.Api.V1.RemotePathMappings
|
||||||
_remotePathMappingService.Update(mapping);
|
_remotePathMappingService.Update(mapping);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Core.RemotePathMappings;
|
|
||||||
using Lidarr.Http.REST;
|
using Lidarr.Http.REST;
|
||||||
|
using NzbDrone.Core.RemotePathMappings;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.RemotePathMappings
|
namespace Lidarr.Api.V1.RemotePathMappings
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,10 @@ namespace Lidarr.Api.V1.RemotePathMappings
|
||||||
{
|
{
|
||||||
public static RemotePathMappingResource ToResource(this RemotePathMapping model)
|
public static RemotePathMappingResource ToResource(this RemotePathMapping model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new RemotePathMappingResource
|
return new RemotePathMappingResource
|
||||||
{
|
{
|
||||||
|
@ -30,7 +33,10 @@ namespace Lidarr.Api.V1.RemotePathMappings
|
||||||
|
|
||||||
public static RemotePathMapping ToModel(this RemotePathMappingResource resource)
|
public static RemotePathMapping ToModel(this RemotePathMappingResource resource)
|
||||||
{
|
{
|
||||||
if (resource == null) return null;
|
if (resource == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new RemotePathMapping
|
return new RemotePathMapping
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
using Lidarr.Http;
|
||||||
using NzbDrone.Core.RootFolders;
|
using NzbDrone.Core.RootFolders;
|
||||||
using NzbDrone.Core.Validation.Paths;
|
using NzbDrone.Core.Validation.Paths;
|
||||||
using NzbDrone.SignalR;
|
using NzbDrone.SignalR;
|
||||||
using Lidarr.Http;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.RootFolders
|
namespace Lidarr.Api.V1.RootFolders
|
||||||
{
|
{
|
||||||
|
@ -18,8 +18,7 @@ namespace Lidarr.Api.V1.RootFolders
|
||||||
MappedNetworkDriveValidator mappedNetworkDriveValidator,
|
MappedNetworkDriveValidator mappedNetworkDriveValidator,
|
||||||
StartupFolderValidator startupFolderValidator,
|
StartupFolderValidator startupFolderValidator,
|
||||||
SystemFolderValidator systemFolderValidator,
|
SystemFolderValidator systemFolderValidator,
|
||||||
FolderWritableValidator folderWritableValidator
|
FolderWritableValidator folderWritableValidator)
|
||||||
)
|
|
||||||
: base(signalRBroadcaster)
|
: base(signalRBroadcaster)
|
||||||
{
|
{
|
||||||
_rootFolderService = rootFolderService;
|
_rootFolderService = rootFolderService;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Core.RootFolders;
|
|
||||||
using Lidarr.Http.REST;
|
using Lidarr.Http.REST;
|
||||||
|
using NzbDrone.Core.RootFolders;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.RootFolders
|
namespace Lidarr.Api.V1.RootFolders
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,10 @@ namespace Lidarr.Api.V1.RootFolders
|
||||||
{
|
{
|
||||||
public static RootFolderResource ToResource(this RootFolder model)
|
public static RootFolderResource ToResource(this RootFolder model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new RootFolderResource
|
return new RootFolderResource
|
||||||
{
|
{
|
||||||
|
@ -35,13 +38,17 @@ namespace Lidarr.Api.V1.RootFolders
|
||||||
|
|
||||||
public static RootFolder ToModel(this RootFolderResource resource)
|
public static RootFolder ToModel(this RootFolderResource resource)
|
||||||
{
|
{
|
||||||
if (resource == null) return null;
|
if (resource == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new RootFolder
|
return new RootFolder
|
||||||
{
|
{
|
||||||
Id = resource.Id,
|
Id = resource.Id,
|
||||||
|
|
||||||
Path = resource.Path,
|
Path = resource.Path,
|
||||||
|
|
||||||
//Accessible
|
//Accessible
|
||||||
//FreeSpace
|
//FreeSpace
|
||||||
//UnmappedFolders
|
//UnmappedFolders
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Lidarr.Api.V1.Albums;
|
||||||
|
using Lidarr.Api.V1.Artist;
|
||||||
|
using Lidarr.Http;
|
||||||
using Nancy;
|
using Nancy;
|
||||||
using NzbDrone.Core.MediaCover;
|
using NzbDrone.Core.MediaCover;
|
||||||
using NzbDrone.Core.MetadataSource;
|
using NzbDrone.Core.MetadataSource;
|
||||||
using Lidarr.Http;
|
|
||||||
using Lidarr.Api.V1.Artist;
|
|
||||||
using Lidarr.Api.V1.Albums;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Search
|
namespace Lidarr.Api.V1.Search
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ namespace Lidarr.Api.V1.Search
|
||||||
return MapToResource(searchResults).ToList();
|
return MapToResource(searchResults).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerable<SearchResource> MapToResource(IEnumerable<Object> results)
|
private static IEnumerable<SearchResource> MapToResource(IEnumerable<object> results)
|
||||||
{
|
{
|
||||||
int id = 1;
|
int id = 1;
|
||||||
foreach (var result in results)
|
foreach (var result in results)
|
||||||
|
@ -37,7 +37,7 @@ namespace Lidarr.Api.V1.Search
|
||||||
|
|
||||||
if (result is NzbDrone.Core.Music.Artist)
|
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.Artist = artist.ToResource();
|
||||||
resource.ForeignId = artist.ForeignArtistId;
|
resource.ForeignId = artist.ForeignArtistId;
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ namespace Lidarr.Api.V1.Search
|
||||||
}
|
}
|
||||||
else if (result is NzbDrone.Core.Music.Album)
|
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.Album = album.ToResource();
|
||||||
resource.ForeignId = album.ForeignAlbumId;
|
resource.ForeignId = album.ForeignAlbumId;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using Lidarr.Http.REST;
|
|
||||||
using Lidarr.Api.V1.Artist;
|
|
||||||
using Lidarr.Api.V1.Albums;
|
using Lidarr.Api.V1.Albums;
|
||||||
|
using Lidarr.Api.V1.Artist;
|
||||||
|
using Lidarr.Http.REST;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.Search
|
namespace Lidarr.Api.V1.Search
|
||||||
{
|
{
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue