mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
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 @@ public SeriesModule(ISeriesService seriesService, ISeriesStatisticsService serie
|
||||
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 @@ public interface ISeriesRepository : IBasicRepository<Series>
|
||||
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 @@ public void SetSeriesType(int seriesId, SeriesTypes seriesType)
|
||||
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 @@ public interface ISeriesService
|
||||
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 @@ public Series FindByTvdbId(int tvdbId)
|
||||
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
Block a user