mirror of
https://github.com/Radarr/Radarr.git
synced 2026-03-14 15:46:43 -04:00
Compare commits
3 Commits
v6-develop
...
collection
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04b15f2178 | ||
|
|
39d7320a75 | ||
|
|
207a4b19dc |
@@ -12,7 +12,7 @@ namespace NzbDrone.Common.Instrumentation
|
|||||||
{
|
{
|
||||||
public static class NzbDroneLogger
|
public static class NzbDroneLogger
|
||||||
{
|
{
|
||||||
private const string FILE_LOG_LAYOUT = @"${date:format=yyyy-MM-dd HH\:mm\:ss.f}|${level}|${logger}|${message}${onexception:inner=${newline}${newline}[v${assembly-version}] ${exception:format=ToString}${newline}${exception:format=Data}${newline}}";
|
private const string FILE_LOG_LAYOUT = @"${date:format=yyyy-MM-dd HH\:mm\:ss.fff}|${level}|${logger}|${message}${onexception:inner=${newline}${newline}[v${assembly-version}] ${exception:format=ToString}${newline}${exception:format=Data}${newline}}";
|
||||||
|
|
||||||
private static bool _isConfigured;
|
private static bool _isConfigured;
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NLog;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Datastore.Events;
|
using NzbDrone.Core.Datastore.Events;
|
||||||
using NzbDrone.Core.MediaCover;
|
|
||||||
using NzbDrone.Core.Messaging.Commands;
|
using NzbDrone.Core.Messaging.Commands;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
using NzbDrone.Core.Movies;
|
using NzbDrone.Core.Movies;
|
||||||
@@ -31,8 +29,8 @@ namespace Radarr.Api.V3.Collections
|
|||||||
private readonly IMovieMetadataService _movieMetadataService;
|
private readonly IMovieMetadataService _movieMetadataService;
|
||||||
private readonly IBuildFileNames _fileNameBuilder;
|
private readonly IBuildFileNames _fileNameBuilder;
|
||||||
private readonly INamingConfigService _namingService;
|
private readonly INamingConfigService _namingService;
|
||||||
private readonly IMapCoversToLocal _coverMapper;
|
|
||||||
private readonly IManageCommandQueue _commandQueueManager;
|
private readonly IManageCommandQueue _commandQueueManager;
|
||||||
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public CollectionController(IBroadcastSignalRMessage signalRBroadcaster,
|
public CollectionController(IBroadcastSignalRMessage signalRBroadcaster,
|
||||||
IMovieCollectionService collectionService,
|
IMovieCollectionService collectionService,
|
||||||
@@ -40,8 +38,8 @@ namespace Radarr.Api.V3.Collections
|
|||||||
IMovieMetadataService movieMetadataService,
|
IMovieMetadataService movieMetadataService,
|
||||||
IBuildFileNames fileNameBuilder,
|
IBuildFileNames fileNameBuilder,
|
||||||
INamingConfigService namingService,
|
INamingConfigService namingService,
|
||||||
IMapCoversToLocal coverMapper,
|
IManageCommandQueue commandQueueManager,
|
||||||
IManageCommandQueue commandQueueManager)
|
Logger logger)
|
||||||
: base(signalRBroadcaster)
|
: base(signalRBroadcaster)
|
||||||
{
|
{
|
||||||
_collectionService = collectionService;
|
_collectionService = collectionService;
|
||||||
@@ -49,8 +47,8 @@ namespace Radarr.Api.V3.Collections
|
|||||||
_movieMetadataService = movieMetadataService;
|
_movieMetadataService = movieMetadataService;
|
||||||
_fileNameBuilder = fileNameBuilder;
|
_fileNameBuilder = fileNameBuilder;
|
||||||
_namingService = namingService;
|
_namingService = namingService;
|
||||||
_coverMapper = coverMapper;
|
|
||||||
_commandQueueManager = commandQueueManager;
|
_commandQueueManager = commandQueueManager;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override CollectionResource GetResourceById(int id)
|
protected override CollectionResource GetResourceById(int id)
|
||||||
@@ -62,7 +60,6 @@ namespace Radarr.Api.V3.Collections
|
|||||||
public List<CollectionResource> GetCollections(int? tmdbId)
|
public List<CollectionResource> GetCollections(int? tmdbId)
|
||||||
{
|
{
|
||||||
var collectionResources = new List<CollectionResource>();
|
var collectionResources = new List<CollectionResource>();
|
||||||
var coverFileInfos = _coverMapper.GetCoverFileInfos();
|
|
||||||
|
|
||||||
if (tmdbId.HasValue)
|
if (tmdbId.HasValue)
|
||||||
{
|
{
|
||||||
@@ -75,9 +72,11 @@ namespace Radarr.Api.V3.Collections
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
collectionResources = MapToResource(_collectionService.GetAllCollections(), coverFileInfos).ToList();
|
collectionResources = MapToResource(_collectionService.GetAllCollections()).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_logger.Trace("Returning Collections");
|
||||||
|
|
||||||
return collectionResources;
|
return collectionResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +136,7 @@ namespace Radarr.Api.V3.Collections
|
|||||||
return Accepted(updated);
|
return Accepted(updated);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<CollectionResource> MapToResource(List<MovieCollection> collections, Dictionary<string, FileInfo> coverFileInfos)
|
private IEnumerable<CollectionResource> MapToResource(List<MovieCollection> collections)
|
||||||
{
|
{
|
||||||
// Avoid calling for naming spec on every movie in filenamebuilder
|
// Avoid calling for naming spec on every movie in filenamebuilder
|
||||||
var namingConfig = _namingService.GetConfig();
|
var namingConfig = _namingService.GetConfig();
|
||||||
@@ -161,8 +160,6 @@ namespace Radarr.Api.V3.Collections
|
|||||||
resource.Movies.Add(movieResource);
|
resource.Movies.Add(movieResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
MapCoversToLocal(resource.Movies, coverFileInfos);
|
|
||||||
|
|
||||||
yield return resource;
|
yield return resource;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,8 +175,6 @@ namespace Radarr.Api.V3.Collections
|
|||||||
var movieResource = movie.ToResource();
|
var movieResource = movie.ToResource();
|
||||||
movieResource.Folder = _fileNameBuilder.GetMovieFolder(new Movie { MovieMetadata = movie }, namingConfig);
|
movieResource.Folder = _fileNameBuilder.GetMovieFolder(new Movie { MovieMetadata = movie }, namingConfig);
|
||||||
|
|
||||||
_coverMapper.ConvertToLocalUrls(0, movieResource.Images);
|
|
||||||
|
|
||||||
if (!existingMoviesTmdbIds.Contains(movie.TmdbId))
|
if (!existingMoviesTmdbIds.Contains(movie.TmdbId))
|
||||||
{
|
{
|
||||||
resource.MissingMovies++;
|
resource.MissingMovies++;
|
||||||
@@ -191,11 +186,6 @@ namespace Radarr.Api.V3.Collections
|
|||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MapCoversToLocal(IEnumerable<CollectionMovieResource> movies, Dictionary<string, FileInfo> coverFileInfos)
|
|
||||||
{
|
|
||||||
_coverMapper.ConvertToLocalUrls(movies.Select(x => Tuple.Create(0, x.Images.AsEnumerable())), coverFileInfos);
|
|
||||||
}
|
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public void Handle(CollectionAddedEvent message)
|
public void Handle(CollectionAddedEvent message)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user