diff --git a/src/Ombi.Core.Tests/Engine/V2/MusicSearchEngineV2Tests.cs b/src/Ombi.Core.Tests/Engine/V2/MusicSearchEngineV2Tests.cs index 8a327f649..fbe674df7 100644 --- a/src/Ombi.Core.Tests/Engine/V2/MusicSearchEngineV2Tests.cs +++ b/src/Ombi.Core.Tests/Engine/V2/MusicSearchEngineV2Tests.cs @@ -8,6 +8,8 @@ using Hqub.MusicBrainz.API.Entities; using Microsoft.EntityFrameworkCore.Internal; using Moq; using NUnit.Framework; +using Ombi.Api.Lidarr; +using Ombi.Api.Lidarr.Models; using Ombi.Api.MusicBrainz; using Ombi.Core.Engine.V2; using Ombi.Core.Models.Requests; @@ -20,6 +22,7 @@ using Ombi.Settings.Settings.Models.External; using Ombi.Store.Entities; using Ombi.Store.Repository; using Ombi.Test.Common; +using Artist = Hqub.MusicBrainz.API.Entities.Artist; namespace Ombi.Core.Tests.Engine.V2 { @@ -30,6 +33,8 @@ namespace Ombi.Core.Tests.Engine.V2 private MusicSearchEngineV2 _engine; private Mock _musicApi; + private Mock _lidarrApi; + private Mock> _lidarrSettings; private Fixture F; [SetUp] @@ -48,10 +53,11 @@ namespace Ombi.Core.Tests.Engine.V2 var ombiSettings = new Mock>(); var requestSub = new Mock>(); _musicApi = new Mock(); - var lidarrSettings = new Mock>(); + _lidarrSettings = new Mock>(); + _lidarrApi = new Mock(); _engine = new MusicSearchEngineV2(principle.Object, requestService.Object, ruleEval.Object, um.Object, cache.Object, ombiSettings.Object, requestSub.Object, _musicApi.Object, - lidarrSettings.Object); + _lidarrSettings.Object, _lidarrApi.Object); } @@ -124,7 +130,7 @@ namespace Ombi.Core.Tests.Engine.V2 Resource = url } }, - + }); _musicApi.Setup(x => x.GetArtistInformation("pretend-artist-id")).ReturnsAsync(musicReturnVal.Create()); @@ -155,6 +161,52 @@ namespace Ombi.Core.Tests.Engine.V2 yield return new TestCaseData("play.google.com", RelationLinks.Download, new Func(artist => artist.Links.Google)).Returns("play.google.com").SetName("ArtistInformation_Links_Google"); yield return new TestCaseData("itunes.apple.com", RelationLinks.Download, new Func(artist => artist.Links.Apple)).Returns("itunes.apple.com").SetName("ArtistInformation_Links_Apple"); } + } + + [Test] + public async Task GetArtistInformation_WithPosters() + { + _lidarrSettings.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new LidarrSettings + { + Enabled = true, + ApiKey = "dasdsa", + Ip = "192.168.1.7" + }); + _lidarrApi.Setup(x => x.GetArtistByForeignId(It.IsAny(), It.IsAny(), It.IsAny())) + .ReturnsAsync(new ArtistResult + { + images = new Image[] + { + new Image + { + coverType = "poster", + url = "posterUrl" + }, + new Image + { + coverType = "logo", + url = "logoUrl" + }, + new Image + { + coverType = "banner", + url = "bannerUrl" + }, + new Image + { + coverType = "fanArt", + url = "fanartUrl" + }, + } + }); + _musicApi.Setup(x => x.GetArtistInformation("pretend-artist-id")).ReturnsAsync(F.Create()); + + var result = await _engine.GetArtistInformation("pretend-artist-id"); + + Assert.That(result.Banner, Is.EqualTo("bannerUrl")); + Assert.That(result.Poster, Is.EqualTo("posterUrl")); + Assert.That(result.Logo, Is.EqualTo("logoUrl")); + Assert.That(result.FanArt, Is.EqualTo("fanartUrl")); + } } -} - } \ No newline at end of file +} \ No newline at end of file diff --git a/src/Ombi.Core/Engine/V2/MusicSearchEngineV2.cs b/src/Ombi.Core/Engine/V2/MusicSearchEngineV2.cs index 3bcc5b7dc..07a2f0ef6 100644 --- a/src/Ombi.Core/Engine/V2/MusicSearchEngineV2.cs +++ b/src/Ombi.Core/Engine/V2/MusicSearchEngineV2.cs @@ -1,9 +1,11 @@ +using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Security.Principal; using System.Threading.Tasks; -using Hqub.MusicBrainz.API.Entities; +using Ombi.Api.Lidarr; +using Ombi.Api.Lidarr.Models; using Ombi.Api.MusicBrainz; using Ombi.Core.Authentication; using Ombi.Core.Engine.Interfaces; @@ -16,6 +18,7 @@ using Ombi.Settings.Settings.Models; using Ombi.Settings.Settings.Models.External; using Ombi.Store.Entities; using Ombi.Store.Repository; +using Artist = Hqub.MusicBrainz.API.Entities.Artist; using ReleaseGroup = Ombi.Core.Models.Search.V2.Music.ReleaseGroup; namespace Ombi.Core.Engine.V2 @@ -24,19 +27,28 @@ namespace Ombi.Core.Engine.V2 { private readonly IMusicBrainzApi _musicBrainzApi; private readonly ISettingsService _lidarrSettings; + private readonly ILidarrApi _lidarrApi; public MusicSearchEngineV2(IPrincipal identity, IRequestServiceMain requestService, IRuleEvaluator rules, OmbiUserManager um, ICacheService cache, ISettingsService ombiSettings, - IRepository sub, IMusicBrainzApi musicBrainzApi, ISettingsService lidarrSettings) + IRepository sub, IMusicBrainzApi musicBrainzApi, ISettingsService lidarrSettings, + ILidarrApi lidarrApi) : base(identity, requestService, rules, um, cache, ombiSettings, sub) { _musicBrainzApi = musicBrainzApi; _lidarrSettings = lidarrSettings; + _lidarrApi = lidarrApi; } public async Task GetArtistInformation(string artistId) { var artist = await _musicBrainzApi.GetArtistInformation(artistId); + var lidarrSettings = await GetLidarrSettings(); + Task lidarrArtistTask = null; + if (lidarrSettings.Enabled) + { + lidarrArtistTask = _lidarrApi.GetArtistByForeignId(artistId, lidarrSettings.ApiKey, lidarrSettings.FullUri); + } var info = new ArtistInformation { @@ -65,9 +77,20 @@ namespace Ombi.Core.Engine.V2 info.Links = GetLinksForArtist(artist); info.Members = GetBandMembers(artist); + + if (lidarrArtistTask != null) + { + var artistResult = await lidarrArtistTask; + info.Banner = artistResult.images?.FirstOrDefault(x => x.coverType.Equals("banner", StringComparison.InvariantCultureIgnoreCase))?.url.Replace("http","https"); + info.Logo = artistResult.images?.FirstOrDefault(x => x.coverType.Equals("logo", StringComparison.InvariantCultureIgnoreCase))?.url.Replace("http", "https"); + info.Poster = artistResult.images?.FirstOrDefault(x => x.coverType.Equals("poster", StringComparison.InvariantCultureIgnoreCase))?.url.Replace("http", "https"); + info.FanArt = artistResult.images?.FirstOrDefault(x => x.coverType.Equals("fanart", StringComparison.InvariantCultureIgnoreCase))?.url.Replace("http", "https"); + info.Overview = artistResult.overview; + } + return info; } - + private List GetBandMembers(Artist artist) { var members = new List(); @@ -166,5 +189,11 @@ namespace Ombi.Core.Engine.V2 return links; } + + private LidarrSettings __lidarrSettings; + private async Task GetLidarrSettings() + { + return __lidarrSettings ?? (__lidarrSettings = await _lidarrSettings.GetSettingsAsync()); + } } } \ No newline at end of file diff --git a/src/Ombi.Core/Models/Search/V2/Music/ArtistInformation.cs b/src/Ombi.Core/Models/Search/V2/Music/ArtistInformation.cs index b73e7dbc1..3ecfdd696 100644 --- a/src/Ombi.Core/Models/Search/V2/Music/ArtistInformation.cs +++ b/src/Ombi.Core/Models/Search/V2/Music/ArtistInformation.cs @@ -13,6 +13,11 @@ namespace Ombi.Core.Models.Search.V2.Music public string Country { get; set; } public string Region { get; set; } public string Disambiguation { get; set; } + public string Banner { get; set; } + public string Logo { get; set; } + public string Poster { get; set; } + public string FanArt { get; set; } + public string Overview { get; set; } public List ReleaseGroups { get; set; } public ArtistLinks Links { get; set; } public List Members { get; set; } diff --git a/src/Ombi/ClientApp/src/app/interfaces/IMusicSearchResultV2.ts b/src/Ombi/ClientApp/src/app/interfaces/IMusicSearchResultV2.ts index 9827aef29..9c87d3250 100644 --- a/src/Ombi/ClientApp/src/app/interfaces/IMusicSearchResultV2.ts +++ b/src/Ombi/ClientApp/src/app/interfaces/IMusicSearchResultV2.ts @@ -7,9 +7,16 @@ export interface IArtistSearchResult { country: string; region: string; disambiguation: string; + banner: string; + logo: string; + poster: string; + fanArt: string; releaseGroups: IReleaseGroups[]; links: IArtistLinks; members: IBandMembers[]; + overview: string; + + background: any; } export interface IReleaseGroups { diff --git a/src/Ombi/ClientApp/src/app/media-details/components/artist/artist-details.component.html b/src/Ombi/ClientApp/src/app/media-details/components/artist/artist-details.component.html index 8119d68ca..018709840 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/artist/artist-details.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/artist/artist-details.component.html @@ -4,31 +4,33 @@
- +
- +
- +
- - + + + - + 'Requests.ReportIssue' | translate }} --> @@ -77,20 +79,10 @@
- - - - - - - - - + - + @@ -102,19 +94,19 @@
- {{movie.overview}} + {{artist.overview}}
-
+ -
+ diff --git a/src/Ombi/ClientApp/src/app/media-details/components/artist/artist-details.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/artist/artist-details.component.ts index af8b526b8..3d1c03fe7 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/artist/artist-details.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/artist/artist-details.component.ts @@ -16,7 +16,7 @@ import { IArtistSearchResult } from "../../../interfaces/IMusicSearchResultV2"; export class ArtistDetailsComponent { private artistId: string; - public artist: IArtistSearchResult; + public artist: IArtistSearchResult = null; public isAdmin: boolean; @@ -35,6 +35,26 @@ export class ArtistDetailsComponent { this.searchService.getArtistInformation(this.artistId).subscribe(x => this.artist = x); } + public getBackground(): string { + if(this.artist.fanArt) { + this.artist.background = this.sanitizer.bypassSecurityTrustStyle + ("url(" + this.artist.fanArt + ")"); + return this.artist.background + } + if(this.artist.logo) { + this.artist.background = this.sanitizer.bypassSecurityTrustStyle + ("url(" + this.artist.logo + ")"); + return this.artist.background + } + if(this.artist.poster) { + this.artist.background = this.sanitizer.bypassSecurityTrustStyle + ("url(" + this.artist.poster + ")"); + return this.artist.background + } + + return this.artist.background + } + public async request() { // const result = await this.requestService.requestMovie({ theMovieDbId: this.theMovidDbId, languageCode: null }).toPromise(); // if (result.result) { diff --git a/src/Ombi/ClientApp/src/app/media-details/components/artist/panels/artist-information-panel/artist-information-panel.component.html b/src/Ombi/ClientApp/src/app/media-details/components/artist/panels/artist-information-panel/artist-information-panel.component.html new file mode 100644 index 000000000..a50b59039 --- /dev/null +++ b/src/Ombi/ClientApp/src/app/media-details/components/artist/panels/artist-information-panel/artist-information-panel.component.html @@ -0,0 +1,18 @@ +
+
+ Type: +
{{artist.type}}
+
+
+ Country +
{{artist.country}}
+
+
+ Start Date +
{{artist.startYear}}
+
+
+ End Date +
{{artist.endYear}}
+
+
\ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/media-details/components/artist/panels/artist-information-panel/artist-information-panel.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/artist/panels/artist-information-panel/artist-information-panel.component.ts new file mode 100644 index 000000000..590b05f8e --- /dev/null +++ b/src/Ombi/ClientApp/src/app/media-details/components/artist/panels/artist-information-panel/artist-information-panel.component.ts @@ -0,0 +1,12 @@ +import { Component, Input, ViewEncapsulation } from "@angular/core"; +import { ISearchArtistResult } from "../../../../../interfaces"; + +@Component({ + templateUrl: "./artist-information-panel.component.html", + styleUrls: ["../../../../media-details.component.scss"], + selector: "artist-information-panel", + encapsulation: ViewEncapsulation.None +}) +export class ArtistInformationPanel { + @Input() public artist: ISearchArtistResult; +} diff --git a/src/Ombi/ClientApp/src/app/media-details/components/index.ts b/src/Ombi/ClientApp/src/app/media-details/components/index.ts index 5f1a2dd6a..c7a141145 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/index.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/index.ts @@ -15,6 +15,7 @@ import { SearchService, RequestService, RadarrService } from "../../services"; import { RequestServiceV2 } from "../../services/requestV2.service"; import { NewIssueComponent } from "./shared/new-issue/new-issue.component"; import { ArtistDetailsComponent } from "./artist/artist-details.component"; +import { ArtistInformationPanel } from "./artist/panels/artist-information-panel/artist-information-panel.component"; export const components: any[] = [ MovieDetailsComponent, @@ -32,6 +33,7 @@ export const components: any[] = [ MovieAdvancedOptionsComponent, NewIssueComponent, ArtistDetailsComponent, + ArtistInformationPanel ]; export const entryComponents: any[] = [ diff --git a/src/Ombi/ClientApp/src/app/media-details/components/shared/social-icons/social-icons.component.html b/src/Ombi/ClientApp/src/app/media-details/components/shared/social-icons/social-icons.component.html index b267507a5..3664d7ed5 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/shared/social-icons/social-icons.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/shared/social-icons/social-icons.component.html @@ -13,19 +13,19 @@ - + [href]="doNotAppend ? twitter : 'https://twitter.com/' + twitter" target="_blank"> + [href]="doNotAppend ? facebook : 'https://facebook.com/' + facebook" target="_blank"> + [href]="doNotAppend ? instagram : 'https://instagram.com/' + instagram" target="_blank"> diff --git a/src/Ombi/ClientApp/src/app/media-details/components/shared/social-icons/social-icons.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/shared/social-icons/social-icons.component.ts index 7b1e69ee3..522efb6b8 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/shared/social-icons/social-icons.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/shared/social-icons/social-icons.component.ts @@ -18,6 +18,7 @@ export class SocialIconsComponent { @Input() available: boolean; @Input() plexUrl: string; @Input() embyUrl: string; + @Input() doNotAppend: boolean; @Output() openTrailer: EventEmitter = new EventEmitter(); diff --git a/src/Ombi/ClientApp/src/app/media-details/components/shared/top-banner/top-banner.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/shared/top-banner/top-banner.component.ts index f833a197a..583376537 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/shared/top-banner/top-banner.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/shared/top-banner/top-banner.component.ts @@ -1,4 +1,5 @@ import { Component, Inject, Input } from "@angular/core"; +import { DomSanitizer, SafeStyle } from "@angular/platform-browser"; @Component({ selector: "top-banner", @@ -11,5 +12,11 @@ export class TopBannerComponent { @Input() tagline: string; @Input() available: boolean; @Input() background: any; + + constructor(private sanitizer:DomSanitizer){} + + public getBackgroundImage(): SafeStyle { + return this.sanitizer.bypassSecurityTrustStyle(this.background); + } }