diff --git a/src/Ombi.Core/Engine/Demo/DemoTvSearchEngine.cs b/src/Ombi.Core/Engine/Demo/DemoTvSearchEngine.cs index ee857129a..dd117fb53 100644 --- a/src/Ombi.Core/Engine/Demo/DemoTvSearchEngine.cs +++ b/src/Ombi.Core/Engine/Demo/DemoTvSearchEngine.cs @@ -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 s, IRepository sub, IOptions lists, IImageService imageService) - : base(identity, service, tvMaze, mapper, trakt, r, um, memCache, s, sub, imageService) + ISettingsService s, IRepository sub, IOptions lists, IImageService imageService, + ISettingsService custom) + : base(identity, service, tvMaze, mapper, trakt, r, um, custom, memCache, s, sub, imageService) { _demoLists = lists.Value; } diff --git a/src/Ombi.Core/Engine/TvSearchEngine.cs b/src/Ombi.Core/Engine/TvSearchEngine.cs index a2b707ff9..0d2cc4850 100644 --- a/src/Ombi.Core/Engine/TvSearchEngine.cs +++ b/src/Ombi.Core/Engine/TvSearchEngine.cs @@ -27,10 +27,11 @@ namespace Ombi.Core.Engine { public class TvSearchEngine : BaseMediaEngine, ITvSearchEngine { + private readonly ISettingsService _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, ICacheService memCache, ISettingsService s, IRepository 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> ProcessResults(IEnumerable items, bool includeImages = false) { var retVal = new List(); + 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; } diff --git a/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs b/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs index df7f643d7..b0a78fbb3 100644 --- a/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs +++ b/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs @@ -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 logger, IRuleEvaluator r, OmbiUserManager um, ICacheService mem, ISettingsService s, IRepository sub) + ILogger logger, IRuleEvaluator r, OmbiUserManager um, ICacheService mem, ISettingsService s, IRepository sub, + ISettingsService 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; public async Task GetFullMovieInformation(int theMovieDbId, CancellationToken cancellationToken, string langCode = null) @@ -121,7 +124,7 @@ namespace Ombi.Core.Engine.V2 public async Task> PopularMovies(int currentlyLoaded, int toLoad, CancellationToken cancellationToken) { var langCode = await DefaultLanguageCode(null); - + var pages = PaginationHelper.GetNextPages(currentlyLoaded, toLoad, _theMovieDbMaxPageItems); var results = new List(); @@ -249,10 +252,16 @@ namespace Ombi.Core.Engine.V2 protected async Task> TransformMovieResultsToResponse( IEnumerable movies) { + var settings = await _customizationSettings.GetSettingsAsync(); var viewMovies = new List(); 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 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); diff --git a/src/Ombi.Core/Engine/V2/TvSearchEngineV2.cs b/src/Ombi.Core/Engine/V2/TvSearchEngineV2.cs index ef07bc533..6ad512ff4 100644 --- a/src/Ombi.Core/Engine/V2/TvSearchEngineV2.cs +++ b/src/Ombi.Core/Engine/V2/TvSearchEngineV2.cs @@ -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, - ISettingsService embySettings, IPlexContentRepository repo, IEmbyContentRepository embyRepo, ITraktApi trakt, IRuleEvaluator r, OmbiUserManager um, - ICacheService memCache, ISettingsService s, IRepository 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 s, + IRepository 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 { get; } - private ISettingsService EmbySettings { get; } - private IPlexContentRepository PlexContentRepo { get; } - private IEmbyContentRepository EmbyContentRepo { get; } - private ITraktApi TraktApi { get; } public async Task GetShowByRequest(int requestId) { @@ -58,13 +50,13 @@ namespace Ombi.Core.Engine.V2 public async Task 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(show); + var mapped = _mapper.Map(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 tvMazeSearch) { - return Mapper.Map(tvMazeSearch); + return _mapper.Map(tvMazeSearch); } private async Task ProcessResult(SearchFullInfoTvShowViewModel item, Task showInfoTask) { item.TheTvDbId = item.Id.ToString(); - var oldModel = Mapper.Map(item); + var oldModel = _mapper.Map(item); await RunSearchRules(oldModel); item.Available = oldModel.Available; diff --git a/src/Ombi.Settings/Settings/Models/CustomizationSettings.cs b/src/Ombi.Settings/Settings/Models/CustomizationSettings.cs index 040b6a110..1f2155331 100644 --- a/src/Ombi.Settings/Settings/Models/CustomizationSettings.cs +++ b/src/Ombi.Settings/Settings/Models/CustomizationSettings.cs @@ -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) { diff --git a/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts index ee1523a76..03523ca2e 100644 --- a/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts @@ -133,6 +133,7 @@ export interface ICustomizationSettings extends ISettings { customDonationMessage: string; recentlyAddedPage: boolean; useCustomPage: boolean; + hideAvailableFromDiscover: boolean; } export interface IJobSettings { diff --git a/src/Ombi/ClientApp/src/app/settings/about/about.component.html b/src/Ombi/ClientApp/src/app/settings/about/about.component.html index 8775187be..b52d00c43 100644 --- a/src/Ombi/ClientApp/src/app/settings/about/about.component.html +++ b/src/Ombi/ClientApp/src/app/settings/about/about.component.html @@ -16,10 +16,10 @@ style="color:#df691a">(New Update Available) -
+
Github
diff --git a/src/Ombi/ClientApp/src/app/settings/about/about.component.ts b/src/Ombi/ClientApp/src/app/settings/about/about.component.ts index a9a761c84..f1ea6c29d 100644 --- a/src/Ombi/ClientApp/src/app/settings/about/about.component.ts +++ b/src/Ombi/ClientApp/src/app/settings/about/about.component.ts @@ -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(); } diff --git a/src/Ombi/ClientApp/src/app/settings/customization/customization.component.html b/src/Ombi/ClientApp/src/app/settings/customization/customization.component.html index 7705dde13..a096fd4ab 100644 --- a/src/Ombi/ClientApp/src/app/settings/customization/customization.component.html +++ b/src/Ombi/ClientApp/src/app/settings/customization/customization.component.html @@ -31,6 +31,11 @@
+
+ + Hide Available Content On The Discover Page + +
Enable Custom Donation Link