mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-20 18:02:44 +01:00
Movie stats for Calendar
This commit is contained in:
parent
84c2d7f69d
commit
cc7104a814
@ -8,6 +8,7 @@
|
||||
using NzbDrone.Core.Languages;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Movies.Translations;
|
||||
using NzbDrone.Core.MovieStats;
|
||||
using NzbDrone.Core.Tags;
|
||||
using NzbDrone.SignalR;
|
||||
using Radarr.Api.V3.Movies;
|
||||
@ -21,6 +22,7 @@ public class CalendarController : RestControllerWithSignalR<MovieResource, Movie
|
||||
{
|
||||
private readonly IMovieService _moviesService;
|
||||
private readonly IMovieTranslationService _movieTranslationService;
|
||||
private readonly IMovieStatisticsService _movieStatisticsService;
|
||||
private readonly IUpgradableSpecification _qualityUpgradableSpecification;
|
||||
private readonly ITagService _tagService;
|
||||
private readonly IConfigService _configService;
|
||||
@ -28,6 +30,7 @@ public class CalendarController : RestControllerWithSignalR<MovieResource, Movie
|
||||
public CalendarController(IBroadcastSignalRMessage signalR,
|
||||
IMovieService moviesService,
|
||||
IMovieTranslationService movieTranslationService,
|
||||
IMovieStatisticsService movieStatisticsService,
|
||||
IUpgradableSpecification qualityUpgradableSpecification,
|
||||
ITagService tagService,
|
||||
IConfigService configService)
|
||||
@ -35,6 +38,7 @@ public CalendarController(IBroadcastSignalRMessage signalR,
|
||||
{
|
||||
_moviesService = moviesService;
|
||||
_movieTranslationService = movieTranslationService;
|
||||
_movieStatisticsService = movieStatisticsService;
|
||||
_qualityUpgradableSpecification = qualityUpgradableSpecification;
|
||||
_tagService = tagService;
|
||||
_configService = configService;
|
||||
@ -97,7 +101,10 @@ protected List<MovieResource> MapToResource(List<Movie> movies)
|
||||
var translations = _movieTranslationService.GetAllTranslationsForMovieMetadata(movie.MovieMetadataId);
|
||||
var translation = GetMovieTranslation(translations, movie.MovieMetadata, language);
|
||||
|
||||
resources.Add(movie.ToResource(availDelay, translation, _qualityUpgradableSpecification));
|
||||
var resource = movie.ToResource(availDelay, translation, _qualityUpgradableSpecification);
|
||||
FetchAndLinkMovieStatistics(resource);
|
||||
|
||||
resources.Add(resource);
|
||||
}
|
||||
|
||||
return resources;
|
||||
@ -116,5 +123,17 @@ private MovieTranslation GetMovieTranslation(List<MovieTranslation> translations
|
||||
|
||||
return translations.FirstOrDefault(t => t.Language == language && t.MovieMetadataId == movie.Id);
|
||||
}
|
||||
|
||||
private void FetchAndLinkMovieStatistics(MovieResource resource)
|
||||
{
|
||||
LinkMovieStatistics(resource, _movieStatisticsService.MovieStatistics(resource.Id));
|
||||
}
|
||||
|
||||
private void LinkMovieStatistics(MovieResource resource, MovieStatistics movieStatistics)
|
||||
{
|
||||
resource.Statistics = movieStatistics.ToResource();
|
||||
resource.HasFile = movieStatistics.MovieFileCount > 0;
|
||||
resource.SizeOnDisk = movieStatistics.SizeOnDisk;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user