mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-23 06:45:19 -07:00
remove duplicate code
This commit is contained in:
parent
6d4e1f6c2e
commit
2b7afd3272
1 changed files with 23 additions and 37 deletions
|
@ -27,16 +27,35 @@ namespace NzbDrone.Core.NetImport
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Movie> Fetch(int listId, bool onlyEnableAuto)
|
public List<Movie> Fetch(int listId, bool onlyEnableAuto)
|
||||||
|
{
|
||||||
|
return MovieListSearch(listId, onlyEnableAuto);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Movie> FetchAndFilter(int listId, bool onlyEnableAuto)
|
||||||
|
{
|
||||||
|
var existingMovies = _movieService.GetAllMovies();
|
||||||
|
|
||||||
|
var movies = MovieListSearch(listId, onlyEnableAuto);
|
||||||
|
|
||||||
|
// remove from movies list where existMovies (choose one)
|
||||||
|
// movies.RemoveAll(x => existingMovies.Contains(x));
|
||||||
|
// return movies;
|
||||||
|
//// or
|
||||||
|
// movies.RemoveAll(a => existingMovies.Exists(w => w.TmdbId == a.TmdbId));
|
||||||
|
// return movies;
|
||||||
|
//// or
|
||||||
|
|
||||||
|
return movies.Where(x => !existingMovies.Contains(x)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Movie> MovieListSearch(int listId, bool onlyEnableAuto)
|
||||||
{
|
{
|
||||||
var movies = new List<Movie>();
|
var movies = new List<Movie>();
|
||||||
|
|
||||||
// Get all the lists
|
|
||||||
var importLists = _netImportFactory.GetAvailableProviders();
|
var importLists = _netImportFactory.GetAvailableProviders();
|
||||||
|
|
||||||
// No listId is set return all movies in all lists
|
var lists = listId == 0 ? importLists.Where(n => ((NetImportDefinition)n.Definition).Enabled == true) : importLists.Where(n => ((NetImportDefinition)n.Definition).Id == listId);
|
||||||
var lists = listId == 0 ? importLists.Where(n => ((NetImportDefinition) n.Definition).Enabled == true) : importLists.Where(n => ((NetImportDefinition) n.Definition).Id == listId);
|
|
||||||
|
|
||||||
// Only return lists where enabledAuto is truthy
|
|
||||||
if (onlyEnableAuto)
|
if (onlyEnableAuto)
|
||||||
{
|
{
|
||||||
lists = importLists.Where(a => a.EnableAuto == true);
|
lists = importLists.Where(a => a.EnableAuto == true);
|
||||||
|
@ -49,38 +68,5 @@ namespace NzbDrone.Core.NetImport
|
||||||
|
|
||||||
return movies;
|
return movies;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Movie> FetchAndFilter(int listId, bool onlyEnableAuto)
|
|
||||||
{
|
|
||||||
var movies = new List<Movie>();
|
|
||||||
|
|
||||||
// Get all the lists
|
|
||||||
var importLists = _netImportFactory.GetAvailableProviders();
|
|
||||||
|
|
||||||
// No listId is set return all movies in all lists
|
|
||||||
var lists = listId == 0 ? importLists.Where(n => ((NetImportDefinition)n.Definition).Enabled == true) : importLists.Where(n => ((NetImportDefinition)n.Definition).Id == listId);
|
|
||||||
|
|
||||||
// Only return lists where enabledAuto is truthy
|
|
||||||
if (onlyEnableAuto)
|
|
||||||
{
|
|
||||||
lists = importLists.Where(a => a.EnableAuto == true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get all existing movies
|
|
||||||
var existingMovies = _movieService.GetAllMovies();
|
|
||||||
|
|
||||||
foreach (var list in lists)
|
|
||||||
{
|
|
||||||
movies.AddRange((List<Movie>)list.Fetch());
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove from movies list where existMovies (choose one)
|
|
||||||
// movies.RemoveAll(x => existingMovies.Contains(x));
|
|
||||||
// return movies;
|
|
||||||
// movies.RemoveAll(a => existingMovies.Exists(w => w.TmdbId == a.TmdbId));
|
|
||||||
// return movies;
|
|
||||||
|
|
||||||
return movies.Where(x => !existingMovies.Contains(x)).ToList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue