mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 16:22:55 -07:00
Increase the results for the discover page
This commit is contained in:
parent
2f5dc4a498
commit
0ce93071f1
14 changed files with 197 additions and 32 deletions
|
@ -32,7 +32,12 @@ namespace Ombi.Core.Engine
|
|||
OmbiSettings = ombiSettings;
|
||||
_subscriptionRepository = sub;
|
||||
}
|
||||
|
||||
private int _resultLimit;
|
||||
public int ResultLimit
|
||||
{
|
||||
get => _resultLimit > 0 ? _resultLimit : 10;
|
||||
set => _resultLimit = value;
|
||||
}
|
||||
protected IRequestServiceMain RequestService { get; }
|
||||
protected IMovieRequestRepository MovieRepository => RequestService.MovieRequestService;
|
||||
protected ITvRequestRepository TvRepository => RequestService.TvRequestService;
|
||||
|
|
|
@ -20,5 +20,6 @@ namespace Ombi.Core
|
|||
|
||||
Task<IEnumerable<SearchMovieViewModel>> SimilarMovies(int theMovieDbId, string langCode);
|
||||
Task<IEnumerable<SearchMovieViewModel>> SearchActor(string search, string langaugeCode);
|
||||
int ResultLimit { get; set; }
|
||||
}
|
||||
}
|
|
@ -12,5 +12,6 @@ namespace Ombi.Core.Engine.Interfaces
|
|||
Task<IEnumerable<SearchTvShowViewModel>> Anticipated();
|
||||
Task<IEnumerable<SearchTvShowViewModel>> MostWatches();
|
||||
Task<IEnumerable<SearchTvShowViewModel>> Trending();
|
||||
int ResultLimit { get; set; }
|
||||
}
|
||||
}
|
|
@ -35,7 +35,6 @@ namespace Ombi.Core.Engine
|
|||
private IMapper Mapper { get; }
|
||||
private ILogger<MovieSearchEngine> Logger { get; }
|
||||
|
||||
private const int MovieLimit = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Lookups the imdb information.
|
||||
|
@ -61,7 +60,7 @@ namespace Ombi.Core.Engine
|
|||
|
||||
if (result != null)
|
||||
{
|
||||
return await TransformMovieResultsToResponse(result.Take(MovieLimit)); // Take x to stop us overloading the API
|
||||
return await TransformMovieResultsToResponse(result.Take(ResultLimit)); // Take x to stop us overloading the API
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -105,7 +104,7 @@ namespace Ombi.Core.Engine
|
|||
if (result != null)
|
||||
{
|
||||
Logger.LogDebug("Search Result: {result}", result);
|
||||
return await TransformMovieResultsToResponse(result.Take(MovieLimit)); // Take x to stop us overloading the API
|
||||
return await TransformMovieResultsToResponse(result.Take(ResultLimit)); // Take x to stop us overloading the API
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -124,7 +123,7 @@ namespace Ombi.Core.Engine
|
|||
}, DateTime.Now.AddHours(12));
|
||||
if (result != null)
|
||||
{
|
||||
return await TransformMovieResultsToResponse(result.Take(MovieLimit)); // Take x to stop us overloading the API
|
||||
return await TransformMovieResultsToResponse(result.Take(ResultLimit)); // Take x to stop us overloading the API
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -142,7 +141,7 @@ namespace Ombi.Core.Engine
|
|||
}, DateTime.Now.AddHours(12));
|
||||
if (result != null)
|
||||
{
|
||||
return await TransformMovieResultsToResponse(result.Take(MovieLimit)); // Take x to stop us overloading the API
|
||||
return await TransformMovieResultsToResponse(result.Take(ResultLimit)); // Take x to stop us overloading the API
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -161,7 +160,7 @@ namespace Ombi.Core.Engine
|
|||
if (result != null)
|
||||
{
|
||||
Logger.LogDebug("Search Result: {result}", result);
|
||||
return await TransformMovieResultsToResponse(result.Take(MovieLimit)); // Take x to stop us overloading the API
|
||||
return await TransformMovieResultsToResponse(result.Take(ResultLimit)); // Take x to stop us overloading the API
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -179,7 +178,7 @@ namespace Ombi.Core.Engine
|
|||
}, DateTime.Now.AddHours(12));
|
||||
if (result != null)
|
||||
{
|
||||
return await TransformMovieResultsToResponse(result.Take(MovieLimit)); // Take x to stop us overloading the API
|
||||
return await TransformMovieResultsToResponse(result.Take(ResultLimit)); // Take x to stop us overloading the API
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace Ombi.Core.Engine
|
|||
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> Popular()
|
||||
{
|
||||
var result = await Cache.GetOrAdd(CacheKeys.PopularTv, async () => await TraktApi.GetPopularShows(), DateTime.Now.AddHours(12));
|
||||
var result = await Cache.GetOrAdd(CacheKeys.PopularTv, async () => await TraktApi.GetPopularShows(null, ResultLimit), DateTime.Now.AddHours(12));
|
||||
var processed = ProcessResults(result);
|
||||
return processed;
|
||||
}
|
||||
|
@ -130,21 +130,21 @@ namespace Ombi.Core.Engine
|
|||
public async Task<IEnumerable<SearchTvShowViewModel>> Anticipated()
|
||||
{
|
||||
|
||||
var result = await Cache.GetOrAdd(CacheKeys.AnticipatedTv, async () => await TraktApi.GetAnticipatedShows(), DateTime.Now.AddHours(12));
|
||||
var result = await Cache.GetOrAdd(CacheKeys.AnticipatedTv, async () => await TraktApi.GetAnticipatedShows(null, ResultLimit), DateTime.Now.AddHours(12));
|
||||
var processed = ProcessResults(result);
|
||||
return processed;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> MostWatches()
|
||||
{
|
||||
var result = await Cache.GetOrAdd(CacheKeys.MostWatchesTv, async () => await TraktApi.GetMostWatchesShows(), DateTime.Now.AddHours(12));
|
||||
var result = await Cache.GetOrAdd(CacheKeys.MostWatchesTv, async () => await TraktApi.GetMostWatchesShows(null, ResultLimit), DateTime.Now.AddHours(12));
|
||||
var processed = ProcessResults(result);
|
||||
return processed;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> Trending()
|
||||
{
|
||||
var result = await Cache.GetOrAdd(CacheKeys.TrendingTv, async () => await TraktApi.GetTrendingShows(), DateTime.Now.AddHours(12));
|
||||
var result = await Cache.GetOrAdd(CacheKeys.TrendingTv, async () => await TraktApi.GetTrendingShows(null, ResultLimit), DateTime.Now.AddHours(12));
|
||||
var processed = ProcessResults(result);
|
||||
return processed;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
"src/styles/_imports.scss",
|
||||
"node_modules/bootstrap/scss/bootstrap.scss",
|
||||
"node_modules/angular-bootstrap-md/scss/mdb-free.scss",
|
||||
"node_modules/pace/themes/orange/pace-theme-flash.css",
|
||||
"node_modules/pace/themes/orange/pace-theme-flat-top.css",
|
||||
"node_modules/font-awesome/scss/font-awesome.scss"
|
||||
],
|
||||
"scripts": [
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Component, OnInit } from "@angular/core";
|
||||
import { SearchService } from "../services";
|
||||
import { SearchV2Service } from "../services";
|
||||
import { ISearchMovieResult, ISearchTvResult, RequestType } from "../interfaces";
|
||||
import { IDiscoverCardResult } from "./interfaces";
|
||||
import { trigger, transition, style, animate } from "@angular/animations";
|
||||
|
@ -24,7 +24,7 @@ export class DiscoverComponent implements OnInit {
|
|||
|
||||
public defaultTvPoster: string;
|
||||
|
||||
constructor(private searchService: SearchService) {
|
||||
constructor(private searchService: SearchV2Service) {
|
||||
|
||||
}
|
||||
public async ngOnInit() {
|
||||
|
|
|
@ -16,3 +16,4 @@ export * from "./notificationMessage.service";
|
|||
export * from "./recentlyAdded.service";
|
||||
export * from "./vote.service";
|
||||
export * from "./requestretry.service";
|
||||
export * from "./searchV2.service";
|
||||
|
|
|
@ -4,7 +4,7 @@ import { Injectable } from "@angular/core";
|
|||
import { HttpClient } from "@angular/common/http";
|
||||
import { Observable } from "rxjs";
|
||||
|
||||
import { IMultiSearchResult } from "../interfaces";
|
||||
import { IMultiSearchResult, ISearchMovieResult, ISearchTvResult } from "../interfaces";
|
||||
import { ServiceHelpers } from "./service.helpers";
|
||||
|
||||
@Injectable()
|
||||
|
@ -16,4 +16,39 @@ export class SearchV2Service extends ServiceHelpers {
|
|||
public multiSearch(searchTerm: string): Observable<IMultiSearchResult[]> {
|
||||
return this.http.get<IMultiSearchResult[]>(`${this.url}/multi/${searchTerm}`);
|
||||
}
|
||||
|
||||
|
||||
public similarMovies(theMovieDbId: number, langCode: string): Observable<ISearchMovieResult[]> {
|
||||
return this.http.post<ISearchMovieResult[]>(`${this.url}/Movie/similar`, {theMovieDbId, languageCode: langCode});
|
||||
}
|
||||
|
||||
public popularMovies(): Observable<ISearchMovieResult[]> {
|
||||
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/Popular`);
|
||||
}
|
||||
|
||||
public upcomingMovies(): Observable<ISearchMovieResult[]> {
|
||||
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/upcoming`);
|
||||
}
|
||||
|
||||
public nowPlayingMovies(): Observable<ISearchMovieResult[]> {
|
||||
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/nowplaying`);
|
||||
}
|
||||
|
||||
public topRatedMovies(): Observable<ISearchMovieResult[]> {
|
||||
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/toprated`);
|
||||
}
|
||||
|
||||
|
||||
public popularTv(): Observable<ISearchTvResult[]> {
|
||||
return this.http.get<ISearchTvResult[]>(`${this.url}/Tv/popular`, { headers: this.headers });
|
||||
}
|
||||
public mostWatchedTv(): Observable<ISearchTvResult[]> {
|
||||
return this.http.get<ISearchTvResult[]>(`${this.url}/Tv/mostwatched`, { headers: this.headers });
|
||||
}
|
||||
public anticipatedTv(): Observable<ISearchTvResult[]> {
|
||||
return this.http.get<ISearchTvResult[]>(`${this.url}/Tv/anticipated`, { headers: this.headers });
|
||||
}
|
||||
public trendingTv(): Observable<ISearchTvResult[]> {
|
||||
return this.http.get<ISearchTvResult[]>(`${this.url}/Tv/trending`, { headers: this.headers });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3955,16 +3955,6 @@ next-tick@1:
|
|||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c"
|
||||
|
||||
ng-auto-complete@^4.1.4:
|
||||
version "4.1.4"
|
||||
resolved "https://registry.yarnpkg.com/ng-auto-complete/-/ng-auto-complete-4.1.4.tgz#f7b73d1f426d4de1c236b771f984f3d2da51b5fa"
|
||||
dependencies:
|
||||
tslib "^1.9.0"
|
||||
|
||||
ng2-completer@^2.0.8:
|
||||
version "2.0.8"
|
||||
resolved "https://registry.yarnpkg.com/ng2-completer/-/ng2-completer-2.0.8.tgz#36101eb5a796f966897e7894fc437effd88ebdfb"
|
||||
|
||||
ng2-cookies@^1.0.12:
|
||||
version "1.0.12"
|
||||
resolved "https://registry.yarnpkg.com/ng2-cookies/-/ng2-cookies-1.0.12.tgz#3f3e613e0137b0649b705c678074b4bd08149ccc"
|
||||
|
|
|
@ -136,7 +136,6 @@ namespace Ombi.Controllers.V1
|
|||
/// <summary>
|
||||
/// Returns similar movies to the movie id passed in
|
||||
/// </summary>
|
||||
/// <param name="theMovieDbId">ID of the movie</param>
|
||||
/// <remarks>
|
||||
/// We use TheMovieDb as the Movie Provider
|
||||
/// </remarks>
|
||||
|
|
|
@ -4,6 +4,11 @@ using Microsoft.AspNetCore.Mvc;
|
|||
using Ombi.Api.TheMovieDb.Models;
|
||||
using Ombi.Core.Engine.V2;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Ombi.Core;
|
||||
using Ombi.Core.Engine.Interfaces;
|
||||
using Ombi.Core.Models.Search;
|
||||
using Ombi.Models;
|
||||
|
||||
namespace Ombi.Controllers.V2
|
||||
{
|
||||
|
@ -12,21 +17,148 @@ namespace Ombi.Controllers.V2
|
|||
[ApiController]
|
||||
public class SearchController : ControllerBase
|
||||
{
|
||||
public SearchController(IMultiSearchEngine multiSearchEngine)
|
||||
public SearchController(IMultiSearchEngine multiSearchEngine, IMovieEngine movieEngine,
|
||||
ITvSearchEngine tvSearchEngine)
|
||||
{
|
||||
_multiSearchEngine = multiSearchEngine;
|
||||
_movieEngine = movieEngine;
|
||||
_movieEngine.ResultLimit = 12;
|
||||
_tvSearchEngine = tvSearchEngine;
|
||||
_tvSearchEngine.ResultLimit = 12;
|
||||
}
|
||||
|
||||
private readonly IMultiSearchEngine _multiSearchEngine;
|
||||
private readonly IMovieEngine _movieEngine;
|
||||
private readonly ITvSearchEngine _tvSearchEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Runs the update job
|
||||
/// Returns search results for both TV and Movies
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("multi/{searchTerm}")]
|
||||
public async Task<List<MultiSearch>> ForceUpdate(string searchTerm)
|
||||
public async Task<List<MultiSearch>> MultiSearch(string searchTerm)
|
||||
{
|
||||
return await _multiSearchEngine.MultiSearch(searchTerm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns similar movies to the movie id passed in
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// We use TheMovieDb as the Movie Provider
|
||||
/// </remarks>
|
||||
[HttpPost("movie/similar")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesDefaultResponseType]
|
||||
public async Task<IEnumerable<SearchMovieViewModel>> SimilarMovies([FromBody] SimilarMoviesRefineModel model)
|
||||
{
|
||||
return await _movieEngine.SimilarMovies(model.TheMovieDbId, model.LanguageCode);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns Popular Movies
|
||||
/// </summary>
|
||||
/// <remarks>We use TheMovieDb as the Movie Provider</remarks>
|
||||
/// <returns></returns>
|
||||
[HttpGet("movie/popular")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesDefaultResponseType]
|
||||
public async Task<IEnumerable<SearchMovieViewModel>> Popular()
|
||||
{
|
||||
return await _movieEngine.PopularMovies();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns Now Playing Movies
|
||||
/// </summary>
|
||||
/// <remarks>We use TheMovieDb as the Movie Provider</remarks>
|
||||
/// <returns></returns>
|
||||
[HttpGet("movie/nowplaying")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesDefaultResponseType]
|
||||
public async Task<IEnumerable<SearchMovieViewModel>> NowPlayingMovies()
|
||||
{
|
||||
return await _movieEngine.NowPlayingMovies();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns top rated movies.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks>We use TheMovieDb as the Movie Provider</remarks>
|
||||
[HttpGet("movie/toprated")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesDefaultResponseType]
|
||||
public async Task<IEnumerable<SearchMovieViewModel>> TopRatedMovies()
|
||||
{
|
||||
return await _movieEngine.TopRatedMovies();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns Upcoming movies.
|
||||
/// </summary>
|
||||
/// <remarks>We use TheMovieDb as the Movie Provider</remarks>
|
||||
/// <returns></returns>
|
||||
[HttpGet("movie/upcoming")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesDefaultResponseType]
|
||||
public async Task<IEnumerable<SearchMovieViewModel>> UpcomingMovies()
|
||||
{
|
||||
return await _movieEngine.UpcomingMovies();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns Popular Tv Shows
|
||||
/// </summary>
|
||||
/// <remarks>We use Trakt.tv as the Provider</remarks>
|
||||
/// <returns></returns>
|
||||
[HttpGet("tv/popular")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesDefaultResponseType]
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> PopularTv()
|
||||
{
|
||||
return await _tvSearchEngine.Popular();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns most Anticiplateds tv shows.
|
||||
/// </summary>
|
||||
/// <remarks>We use Trakt.tv as the Provider</remarks>
|
||||
/// <returns></returns>
|
||||
[HttpGet("tv/anticipated")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesDefaultResponseType]
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> AnticipatedTv()
|
||||
{
|
||||
return await _tvSearchEngine.Anticipated();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns Most watched shows.
|
||||
/// </summary>
|
||||
/// <remarks>We use Trakt.tv as the Provider</remarks>
|
||||
/// <returns></returns>
|
||||
[HttpGet("tv/mostwatched")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesDefaultResponseType]
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> MostWatched()
|
||||
{
|
||||
return await _tvSearchEngine.MostWatches();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns trending shows
|
||||
/// </summary>
|
||||
/// <remarks>We use Trakt.tv as the Provider</remarks>
|
||||
/// <returns></returns>
|
||||
[HttpGet("tv/trending")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesDefaultResponseType]
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> Trending()
|
||||
{
|
||||
return await _tvSearchEngine.Trending();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -237,7 +237,8 @@ namespace Ombi
|
|||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "API V1");
|
||||
c.SwaggerEndpoint("/swagger/v2/swagger.json", "API V2");
|
||||
});
|
||||
|
||||
app.UseMvc(routes =>
|
||||
|
|
|
@ -43,13 +43,14 @@ namespace Ombi
|
|||
c.SwaggerDoc("v1", new Info
|
||||
{
|
||||
Version = "v1",
|
||||
Title = "Ombi Api",
|
||||
Title = "Ombi Api V1",
|
||||
Contact = new Contact
|
||||
{
|
||||
Name = "Jamie Rees",
|
||||
Url = "https://www.ombi.io/"
|
||||
}
|
||||
});
|
||||
|
||||
var security = new Dictionary<string, IEnumerable<string>>
|
||||
{
|
||||
//{"Bearer", new string[] { }},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue