mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
parent
96852c9f96
commit
d5addfa12f
@ -6,7 +6,7 @@ namespace NzbDrone.Core.ImportLists.ImportListMovies
|
||||
{
|
||||
public interface IImportListMovieRepository : IBasicRepository<ImportListMovie>
|
||||
{
|
||||
List<ImportListMovie> GetAllForList(int listId);
|
||||
List<ImportListMovie> GetAllForLists(List<int> listIds);
|
||||
}
|
||||
|
||||
public class ImportListMovieRepository : BasicRepository<ImportListMovie>, IImportListMovieRepository
|
||||
@ -16,9 +16,9 @@ public ImportListMovieRepository(IMainDatabase database, IEventAggregator eventA
|
||||
{
|
||||
}
|
||||
|
||||
public List<ImportListMovie> GetAllForList(int listId)
|
||||
public List<ImportListMovie> GetAllForLists(List<int> listIds)
|
||||
{
|
||||
return Query(x => x.ListId == listId);
|
||||
return Query(x => listIds.Contains(x.ListId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ namespace NzbDrone.Core.ImportLists.ImportListMovies
|
||||
public interface IImportListMovieService
|
||||
{
|
||||
List<ImportListMovie> GetAllListMovies();
|
||||
List<ImportListMovie> GetAllForList(int listId);
|
||||
List<ImportListMovie> GetAllForLists(List<int> listIds);
|
||||
ImportListMovie AddListMovie(ImportListMovie listMovie);
|
||||
List<ImportListMovie> AddListMovies(List<ImportListMovie> listMovies);
|
||||
List<ImportListMovie> SyncMoviesForList(List<ImportListMovie> listMovies, int listId);
|
||||
@ -43,7 +43,7 @@ public List<ImportListMovie> AddListMovies(List<ImportListMovie> listMovies)
|
||||
|
||||
public List<ImportListMovie> SyncMoviesForList(List<ImportListMovie> listMovies, int listId)
|
||||
{
|
||||
var existingListMovies = GetAllForList(listId);
|
||||
var existingListMovies = GetAllForLists(new List<int> { listId });
|
||||
|
||||
listMovies.ForEach(l => l.Id = existingListMovies.FirstOrDefault(e => e.TmdbId == l.TmdbId)?.Id ?? 0);
|
||||
|
||||
@ -59,9 +59,9 @@ public List<ImportListMovie> GetAllListMovies()
|
||||
return _importListMovieRepository.All().ToList();
|
||||
}
|
||||
|
||||
public List<ImportListMovie> GetAllForList(int listId)
|
||||
public List<ImportListMovie> GetAllForLists(List<int> listIds)
|
||||
{
|
||||
return _importListMovieRepository.GetAllForList(listId).ToList();
|
||||
return _importListMovieRepository.GetAllForLists(listIds).ToList();
|
||||
}
|
||||
|
||||
public void RemoveListMovie(ImportListMovie listMovie)
|
||||
@ -76,7 +76,7 @@ public ImportListMovie GetById(int id)
|
||||
|
||||
public void HandleAsync(ProviderDeletedEvent<IImportList> message)
|
||||
{
|
||||
var moviesOnList = _importListMovieRepository.GetAllForList(message.ProviderId);
|
||||
var moviesOnList = _importListMovieRepository.GetAllForLists(new List<int> { message.ProviderId });
|
||||
_importListMovieRepository.DeleteMany(moviesOnList);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.ImportLists;
|
||||
using NzbDrone.Core.ImportLists.ImportExclusions;
|
||||
using NzbDrone.Core.ImportLists.ImportListMovies;
|
||||
using NzbDrone.Core.Languages;
|
||||
@ -20,6 +21,7 @@ public class ImportListMoviesModule : RadarrRestModule<ImportListMoviesResource>
|
||||
private readonly IProvideMovieInfo _movieInfo;
|
||||
private readonly IBuildFileNames _fileNameBuilder;
|
||||
private readonly IImportListMovieService _listMovieService;
|
||||
private readonly IImportListFactory _importListFactory;
|
||||
private readonly IImportExclusionsService _importExclusionService;
|
||||
private readonly IConfigService _configService;
|
||||
|
||||
@ -27,6 +29,7 @@ public ImportListMoviesModule(IMovieService movieService,
|
||||
IProvideMovieInfo movieInfo,
|
||||
IBuildFileNames fileNameBuilder,
|
||||
IImportListMovieService listMovieService,
|
||||
IImportListFactory importListFactory,
|
||||
IImportExclusionsService importExclusionsService,
|
||||
IConfigService configService)
|
||||
: base("/importlist/movie")
|
||||
@ -35,6 +38,7 @@ public ImportListMoviesModule(IMovieService movieService,
|
||||
_movieInfo = movieInfo;
|
||||
_fileNameBuilder = fileNameBuilder;
|
||||
_listMovieService = listMovieService;
|
||||
_importListFactory = importListFactory;
|
||||
_importExclusionService = importExclusionsService;
|
||||
_configService = configService;
|
||||
Get("/", x => GetDiscoverMovies());
|
||||
@ -64,7 +68,7 @@ private object GetDiscoverMovies()
|
||||
realResults.ForEach(x => x.IsRecommendation = true);
|
||||
}
|
||||
|
||||
var listMovies = MapToResource(_listMovieService.GetAllListMovies(), movieLanguge).ToList();
|
||||
var listMovies = MapToResource(_listMovieService.GetAllForLists(_importListFactory.Enabled().Select(x => x.Definition.Id).ToList()), movieLanguge).ToList();
|
||||
|
||||
realResults.AddRange(listMovies);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user