Added the new banner background for tv shows

pull/1676/head
tidusjar 7 years ago
parent c84e0c5ee8
commit 5e48c66325

@ -18,5 +18,6 @@ namespace Ombi.Helpers
public const string NowPlayingMovies = nameof(NowPlayingMovies); public const string NowPlayingMovies = nameof(NowPlayingMovies);
public const string RadarrRootProfiles = nameof(RadarrRootProfiles); public const string RadarrRootProfiles = nameof(RadarrRootProfiles);
public const string RadarrQualityProfiles = nameof(RadarrQualityProfiles); public const string RadarrQualityProfiles = nameof(RadarrQualityProfiles);
public const string FanartTv = nameof(FanartTv);
} }
} }

@ -93,7 +93,7 @@ namespace Ombi.Schedule.Jobs.Plex
{ {
Logger.LogInformation("Getting all content from server {0}", servers.Name); 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); Logger.LogInformation("We found {0} items", allContent.Count);
// Let's now process this. // Let's now process this.
@ -222,9 +222,9 @@ namespace Ombi.Schedule.Jobs.Plex
/// </summary> /// </summary>
/// <param name="plexSettings">The plex settings.</param> /// <param name="plexSettings">The plex settings.</param>
/// <returns></returns> /// <returns></returns>
private List<Mediacontainer> GetAllContent(PlexServers plexSettings) private async Task<List<Mediacontainer>> 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<Mediacontainer>(); var libs = new List<Mediacontainer>();
if (sections != null) 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) if (lib != null)
{ {
libs.Add(lib.MediaContainer); libs.Add(lib.MediaContainer);

@ -40,13 +40,13 @@
<ng-template let-col let-node="rowData" pTemplate="body"> <ng-template let-col let-node="rowData" pTemplate="body">
<!--This is the section that holds the parent level search results set--> <!--This is the section that holds the parent level search results set-->
<div *ngIf="!node.leaf"> <div *ngIf="!node.leaf">
<div class="row"> <div class="row backdrop" [style.background-image]="node?.data?.background">
<div class="col-sm-2"> <div class="col-sm-2 small-padding">
<img *ngIf="node?.data?.banner" class="img-responsive poster" width="150" [src]="node.data.banner" alt="poster"> <img *ngIf="node?.data?.banner" class="img-responsive poster" width="150" [src]="node.data.banner" alt="poster">
</div> </div>
<div class="col-sm-8"> <div class="col-sm-8 small-padding">
<div> <div>
<a href="http://www.imdb.com/title/{{node.data.imdbId}}/" target="_blank"> <a href="http://www.imdb.com/title/{{node.data.imdbId}}/" target="_blank">
@ -73,11 +73,11 @@
<br /> <br />
<br /> <br />
</div> </div>
<p style="font-size: 0.9rem !important">{{node.data.overview}}</p> <p class="tv-overview">{{node.data.overview}}</p>
</div> </div>
<div class="col-sm-2"> <div class="col-sm-2 small-padding">
<div *ngIf="!node.data.fullyAvailable" class="dropdown"> <div *ngIf="!node.data.fullyAvailable" class="dropdown">
<button class="btn btn-primary-outline dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> <button class="btn btn-primary-outline dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<i class="fa fa-plus"></i> Request <i class="fa fa-plus"></i> Request
@ -112,7 +112,8 @@
<seriesinformation [seriesId]="node.data.id"></seriesinformation> <seriesinformation [seriesId]="node.data.id"></seriesinformation>
</div> </div>
<hr /> <br/>
<br/>
</ng-template> </ng-template>
</p-column> </p-column>
</p-treeTable> </p-treeTable>

@ -1,11 +1,10 @@
import { Component, OnDestroy, OnInit } from "@angular/core"; import { Component, OnDestroy, OnInit } from "@angular/core";
import { DomSanitizer } from "@angular/platform-browser";
import { Router } from "@angular/router"; import { Router } from "@angular/router";
import { Subject } from "rxjs/Subject"; import { Subject } from "rxjs/Subject";
import { AuthService } from "../auth/auth.service"; import { AuthService } from "../auth/auth.service";
import { NotificationService } from "../services"; import { ImageService, NotificationService, RequestService, SearchService} from "../services";
import { RequestService } from "../services";
import { SearchService } from "../services";
import { TreeNode } from "primeng/primeng"; import { TreeNode } from "primeng/primeng";
import { IRequestEngineResult } from "../interfaces"; import { IRequestEngineResult } from "../interfaces";
@ -27,10 +26,11 @@ export class TvSearchComponent implements OnInit, OnDestroy {
private subscriptions = new Subject<void>(); private subscriptions = new Subject<void>();
constructor(private searchService: SearchService, private requestService: RequestService, 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 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 .distinctUntilChanged() // only emit if value is different from previous value
.takeUntil(this.subscriptions) .takeUntil(this.subscriptions)
.subscribe(x => { .subscribe(x => {
@ -130,6 +130,13 @@ export class TvSearchComponent implements OnInit, OnDestroy {
public getExtraInfo() { public getExtraInfo() {
this.tvResults.forEach((val, index) => { 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) this.searchService.getShowInformationTreeNode(val.data.id)
.takeUntil(this.subscriptions) .takeUntil(this.subscriptions)
.subscribe(x => { .subscribe(x => {
@ -203,6 +210,7 @@ export class TvSearchComponent implements OnInit, OnDestroy {
this.tvResults[index].data.seasonRequests = updated.data.seasonRequests; this.tvResults[index].data.seasonRequests = updated.data.seasonRequests;
this.tvResults[index].data.seriesId = updated.data.seriesId; this.tvResults[index].data.seriesId = updated.data.seriesId;
this.tvResults[index].data.fullyAvailable = updated.data.fullyAvailable; this.tvResults[index].data.fullyAvailable = updated.data.fullyAvailable;
this.tvResults[index].data.backdrop = updated.data.backdrop;
} }
} }

@ -15,4 +15,8 @@ export class ImageService extends ServiceHelpers {
public getRandomBackground(): Observable<IImages> { public getRandomBackground(): Observable<IImages> {
return this.http.get(`${this.url}background/`, { headers: this.headers }).map(this.extractData); return this.http.get(`${this.url}background/`, { headers: this.headers }).map(this.extractData);
} }
public getTvBanner(tvdbid: number): Observable<string> {
return this.http.get(`${this.url}tv/${tvdbid}`, { headers: this.headers }).map(this.extractData);
}
} }

@ -842,4 +842,12 @@ a > h4:hover {
.backdrop{ .backdrop{
box-shadow: 3px 3px 10px #000000; box-shadow: 3px 3px 10px #000000;
background-position: center; 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
}

@ -5,8 +5,11 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Ombi.Config; using Ombi.Config;
using Ombi.Helpers;
namespace Ombi.Controllers namespace Ombi.Controllers
{ {
@ -14,16 +17,32 @@ namespace Ombi.Controllers
[Produces("application/json")] [Produces("application/json")]
public class ImagesController : Controller public class ImagesController : Controller
{ {
public ImagesController(IFanartTvApi api, IApplicationConfigRepository config, IOptions<LandingPageBackground> options) public ImagesController(IFanartTvApi api, IApplicationConfigRepository config,
IOptions<LandingPageBackground> options, IMemoryCache c)
{ {
Api = api; Api = api;
Config = config; Config = config;
Options = options.Value; Options = options.Value;
_cache = c;
} }
private IFanartTvApi Api { get; } private IFanartTvApi Api { get; }
private IApplicationConfigRepository Config { get; } private IApplicationConfigRepository Config { get; }
private LandingPageBackground Options { get; } private LandingPageBackground Options { get; }
private readonly IMemoryCache _cache;
[HttpGet("tv/{tvdbid}")]
public async Task<string> 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")] [HttpGet("background")]
public async Task<object> GetBackgroundImage() public async Task<object> GetBackgroundImage()
@ -35,10 +54,15 @@ namespace Ombi.Controllers
var movieUrl = string.Empty; var movieUrl = string.Empty;
var tvUrl = 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()) if (moviesArray.Any())
{ {
var item = rand.Next(moviesArray.Length); var item = rand.Next(moviesArray.Length);
var key = await Config.Get(Store.Entities.ConfigurationTypes.FanartTv);
var result = await Api.GetMovieImages(moviesArray[item], key.Value); var result = await Api.GetMovieImages(moviesArray[item], key.Value);
while (!result.moviebackground.Any()) while (!result.moviebackground.Any())
@ -51,7 +75,6 @@ namespace Ombi.Controllers
if(tvArray.Any()) if(tvArray.Any())
{ {
var item = rand.Next(tvArray.Length); var item = rand.Next(tvArray.Length);
var key = await Config.Get(Store.Entities.ConfigurationTypes.FanartTv);
var result = await Api.GetTvImages(tvArray[item], key.Value); var result = await Api.GetTvImages(tvArray[item], key.Value);
while (!result.showbackground.Any()) while (!result.showbackground.Any())

Loading…
Cancel
Save