diff --git a/src/Ombi.Helpers/CacheKeys.cs b/src/Ombi.Helpers/CacheKeys.cs index db66d4e13..e6c482f7b 100644 --- a/src/Ombi.Helpers/CacheKeys.cs +++ b/src/Ombi.Helpers/CacheKeys.cs @@ -18,5 +18,6 @@ namespace Ombi.Helpers public const string NowPlayingMovies = nameof(NowPlayingMovies); public const string RadarrRootProfiles = nameof(RadarrRootProfiles); public const string RadarrQualityProfiles = nameof(RadarrQualityProfiles); + public const string FanartTv = nameof(FanartTv); } } diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexContentCacher.cs b/src/Ombi.Schedule/Jobs/Plex/PlexContentCacher.cs index c5f78bd71..398f7c3d8 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexContentCacher.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexContentCacher.cs @@ -93,7 +93,7 @@ namespace Ombi.Schedule.Jobs.Plex { Logger.LogInformation("Getting all content from server {0}", servers.Name); - var allContent = GetAllContent(servers); + var allContent = await GetAllContent(servers); Logger.LogInformation("We found {0} items", allContent.Count); // Let's now process this. @@ -222,9 +222,9 @@ namespace Ombi.Schedule.Jobs.Plex /// /// The plex settings. /// - private List GetAllContent(PlexServers plexSettings) + private async Task> GetAllContent(PlexServers plexSettings) { - var sections = PlexApi.GetLibrarySections(plexSettings.PlexAuthToken, plexSettings.FullUri).Result; + var sections = await PlexApi.GetLibrarySections(plexSettings.PlexAuthToken, plexSettings.FullUri); var libs = new List(); if (sections != null) @@ -246,7 +246,7 @@ namespace Ombi.Schedule.Jobs.Plex } } } - var lib = PlexApi.GetLibrary(plexSettings.PlexAuthToken, plexSettings.FullUri, dir.key).Result; + var lib = await PlexApi.GetLibrary(plexSettings.PlexAuthToken, plexSettings.FullUri, dir.key); if (lib != null) { libs.Add(lib.MediaContainer); diff --git a/src/Ombi/ClientApp/app/search/tvsearch.component.html b/src/Ombi/ClientApp/app/search/tvsearch.component.html index c57e32fa0..24ab82238 100644 --- a/src/Ombi/ClientApp/app/search/tvsearch.component.html +++ b/src/Ombi/ClientApp/app/search/tvsearch.component.html @@ -40,13 +40,13 @@
-
-
+
+
poster
-
+ -
+
-
+
+
diff --git a/src/Ombi/ClientApp/app/search/tvsearch.component.ts b/src/Ombi/ClientApp/app/search/tvsearch.component.ts index 6daeb5dec..07889499f 100644 --- a/src/Ombi/ClientApp/app/search/tvsearch.component.ts +++ b/src/Ombi/ClientApp/app/search/tvsearch.component.ts @@ -1,11 +1,10 @@ import { Component, OnDestroy, OnInit } from "@angular/core"; +import { DomSanitizer } from "@angular/platform-browser"; import { Router } from "@angular/router"; import { Subject } from "rxjs/Subject"; import { AuthService } from "../auth/auth.service"; -import { NotificationService } from "../services"; -import { RequestService } from "../services"; -import { SearchService } from "../services"; +import { ImageService, NotificationService, RequestService, SearchService} from "../services"; import { TreeNode } from "primeng/primeng"; import { IRequestEngineResult } from "../interfaces"; @@ -27,10 +26,11 @@ export class TvSearchComponent implements OnInit, OnDestroy { private subscriptions = new Subject(); constructor(private searchService: SearchService, private requestService: RequestService, - private notificationService: NotificationService, private route: Router, private authService: AuthService) { + private notificationService: NotificationService, private route: Router, private authService: AuthService, + private imageService: ImageService, private sanitizer: DomSanitizer) { this.searchChanged - .debounceTime(600) // Wait Xms afterthe last event before emitting last event + .debounceTime(600) // Wait Xms after the last event before emitting last event .distinctUntilChanged() // only emit if value is different from previous value .takeUntil(this.subscriptions) .subscribe(x => { @@ -130,6 +130,13 @@ export class TvSearchComponent implements OnInit, OnDestroy { public getExtraInfo() { this.tvResults.forEach((val, index) => { + + this.imageService.getTvBanner(val.data.id).subscribe(x => { + + val.data.background = this.sanitizer. + bypassSecurityTrustStyle + ("linear-gradient(to bottom, rgba(0,0,0,0.6) 0%,rgba(0,0,0,0.6) 100%),url(" + x + ")"); + }); this.searchService.getShowInformationTreeNode(val.data.id) .takeUntil(this.subscriptions) .subscribe(x => { @@ -203,6 +210,7 @@ export class TvSearchComponent implements OnInit, OnDestroy { this.tvResults[index].data.seasonRequests = updated.data.seasonRequests; this.tvResults[index].data.seriesId = updated.data.seriesId; this.tvResults[index].data.fullyAvailable = updated.data.fullyAvailable; + this.tvResults[index].data.backdrop = updated.data.backdrop; } } diff --git a/src/Ombi/ClientApp/app/services/image.service.ts b/src/Ombi/ClientApp/app/services/image.service.ts index 337b297bc..8175cf9e0 100644 --- a/src/Ombi/ClientApp/app/services/image.service.ts +++ b/src/Ombi/ClientApp/app/services/image.service.ts @@ -15,4 +15,8 @@ export class ImageService extends ServiceHelpers { public getRandomBackground(): Observable { return this.http.get(`${this.url}background/`, { headers: this.headers }).map(this.extractData); } + + public getTvBanner(tvdbid: number): Observable { + return this.http.get(`${this.url}tv/${tvdbid}`, { headers: this.headers }).map(this.extractData); + } } diff --git a/src/Ombi/ClientApp/styles/base.scss b/src/Ombi/ClientApp/styles/base.scss index 6be03820e..fb5fc0552 100644 --- a/src/Ombi/ClientApp/styles/base.scss +++ b/src/Ombi/ClientApp/styles/base.scss @@ -842,4 +842,12 @@ a > h4:hover { .backdrop{ box-shadow: 3px 3px 10px #000000; background-position: center; + background-size: cover; } + +.tv-overview{ + -webkit-text-fill-color: white; + -webkit-text-stroke-width: 0.3px; + -webkit-text-stroke-color: black; + font-size: 0.9rem !important +} \ No newline at end of file diff --git a/src/Ombi/Controllers/ImagesController.cs b/src/Ombi/Controllers/ImagesController.cs index 7e698eb97..6efd2f83c 100644 --- a/src/Ombi/Controllers/ImagesController.cs +++ b/src/Ombi/Controllers/ImagesController.cs @@ -5,8 +5,11 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Options; using Ombi.Config; +using Ombi.Helpers; namespace Ombi.Controllers { @@ -14,16 +17,32 @@ namespace Ombi.Controllers [Produces("application/json")] public class ImagesController : Controller { - public ImagesController(IFanartTvApi api, IApplicationConfigRepository config, IOptions options) + public ImagesController(IFanartTvApi api, IApplicationConfigRepository config, + IOptions options, IMemoryCache c) { Api = api; Config = config; Options = options.Value; + _cache = c; } private IFanartTvApi Api { get; } private IApplicationConfigRepository Config { get; } private LandingPageBackground Options { get; } + private readonly IMemoryCache _cache; + + [HttpGet("tv/{tvdbid}")] + public async Task GetTvBanner(int tvdbid) + { + var key = await _cache.GetOrCreateAsync(CacheKeys.FanartTv, async entry => + { + entry.SlidingExpiration = TimeSpan.FromDays(1); + return await Config.Get(Store.Entities.ConfigurationTypes.FanartTv); + }); + + var images = await Api.GetTvImages(tvdbid, key.Value); + return images.tvbanner.FirstOrDefault()?.url ?? string.Empty; + } [HttpGet("background")] public async Task GetBackgroundImage() @@ -35,10 +54,15 @@ namespace Ombi.Controllers var movieUrl = string.Empty; var tvUrl = string.Empty; + var key = await _cache.GetOrCreateAsync(CacheKeys.FanartTv, async entry => + { + entry.SlidingExpiration = TimeSpan.FromDays(1); + return await Config.Get(Store.Entities.ConfigurationTypes.FanartTv); + }); + if (moviesArray.Any()) { var item = rand.Next(moviesArray.Length); - var key = await Config.Get(Store.Entities.ConfigurationTypes.FanartTv); var result = await Api.GetMovieImages(moviesArray[item], key.Value); while (!result.moviebackground.Any()) @@ -51,7 +75,6 @@ namespace Ombi.Controllers if(tvArray.Any()) { var item = rand.Next(tvArray.Length); - var key = await Config.Get(Store.Entities.ConfigurationTypes.FanartTv); var result = await Api.GetTvImages(tvArray[item], key.Value); while (!result.showbackground.Any())