mirror of https://github.com/Radarr/Radarr
New: Added new API endpoints to get missing and wanted movies
This commit is contained in:
parent
3db78079f3
commit
178525d8d7
|
@ -31,6 +31,7 @@ namespace NzbDrone.Core.Movies
|
||||||
List<int> GetRecommendations();
|
List<int> GetRecommendations();
|
||||||
bool ExistsByMetadataId(int metadataId);
|
bool ExistsByMetadataId(int metadataId);
|
||||||
HashSet<int> AllMovieWithCollectionsTmdbIds();
|
HashSet<int> AllMovieWithCollectionsTmdbIds();
|
||||||
|
List<Movie> FindMissing();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MovieRepository : BasicRepository<Movie>, IMovieRepository
|
public class MovieRepository : BasicRepository<Movie>, IMovieRepository
|
||||||
|
@ -378,5 +379,10 @@ namespace NzbDrone.Core.Movies
|
||||||
return conn.Query<int>("SELECT \"TmdbId\" FROM \"MovieMetadata\" JOIN \"Movies\" ON (\"Movies\".\"MovieMetadataId\" = \"MovieMetadata\".\"Id\") WHERE \"CollectionTmdbId\" > 0").ToHashSet();
|
return conn.Query<int>("SELECT \"TmdbId\" FROM \"MovieMetadata\" JOIN \"Movies\" ON (\"Movies\".\"MovieMetadataId\" = \"MovieMetadata\".\"Id\") WHERE \"CollectionTmdbId\" > 0").ToHashSet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Movie> FindMissing()
|
||||||
|
{
|
||||||
|
return Query(x => x.Monitored == true && x.MovieFileId == 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,8 @@ namespace NzbDrone.Core.Movies
|
||||||
void RemoveAddOptions(Movie movie);
|
void RemoveAddOptions(Movie movie);
|
||||||
bool ExistsByMetadataId(int metadataId);
|
bool ExistsByMetadataId(int metadataId);
|
||||||
HashSet<int> AllMovieWithCollectionsTmdbIds();
|
HashSet<int> AllMovieWithCollectionsTmdbIds();
|
||||||
|
List<Movie> GetMissingMovies();
|
||||||
|
List<Movie> GetWantedMovies();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MovieService : IMovieService, IHandle<MovieFileAddedEvent>,
|
public class MovieService : IMovieService, IHandle<MovieFileAddedEvent>,
|
||||||
|
@ -412,5 +414,15 @@ namespace NzbDrone.Core.Movies
|
||||||
UpdateMovie(movie);
|
UpdateMovie(movie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Movie> GetMissingMovies()
|
||||||
|
{
|
||||||
|
return _movieRepository.FindMissing();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Movie> GetWantedMovies()
|
||||||
|
{
|
||||||
|
return _movieRepository.FindMissing().Where(m => m.IsAvailable() == true).ToList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NzbDrone.Core.Movies;
|
||||||
|
using Radarr.Http;
|
||||||
|
|
||||||
|
namespace Radarr.Api.V3.Movies
|
||||||
|
{
|
||||||
|
[V3ApiController("missing")]
|
||||||
|
public class MissingController : Controller
|
||||||
|
{
|
||||||
|
private readonly IMovieService _movieService;
|
||||||
|
|
||||||
|
public MissingController(IMovieService movieService)
|
||||||
|
{
|
||||||
|
_movieService = movieService;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public MissingWantedResource GetMissing()
|
||||||
|
{
|
||||||
|
return _movieService.GetMissingMovies().ToResource();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using NzbDrone.Core.Movies;
|
||||||
|
using Radarr.Http.REST;
|
||||||
|
|
||||||
|
namespace Radarr.Api.V3.Movies
|
||||||
|
{
|
||||||
|
public class MissingWantedResource : RestResource
|
||||||
|
{
|
||||||
|
public int Total { get; set; }
|
||||||
|
public List<MovieResource> Movies { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MissingResourceMapper
|
||||||
|
{
|
||||||
|
public static MissingWantedResource ToResource(this List<Movie> model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new MissingWantedResource
|
||||||
|
{
|
||||||
|
Total = model.Count,
|
||||||
|
Movies = model.ToResource(0)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NzbDrone.Core.Movies;
|
||||||
|
using Radarr.Http;
|
||||||
|
|
||||||
|
namespace Radarr.Api.V3.Movies
|
||||||
|
{
|
||||||
|
[V3ApiController("wanted")]
|
||||||
|
public class WantedController : Controller
|
||||||
|
{
|
||||||
|
private readonly IMovieService _movieService;
|
||||||
|
|
||||||
|
public WantedController(IMovieService movieService)
|
||||||
|
{
|
||||||
|
_movieService = movieService;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public MissingWantedResource GetWanted()
|
||||||
|
{
|
||||||
|
return _movieService.GetWantedMovies().ToResource();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue