Lidarr/src/Lidarr.Api.V1/Blocklist/BlocklistResource.cs

54 lines
1.7 KiB
C#
Raw Normal View History

2017-09-04 02:20:56 +00:00
using System;
using System.Collections.Generic;
2017-10-31 01:28:29 +00:00
using Lidarr.Api.V1.Artist;
using Lidarr.Api.V1.CustomFormats;
2017-09-04 02:20:56 +00:00
using Lidarr.Http.REST;
using NzbDrone.Core.CustomFormats;
using NzbDrone.Core.Qualities;
2017-09-04 02:20:56 +00:00
2021-08-19 21:35:06 +00:00
namespace Lidarr.Api.V1.Blocklist
2017-09-04 02:20:56 +00:00
{
2021-08-19 21:35:06 +00:00
public class BlocklistResource : RestResource
2017-09-04 02:20:56 +00:00
{
public int ArtistId { get; set; }
public List<int> AlbumIds { get; set; }
public string SourceTitle { get; set; }
public QualityModel Quality { get; set; }
public List<CustomFormatResource> CustomFormats { get; set; }
2017-09-04 02:20:56 +00:00
public DateTime Date { get; set; }
2022-07-19 20:08:53 +00:00
public string Protocol { get; set; }
2017-09-04 02:20:56 +00:00
public string Indexer { get; set; }
public string Message { get; set; }
public ArtistResource Artist { get; set; }
}
2021-08-19 21:35:06 +00:00
public static class BlocklistResourceMapper
2017-09-04 02:20:56 +00:00
{
public static BlocklistResource MapToResource(this NzbDrone.Core.Blocklisting.Blocklist model, ICustomFormatCalculationService formatCalculator)
2017-09-04 02:20:56 +00:00
{
if (model == null)
{
return null;
}
2017-09-04 02:20:56 +00:00
2021-08-19 21:35:06 +00:00
return new BlocklistResource
2017-09-04 02:20:56 +00:00
{
Id = model.Id,
ArtistId = model.ArtistId,
AlbumIds = model.AlbumIds,
SourceTitle = model.SourceTitle,
Quality = model.Quality,
CustomFormats = formatCalculator.ParseCustomFormat(model, model.Artist).ToResource(false),
2017-09-04 02:20:56 +00:00
Date = model.Date,
Protocol = model.Protocol,
Indexer = model.Indexer,
Message = model.Message,
Artist = model.Artist.ToResource()
};
}
}
}