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, public DemoTvSearchEngine(IPrincipal identity, IRequestServiceMain service, ITvMazeApi tvMaze, IMapper mapper,
ITraktApi trakt, IRuleEvaluator r, OmbiUserManager um, ICacheService memCache, ITraktApi trakt, IRuleEvaluator r, OmbiUserManager um, ICacheService memCache,
ISettingsService<OmbiSettings> s, IRepository<RequestSubscription> sub, IOptions<DemoLists> lists, IImageService imageService) ISettingsService<OmbiSettings> s, IRepository<RequestSubscription> sub, IOptions<DemoLists> lists, IImageService imageService,
: base(identity, service, tvMaze, mapper, trakt, r, um, memCache, s, sub, imageService) ISettingsService<CustomizationSettings> custom)
: base(identity, service, tvMaze, mapper, trakt, r, um, custom, memCache, s, sub, imageService)
{ {
_demoLists = lists.Value; _demoLists = lists.Value;
} }

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

@ -26,17 +26,20 @@ namespace Ombi.Core.Engine.V2
public class MovieSearchEngineV2 : BaseMediaEngine, IMovieEngineV2 public class MovieSearchEngineV2 : BaseMediaEngine, IMovieEngineV2
{ {
public MovieSearchEngineV2(IPrincipal identity, IRequestServiceMain service, IMovieDbApi movApi, IMapper mapper, 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) : base(identity, service, r, um, mem, s, sub)
{ {
MovieApi = movApi; MovieApi = movApi;
Mapper = mapper; Mapper = mapper;
Logger = logger; Logger = logger;
_customizationSettings = customizationSettings;
} }
private IMovieDbApi MovieApi { get; } private IMovieDbApi MovieApi { get; }
private IMapper Mapper { get; } private IMapper Mapper { get; }
private ILogger Logger { get; } private ILogger Logger { get; }
private readonly ISettingsService<CustomizationSettings> _customizationSettings;
public async Task<MovieFullInfoViewModel> GetFullMovieInformation(int theMovieDbId, CancellationToken cancellationToken, string langCode = null) public async Task<MovieFullInfoViewModel> GetFullMovieInformation(int theMovieDbId, CancellationToken cancellationToken, string langCode = null)
@ -249,10 +252,16 @@ namespace Ombi.Core.Engine.V2
protected async Task<List<SearchMovieViewModel>> TransformMovieResultsToResponse( protected async Task<List<SearchMovieViewModel>> TransformMovieResultsToResponse(
IEnumerable<MovieSearchResult> movies) IEnumerable<MovieSearchResult> movies)
{ {
var settings = await _customizationSettings.GetSettingsAsync();
var viewMovies = new List<SearchMovieViewModel>(); var viewMovies = new List<SearchMovieViewModel>();
foreach (var movie in movies) 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; return viewMovies;
} }

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

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

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

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

@ -19,11 +19,14 @@ export class AboutComponent implements OnInit {
public async ngOnInit() { public async ngOnInit() {
this.settingsService.about().subscribe(x => this.about = x); 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(); this.connectedUsers = await this.hubService.getConnectedUsers();
} }

@ -31,6 +31,11 @@
</div> </div>
</div> </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"> <div class="md-form-field">
<mat-checkbox [(ngModel)]="settings.enableCustomDonations" matTooltip="Enable to show a custom donation link in the navigation bar"> <mat-checkbox [(ngModel)]="settings.enableCustomDonations" matTooltip="Enable to show a custom donation link in the navigation bar">
Enable Custom Donation Link Enable Custom Donation Link

Loading…
Cancel
Save