mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -07:00
added caching breaker to media cover images.
This commit is contained in:
parent
1585234055
commit
38589742e3
10 changed files with 115 additions and 54 deletions
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using FluentValidation;
|
||||
using Nancy;
|
||||
using NzbDrone.Core.MediaCover;
|
||||
using NzbDrone.Core.SeriesStats;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Api.Validation;
|
||||
|
@ -14,12 +15,14 @@ namespace NzbDrone.Api.Series
|
|||
{
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly ISeriesStatisticsService _seriesStatisticsService;
|
||||
private readonly IMapCoversToLocal _coverMapper;
|
||||
|
||||
public SeriesModule(ISeriesService seriesService, ISeriesStatisticsService seriesStatisticsService)
|
||||
public SeriesModule(ISeriesService seriesService, ISeriesStatisticsService seriesStatisticsService, IMapCoversToLocal coverMapper)
|
||||
: base("/Series")
|
||||
{
|
||||
_seriesService = seriesService;
|
||||
_seriesStatisticsService = seriesStatisticsService;
|
||||
_coverMapper = coverMapper;
|
||||
|
||||
GetResourceAll = AllSeries;
|
||||
GetResourceById = GetSeries;
|
||||
|
@ -51,9 +54,9 @@ namespace NzbDrone.Api.Series
|
|||
private List<SeriesResource> AllSeries()
|
||||
{
|
||||
var seriesStats = _seriesStatisticsService.SeriesStatistics();
|
||||
var seriesModels = ToListResource(_seriesService.GetAllSeries);
|
||||
var seriesResources = ToListResource(_seriesService.GetAllSeries);
|
||||
|
||||
foreach (var s in seriesModels)
|
||||
foreach (var s in seriesResources)
|
||||
{
|
||||
var stats = seriesStats.SingleOrDefault(ss => ss.SeriesId == s.Id);
|
||||
if (stats == null) continue;
|
||||
|
@ -64,12 +67,18 @@ namespace NzbDrone.Api.Series
|
|||
s.NextAiring = stats.NextAiring;
|
||||
}
|
||||
|
||||
return seriesModels;
|
||||
MapCoversToLocal(seriesResources.ToArray());
|
||||
|
||||
return seriesResources;
|
||||
}
|
||||
|
||||
private SeriesResource GetSeries(int id)
|
||||
{
|
||||
return ToResource(_seriesService.GetSeries, id);
|
||||
var resource = ToResource(_seriesService.GetSeries, id);
|
||||
|
||||
MapCoversToLocal(resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
private SeriesResource AddSeries(SeriesResource seriesResource)
|
||||
|
@ -92,6 +101,14 @@ namespace NzbDrone.Api.Series
|
|||
var deleteFiles = Convert.ToBoolean(Request.Headers["deleteFiles"].FirstOrDefault());
|
||||
_seriesService.DeleteSeries(id, deleteFiles);
|
||||
}
|
||||
|
||||
private void MapCoversToLocal(params SeriesResource[] series)
|
||||
{
|
||||
foreach (var seriesResource in series)
|
||||
{
|
||||
_coverMapper.ConvertToLocalUrls(seriesResource.Id, seriesResource.Images);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue