Added the ability to hide available media from the discover page

pull/3776/head
tidusjar 4 years ago
parent c81befe6a8
commit ff6041b9d1

@ -26,8 +26,9 @@ namespace Ombi.Core.Engine.Demo
public DemoTvSearchEngine(IPrincipal identity, IRequestServiceMain service, ITvMazeApi tvMaze, IMapper mapper,
ITraktApi trakt, IRuleEvaluator r, OmbiUserManager um, ICacheService memCache,
ISettingsService<OmbiSettings> s, IRepository<RequestSubscription> sub, IOptions<DemoLists> lists, IImageService imageService)
: base(identity, service, tvMaze, mapper, trakt, r, um, memCache, s, sub, imageService)
ISettingsService<OmbiSettings> s, IRepository<RequestSubscription> sub, IOptions<DemoLists> lists, IImageService imageService,
ISettingsService<CustomizationSettings> custom)
: base(identity, service, tvMaze, mapper, trakt, r, um, custom, memCache, s, sub, imageService)
{
_demoLists = lists.Value;
}

@ -27,10 +27,11 @@ namespace Ombi.Core.Engine
{
public class TvSearchEngine : BaseMediaEngine, ITvSearchEngine
{
private readonly ISettingsService<CustomizationSettings> _customizationSettings;
private readonly IImageService _imageService;
public TvSearchEngine(IPrincipal identity, IRequestServiceMain service, ITvMazeApi tvMaze, IMapper mapper,
ITraktApi trakt, IRuleEvaluator r, OmbiUserManager um,
ITraktApi trakt, IRuleEvaluator r, OmbiUserManager um, ISettingsService<CustomizationSettings> customizationSettings,
ICacheService memCache, ISettingsService<OmbiSettings> s, IRepository<RequestSubscription> sub, IImageService imageService)
: base(identity, service, r, um, memCache, s, sub)
{
@ -38,6 +39,7 @@ namespace Ombi.Core.Engine
TvMazeApi = tvMaze;
Mapper = mapper;
TraktApi = trakt;
_customizationSettings = customizationSettings;
}
protected ITvMazeApi TvMazeApi { get; }
@ -188,9 +190,15 @@ namespace Ombi.Core.Engine
protected async Task<IEnumerable<SearchTvShowViewModel>> ProcessResults<T>(IEnumerable<T> items, bool includeImages = false)
{
var retVal = new List<SearchTvShowViewModel>();
var settings = await _customizationSettings.GetSettingsAsync();
foreach (var tvMazeSearch in items)
{
retVal.Add(await ProcessResult(tvMazeSearch, includeImages));
var result = await ProcessResult(tvMazeSearch, includeImages);
if(settings.HideAvailableFromDiscover && result.Available)
{
continue;
}
retVal.Add(result);
}
return retVal;
}

@ -26,17 +26,20 @@ namespace Ombi.Core.Engine.V2
public class MovieSearchEngineV2 : BaseMediaEngine, IMovieEngineV2
{
public MovieSearchEngineV2(IPrincipal identity, IRequestServiceMain service, IMovieDbApi movApi, IMapper mapper,
ILogger<MovieSearchEngineV2> logger, IRuleEvaluator r, OmbiUserManager um, ICacheService mem, ISettingsService<OmbiSettings> s, IRepository<RequestSubscription> sub)
ILogger<MovieSearchEngineV2> logger, IRuleEvaluator r, OmbiUserManager um, ICacheService mem, ISettingsService<OmbiSettings> s, IRepository<RequestSubscription> sub,
ISettingsService<CustomizationSettings> customizationSettings)
: base(identity, service, r, um, mem, s, sub)
{
MovieApi = movApi;
Mapper = mapper;
Logger = logger;
_customizationSettings = customizationSettings;
}
private IMovieDbApi MovieApi { get; }
private IMapper Mapper { get; }
private ILogger Logger { get; }
private readonly ISettingsService<CustomizationSettings> _customizationSettings;
public async Task<MovieFullInfoViewModel> GetFullMovieInformation(int theMovieDbId, CancellationToken cancellationToken, string langCode = null)
@ -121,7 +124,7 @@ namespace Ombi.Core.Engine.V2
public async Task<IEnumerable<SearchMovieViewModel>> PopularMovies(int currentlyLoaded, int toLoad, CancellationToken cancellationToken)
{
var langCode = await DefaultLanguageCode(null);
var pages = PaginationHelper.GetNextPages(currentlyLoaded, toLoad, _theMovieDbMaxPageItems);
var results = new List<MovieSearchResult>();
@ -249,10 +252,16 @@ namespace Ombi.Core.Engine.V2
protected async Task<List<SearchMovieViewModel>> TransformMovieResultsToResponse(
IEnumerable<MovieSearchResult> movies)
{
var settings = await _customizationSettings.GetSettingsAsync();
var viewMovies = new List<SearchMovieViewModel>();
foreach (var movie in movies)
{
viewMovies.Add(await ProcessSingleMovie(movie));
var result = await ProcessSingleMovie(movie);
if (settings.HideAvailableFromDiscover && result.Available)
{
continue;
}
viewMovies.Add(result);
}
return viewMovies;
}
@ -354,11 +363,11 @@ namespace Ombi.Core.Engine.V2
}
public async Task<MovieFullInfoViewModel> GetMovieInfoByImdbId(string imdbId, CancellationToken cancellationToken)
{
{
var langCode = await DefaultLanguageCode(null);
var findResult = await Cache.GetOrAdd(nameof(GetMovieInfoByImdbId) + imdbId + langCode,
async () => await MovieApi.Find(imdbId, ExternalSource.imdb_id), DateTime.Now.AddHours(12), cancellationToken);
var movie = findResult.movie_results.FirstOrDefault();
var movieInfo = await Cache.GetOrAdd(nameof(GetMovieInfoByImdbId) + movie.id + langCode,
async () => await MovieApi.GetFullMovieInfo(movie.id, cancellationToken, langCode), DateTime.Now.AddHours(12), cancellationToken);

@ -18,7 +18,6 @@ using Ombi.Core.Models.Requests;
using Ombi.Core.Models.Search;
using Ombi.Core.Models.Search.V2;
using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External;
using Ombi.Store.Repository;
using TraktSharp.Entities;
using Microsoft.EntityFrameworkCore;
@ -27,27 +26,20 @@ namespace Ombi.Core.Engine.V2
{
public class TvSearchEngineV2 : BaseMediaEngine, ITVSearchEngineV2
{
public TvSearchEngineV2(IPrincipal identity, IRequestServiceMain service, ITvMazeApi tvMaze, IMapper mapper, ISettingsService<PlexSettings> plexSettings,
ISettingsService<EmbySettings> embySettings, IPlexContentRepository repo, IEmbyContentRepository embyRepo, ITraktApi trakt, IRuleEvaluator r, OmbiUserManager um,
ICacheService memCache, ISettingsService<OmbiSettings> s, IRepository<RequestSubscription> sub)
private readonly ITvMazeApi _tvMaze;
private readonly IMapper _mapper;
private readonly ITraktApi _traktApi;
public TvSearchEngineV2(IPrincipal identity, IRequestServiceMain service, ITvMazeApi tvMaze, IMapper mapper,
ITraktApi trakt, IRuleEvaluator r, OmbiUserManager um, ICacheService memCache, ISettingsService<OmbiSettings> s,
IRepository<RequestSubscription> sub)
: base(identity, service, r, um, memCache, s, sub)
{
TvMazeApi = tvMaze;
Mapper = mapper;
PlexSettings = plexSettings;
EmbySettings = embySettings;
PlexContentRepo = repo;
TraktApi = trakt;
EmbyContentRepo = embyRepo;
_tvMaze = tvMaze;
_mapper = mapper;
_traktApi = trakt;
}
private ITvMazeApi TvMazeApi { get; }
private IMapper Mapper { get; }
private ISettingsService<PlexSettings> PlexSettings { get; }
private ISettingsService<EmbySettings> EmbySettings { get; }
private IPlexContentRepository PlexContentRepo { get; }
private IEmbyContentRepository EmbyContentRepo { get; }
private ITraktApi TraktApi { get; }
public async Task<SearchFullInfoTvShowViewModel> GetShowByRequest(int requestId)
{
@ -58,13 +50,13 @@ namespace Ombi.Core.Engine.V2
public async Task<SearchFullInfoTvShowViewModel> GetShowInformation(int tvdbid)
{
var tvdbshow = await Cache.GetOrAdd(nameof(GetShowInformation) + tvdbid,
async () => await TvMazeApi.ShowLookupByTheTvDbId(tvdbid), DateTime.Now.AddHours(12));
async () => await _tvMaze.ShowLookupByTheTvDbId(tvdbid), DateTime.Now.AddHours(12));
if (tvdbshow == null)
{
return null;
}
var show = await Cache.GetOrAdd("GetTvFullInformation" + tvdbshow.id,
async () => await TvMazeApi.GetTvFullInformation(tvdbshow.id), DateTime.Now.AddHours(12));
async () => await _tvMaze.GetTvFullInformation(tvdbshow.id), DateTime.Now.AddHours(12));
if (show == null)
{
// We don't have enough information
@ -76,10 +68,10 @@ namespace Ombi.Core.Engine.V2
if (show.externals?.imdb.HasValue() ?? false)
{
traktInfoTask = Cache.GetOrAdd("GetExtendedTvInfoTrakt" + show.externals?.imdb,
() => TraktApi.GetTvExtendedInfo(show.externals?.imdb), DateTime.Now.AddHours(12));
() => _traktApi.GetTvExtendedInfo(show.externals?.imdb), DateTime.Now.AddHours(12));
}
var mapped = Mapper.Map<SearchFullInfoTvShowViewModel>(show);
var mapped = _mapper.Map<SearchFullInfoTvShowViewModel>(show);
foreach (var e in show._embedded?.episodes ?? new Api.TvMaze.Models.V2.Episode[0])
{
@ -128,14 +120,14 @@ namespace Ombi.Core.Engine.V2
private SearchTvShowViewModel ProcessResult<T>(T tvMazeSearch)
{
return Mapper.Map<SearchTvShowViewModel>(tvMazeSearch);
return _mapper.Map<SearchTvShowViewModel>(tvMazeSearch);
}
private async Task<SearchFullInfoTvShowViewModel> ProcessResult(SearchFullInfoTvShowViewModel item, Task<TraktShow> showInfoTask)
{
item.TheTvDbId = item.Id.ToString();
var oldModel = Mapper.Map<SearchTvShowViewModel>(item);
var oldModel = _mapper.Map<SearchTvShowViewModel>(item);
await RunSearchRules(oldModel);
item.Available = oldModel.Available;

@ -11,6 +11,7 @@
public string Logo { get; set; }
public bool RecentlyAddedPage { get; set; }
public bool UseCustomPage { get; set; }
public bool HideAvailableFromDiscover { get; set; }
public string AddToUrl(string part)
{

@ -133,6 +133,7 @@ export interface ICustomizationSettings extends ISettings {
customDonationMessage: string;
recentlyAddedPage: boolean;
useCustomPage: boolean;
hideAvailableFromDiscover: boolean;
}
export interface IJobSettings {

@ -16,10 +16,10 @@
style="color:#df691a"><b>(New Update Available)</b></a></div>
</div>
<div class="mat-row">
<!-- <div class="mat-row">
<div class="mat-cell">Branch</div>
<div class="mat-cell">{{about.branch}}</div>
</div>
</div> -->
<div class="mat-row">
<div class="mat-cell">Github</div>

@ -19,11 +19,14 @@ export class AboutComponent implements OnInit {
public async ngOnInit() {
this.settingsService.about().subscribe(x => this.about = x);
this.jobService.getCachedUpdate().subscribe(x => {
if (x === true) {
this.newUpdate = true;
}
});
// TODO
// this.jobService.getCachedUpdate().subscribe(x => {
// if (x === true) {
// // this.newUpdate = true; // TODO
// }
// });
this.connectedUsers = await this.hubService.getConnectedUsers();
}

@ -31,6 +31,11 @@
</div>
</div>
</div>
<div class="md-form-field">
<mat-checkbox [(ngModel)]="settings.hideAvailableFromDiscover" matTooltip="Any media content that is available will now be hidden on the discover page, the user still can search for it">
Hide Available Content On The Discover Page
</mat-checkbox>
</div>
<div class="md-form-field">
<mat-checkbox [(ngModel)]="settings.enableCustomDonations" matTooltip="Enable to show a custom donation link in the navigation bar">
Enable Custom Donation Link

Loading…
Cancel
Save