Files
Readarr/src/Readarr.Api.V1/Profiles/Metadata/MetadataProfileSchemaModule.cs
T
2020-02-29 16:58:13 -05:00

52 lines
1.6 KiB
C#

using System.Linq;
using NzbDrone.Core.Profiles.Metadata;
using Readarr.Http;
namespace Readarr.Api.V1.Profiles.Metadata
{
public class MetadataProfileSchemaModule : ReadarrRestModule<MetadataProfileResource>
{
public MetadataProfileSchemaModule()
: base("/metadataprofile/schema")
{
GetResourceSingle = GetAll;
}
private MetadataProfileResource GetAll()
{
var orderedPrimTypes = NzbDrone.Core.Music.PrimaryAlbumType.All
.OrderByDescending(l => l.Id)
.ToList();
var orderedSecTypes = NzbDrone.Core.Music.SecondaryAlbumType.All
.OrderByDescending(l => l.Id)
.ToList();
var orderedRelStatuses = NzbDrone.Core.Music.ReleaseStatus.All
.OrderByDescending(l => l.Id)
.ToList();
var primTypes = orderedPrimTypes
.Select(v => new ProfilePrimaryAlbumTypeItem { PrimaryAlbumType = v, Allowed = false })
.ToList();
var secTypes = orderedSecTypes
.Select(v => new ProfileSecondaryAlbumTypeItem { SecondaryAlbumType = v, Allowed = false })
.ToList();
var relStatuses = orderedRelStatuses
.Select(v => new ProfileReleaseStatusItem { ReleaseStatus = v, Allowed = false })
.ToList();
var profile = new MetadataProfile
{
PrimaryAlbumTypes = primTypes,
SecondaryAlbumTypes = secTypes,
ReleaseStatuses = relStatuses
};
return profile.ToResource();
}
}
}