|
|
@ -10,6 +10,9 @@ using Ombi.Core.Engine.Interfaces;
|
|
|
|
using Ombi.Core.Models.Search;
|
|
|
|
using Ombi.Core.Models.Search;
|
|
|
|
using Ombi.Models;
|
|
|
|
using Ombi.Models;
|
|
|
|
using StackExchange.Profiling;
|
|
|
|
using StackExchange.Profiling;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
|
|
|
using Ombi.Core.Engine.Demo;
|
|
|
|
|
|
|
|
using Ombi.Helpers;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Ombi.Controllers.V1
|
|
|
|
namespace Ombi.Controllers.V1
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -19,18 +22,26 @@ namespace Ombi.Controllers.V1
|
|
|
|
[ApiController]
|
|
|
|
[ApiController]
|
|
|
|
public class SearchController : Controller
|
|
|
|
public class SearchController : Controller
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public SearchController(IMovieEngine movie, ITvSearchEngine tvEngine, ILogger<SearchController> logger, IMusicSearchEngine music)
|
|
|
|
public SearchController(IMovieEngine movie, ITvSearchEngine tvEngine, ILogger<SearchController> logger, IMusicSearchEngine music,
|
|
|
|
|
|
|
|
IDemoMovieSearchEngine demoMovieSearch, IDemoTvSearchEngine demoTvSearchEngine)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MovieEngine = movie;
|
|
|
|
MovieEngine = movie;
|
|
|
|
TvEngine = tvEngine;
|
|
|
|
TvEngine = tvEngine;
|
|
|
|
Logger = logger;
|
|
|
|
Logger = logger;
|
|
|
|
MusicEngine = music;
|
|
|
|
MusicEngine = music;
|
|
|
|
|
|
|
|
DemoMovieSearch = demoMovieSearch;
|
|
|
|
|
|
|
|
DemoTvSearch = demoTvSearchEngine;
|
|
|
|
|
|
|
|
IsDemo = DemoSingleton.Instance.Demo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ILogger<SearchController> Logger { get; }
|
|
|
|
private ILogger<SearchController> Logger { get; }
|
|
|
|
|
|
|
|
|
|
|
|
private IMovieEngine MovieEngine { get; }
|
|
|
|
private IMovieEngine MovieEngine { get; }
|
|
|
|
private ITvSearchEngine TvEngine { get; }
|
|
|
|
private ITvSearchEngine TvEngine { get; }
|
|
|
|
private IMusicSearchEngine MusicEngine { get; }
|
|
|
|
private IMusicSearchEngine MusicEngine { get; }
|
|
|
|
|
|
|
|
private IDemoMovieSearchEngine DemoMovieSearch { get; }
|
|
|
|
|
|
|
|
private IDemoTvSearchEngine DemoTvSearch { get; }
|
|
|
|
|
|
|
|
private readonly bool IsDemo;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Searches for a movie.
|
|
|
|
/// Searches for a movie.
|
|
|
@ -47,6 +58,10 @@ namespace Ombi.Controllers.V1
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logger.LogDebug("Searching : {searchTerm}", searchTerm);
|
|
|
|
Logger.LogDebug("Searching : {searchTerm}", searchTerm);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (IsDemo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return await DemoMovieSearch.Search(searchTerm);
|
|
|
|
|
|
|
|
}
|
|
|
|
return await MovieEngine.Search(searchTerm, null, null);
|
|
|
|
return await MovieEngine.Search(searchTerm, null, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -54,13 +69,13 @@ namespace Ombi.Controllers.V1
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Searches for movies by a certain actor.
|
|
|
|
/// Searches for movies by a certain actor.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="model">The refinement model, language code and year are both optional. Language code uses ISO 639-1</param>
|
|
|
|
/// <param name="model">language code is optional, by default it will be en. Language code uses ISO 639-1</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("movie/actor")]
|
|
|
|
[HttpPost("movie/actor")]
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
public async Task<IActionResult> SearchActor([FromBody] SearchMovieRefineModel model)
|
|
|
|
public async Task<IActionResult> SearchActor([FromBody] SearchActorModel model)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (model == null)
|
|
|
|
if (model == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -172,6 +187,10 @@ namespace Ombi.Controllers.V1
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
public async Task<IEnumerable<SearchMovieViewModel>> Popular()
|
|
|
|
public async Task<IEnumerable<SearchMovieViewModel>> Popular()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (IsDemo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return await DemoMovieSearch.PopularMovies();
|
|
|
|
|
|
|
|
}
|
|
|
|
return await MovieEngine.PopularMovies();
|
|
|
|
return await MovieEngine.PopularMovies();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -184,6 +203,10 @@ namespace Ombi.Controllers.V1
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
public async Task<IEnumerable<SearchMovieViewModel>> NowPlayingMovies()
|
|
|
|
public async Task<IEnumerable<SearchMovieViewModel>> NowPlayingMovies()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (IsDemo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return await DemoMovieSearch.NowPlayingMovies();
|
|
|
|
|
|
|
|
}
|
|
|
|
return await MovieEngine.NowPlayingMovies();
|
|
|
|
return await MovieEngine.NowPlayingMovies();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -196,6 +219,10 @@ namespace Ombi.Controllers.V1
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
public async Task<IEnumerable<SearchMovieViewModel>> TopRatedMovies()
|
|
|
|
public async Task<IEnumerable<SearchMovieViewModel>> TopRatedMovies()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (IsDemo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return await DemoMovieSearch.TopRatedMovies();
|
|
|
|
|
|
|
|
}
|
|
|
|
return await MovieEngine.TopRatedMovies();
|
|
|
|
return await MovieEngine.TopRatedMovies();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -208,6 +235,10 @@ namespace Ombi.Controllers.V1
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
public async Task<IEnumerable<SearchMovieViewModel>> UpcomingMovies()
|
|
|
|
public async Task<IEnumerable<SearchMovieViewModel>> UpcomingMovies()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (IsDemo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return await DemoMovieSearch.UpcomingMovies();
|
|
|
|
|
|
|
|
}
|
|
|
|
return await MovieEngine.UpcomingMovies();
|
|
|
|
return await MovieEngine.UpcomingMovies();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -222,6 +253,10 @@ namespace Ombi.Controllers.V1
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
public async Task<IEnumerable<SearchTvShowViewModel>> SearchTv(string searchTerm)
|
|
|
|
public async Task<IEnumerable<SearchTvShowViewModel>> SearchTv(string searchTerm)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (IsDemo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return await DemoTvSearch.Search(searchTerm);
|
|
|
|
|
|
|
|
}
|
|
|
|
return await TvEngine.Search(searchTerm);
|
|
|
|
return await TvEngine.Search(searchTerm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -249,6 +284,10 @@ namespace Ombi.Controllers.V1
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
public async Task<IEnumerable<SearchTvShowViewModel>> PopularTv()
|
|
|
|
public async Task<IEnumerable<SearchTvShowViewModel>> PopularTv()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (IsDemo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return await DemoTvSearch.NowPlayingMovies();
|
|
|
|
|
|
|
|
}
|
|
|
|
return await TvEngine.Popular();
|
|
|
|
return await TvEngine.Popular();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -262,6 +301,10 @@ namespace Ombi.Controllers.V1
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
public async Task<IEnumerable<SearchTvShowViewModel>> AnticipatedTv()
|
|
|
|
public async Task<IEnumerable<SearchTvShowViewModel>> AnticipatedTv()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (IsDemo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return await DemoTvSearch.NowPlayingMovies();
|
|
|
|
|
|
|
|
}
|
|
|
|
return await TvEngine.Anticipated();
|
|
|
|
return await TvEngine.Anticipated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -276,6 +319,10 @@ namespace Ombi.Controllers.V1
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
public async Task<IEnumerable<SearchTvShowViewModel>> MostWatched()
|
|
|
|
public async Task<IEnumerable<SearchTvShowViewModel>> MostWatched()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (IsDemo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return await DemoTvSearch.NowPlayingMovies();
|
|
|
|
|
|
|
|
}
|
|
|
|
return await TvEngine.MostWatches();
|
|
|
|
return await TvEngine.MostWatches();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -289,6 +336,10 @@ namespace Ombi.Controllers.V1
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
|
public async Task<IEnumerable<SearchTvShowViewModel>> Trending()
|
|
|
|
public async Task<IEnumerable<SearchTvShowViewModel>> Trending()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (IsDemo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return await DemoTvSearch.NowPlayingMovies();
|
|
|
|
|
|
|
|
}
|
|
|
|
return await TvEngine.Trending();
|
|
|
|
return await TvEngine.Trending();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|