mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
updated add series
This commit is contained in:
parent
f3e601d4ed
commit
0531029ce7
16 changed files with 243 additions and 29 deletions
|
@ -1,27 +1,58 @@
|
|||
using System.Linq;
|
||||
using FluentValidation;
|
||||
using Nancy;
|
||||
using NzbDrone.Api.Extentions;
|
||||
using NzbDrone.Api.QualityType;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Jobs;
|
||||
using NzbDrone.Core.Providers;
|
||||
|
||||
namespace NzbDrone.Api.Series
|
||||
{
|
||||
public class SeriesModule : NzbDroneApiModule
|
||||
{
|
||||
private readonly TvDbProvider _tvDbProvider;
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly JobProvider _jobProvider;
|
||||
|
||||
public SeriesModule(TvDbProvider tvDbProvider)
|
||||
public SeriesModule(SeriesProvider seriesProvider, JobProvider jobProvider)
|
||||
: base("/Series")
|
||||
{
|
||||
_tvDbProvider = tvDbProvider;
|
||||
Get["/lookup"] = x => GetQualityType();
|
||||
_seriesProvider = seriesProvider;
|
||||
_jobProvider = jobProvider;
|
||||
Post["/"] = x => AddSeries();
|
||||
}
|
||||
|
||||
|
||||
private Response GetQualityType()
|
||||
private Response AddSeries()
|
||||
{
|
||||
var tvDbResults = _tvDbProvider.SearchSeries((string)Request.Query.term);
|
||||
return tvDbResults.AsResponse();
|
||||
var request = Request.Body.FromJson<Core.Repository.Series>();
|
||||
|
||||
_seriesProvider.AddSeries("", request.Path, request.SeriesId, request.QualityProfileId, null);
|
||||
_jobProvider.QueueJob(typeof(ImportNewSeriesJob));
|
||||
|
||||
return new Response { StatusCode = HttpStatusCode.Created };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class SeriesValidator : AbstractValidator<Core.Repository.Series>
|
||||
{
|
||||
private readonly DiskProvider _diskProvider;
|
||||
|
||||
public SeriesValidator(DiskProvider diskProvider)
|
||||
{
|
||||
_diskProvider = diskProvider;
|
||||
}
|
||||
|
||||
public SeriesValidator()
|
||||
{
|
||||
RuleSet("POST", () =>
|
||||
{
|
||||
RuleFor(s => s.SeriesId).GreaterThan(0);
|
||||
RuleFor(s => s.Path).NotEmpty().Must(_diskProvider.FolderExists);
|
||||
RuleFor(s => s.QualityProfileId).GreaterThan(0);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue