mirror of https://github.com/lidarr/Lidarr
added support for getting series by slug
This commit is contained in:
parent
806ed921f4
commit
8373e1ce10
|
@ -2,9 +2,11 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentValidation;
|
||||
using Nancy;
|
||||
using NzbDrone.Core.SeriesStats;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Api.Validation;
|
||||
using NzbDrone.Api.Extensions;
|
||||
|
||||
namespace NzbDrone.Api.Series
|
||||
{
|
||||
|
@ -25,15 +27,30 @@ namespace NzbDrone.Api.Series
|
|||
UpdateResource = UpdateSeries;
|
||||
DeleteResource = DeleteSeries;
|
||||
|
||||
Get["/{slug}"] = o => GetSeries((string)o.slug.ToString());
|
||||
|
||||
SharedValidator.RuleFor(s => s.RootFolderId).ValidId();
|
||||
SharedValidator.RuleFor(s => s.QualityProfileId).ValidId();
|
||||
|
||||
|
||||
|
||||
|
||||
PostValidator.RuleFor(s => s.Title).NotEmpty();
|
||||
|
||||
}
|
||||
|
||||
private Response GetSeries(string slug)
|
||||
{
|
||||
var series = _seriesService.FindBySlug(slug);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
return new NotFoundResponse();
|
||||
}
|
||||
|
||||
return series.AsResponse();
|
||||
}
|
||||
|
||||
private List<SeriesResource> AllSeries()
|
||||
{
|
||||
var seriesStats = _seriesStatisticsService.SeriesStatistics();
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace NzbDrone.Core.Tv
|
|||
Series FindByTitle(string cleanTitle);
|
||||
Series FindByTvdbId(int tvdbId);
|
||||
void SetSeriesType(int seriesId, SeriesTypes seriesTypes);
|
||||
Series FindBySlug(string slug);
|
||||
}
|
||||
|
||||
public class SeriesRepository : BasicRepository<Series>, ISeriesRepository
|
||||
|
@ -47,5 +48,9 @@ namespace NzbDrone.Core.Tv
|
|||
SetFields(new Series { Id = seriesId, SeriesType = seriesType }, s => s.SeriesType);
|
||||
}
|
||||
|
||||
public Series FindBySlug(string slug)
|
||||
{
|
||||
return Query.SingleOrDefault(c => c.TitleSlug == slug.ToLower());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,6 +35,7 @@ namespace NzbDrone.Core.Tv
|
|||
Series UpdateSeries(Series series);
|
||||
bool SeriesPathExists(string folder);
|
||||
List<Series> GetSeriesInList(IEnumerable<int> seriesIds);
|
||||
Series FindBySlug(string slug);
|
||||
}
|
||||
|
||||
public class SeriesService : ISeriesService, IHandleAsync<SeriesAddedEvent>
|
||||
|
@ -147,6 +148,13 @@ namespace NzbDrone.Core.Tv
|
|||
return _seriesRepository.FindByTvdbId(tvdbId);
|
||||
}
|
||||
|
||||
|
||||
public Series FindBySlug(string slug)
|
||||
{
|
||||
var series = _seriesRepository.FindBySlug(slug);
|
||||
return series;
|
||||
}
|
||||
|
||||
public Series FindByTitle(string title)
|
||||
{
|
||||
var tvdbId = _sceneMappingService.GetTvDbId(title);
|
||||
|
|
Loading…
Reference in New Issue