diff --git a/src/Ombi.Api.Lidarr/LidarrApi.cs b/src/Ombi.Api.Lidarr/LidarrApi.cs index 87a723aa6..b0bbaa5de 100644 --- a/src/Ombi.Api.Lidarr/LidarrApi.cs +++ b/src/Ombi.Api.Lidarr/LidarrApi.cs @@ -22,7 +22,7 @@ namespace Ombi.Api.Lidarr public Task> GetProfiles(string apiKey, string baseUrl) { - var request = new Request($"{ApiVersion}/profile", baseUrl, HttpMethod.Get); + var request = new Request($"{ApiVersion}/qualityprofile", baseUrl, HttpMethod.Get); AddHeaders(request, apiKey); return Api.Request>(request); diff --git a/src/Ombi.Api.Lidarr/Models/LidarrProfile.cs b/src/Ombi.Api.Lidarr/Models/LidarrProfile.cs index 3dc436606..19ebda5a6 100644 --- a/src/Ombi.Api.Lidarr/Models/LidarrProfile.cs +++ b/src/Ombi.Api.Lidarr/Models/LidarrProfile.cs @@ -2,12 +2,6 @@ namespace Ombi.Api.Lidarr.Models { - public class Cutoff - { - public int id { get; set; } - public string name { get; set; } - } - public class Quality { public int id { get; set; } @@ -23,9 +17,7 @@ namespace Ombi.Api.Lidarr.Models public class LidarrProfile { public string name { get; set; } - public Cutoff cutoff { get; set; } public List items { get; set; } - public string language { get; set; } public int id { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.Api.Lidarr/Models/Statistics.cs b/src/Ombi.Api.Lidarr/Models/Statistics.cs index 520ea747a..0f334fcdd 100644 --- a/src/Ombi.Api.Lidarr/Models/Statistics.cs +++ b/src/Ombi.Api.Lidarr/Models/Statistics.cs @@ -7,6 +7,6 @@ public int trackCount { get; set; } public int totalTrackCount { get; set; } public int sizeOnDisk { get; set; } - public int percentOfTracks { get; set; } + public decimal percentOfTracks { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.Core/Engine/Interfaces/IMusicSearchEngine.cs b/src/Ombi.Core/Engine/Interfaces/IMusicSearchEngine.cs new file mode 100644 index 000000000..ca95246d0 --- /dev/null +++ b/src/Ombi.Core/Engine/Interfaces/IMusicSearchEngine.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Ombi.Api.Lidarr.Models; +using Ombi.Core.Models.Search; + +namespace Ombi.Core.Engine +{ + public interface IMusicSearchEngine + { + Task GetAlbumArtist(string foreignArtistId); + Task GetArtist(int artistId); + Task GetArtistAlbums(string foreignArtistId); + Task> SearchAlbum(string search); + Task> SearchArtist(string search); + } +} \ No newline at end of file diff --git a/src/Ombi.Core/Engine/IRecentlyAddedEngine.cs b/src/Ombi.Core/Engine/Interfaces/IRecentlyAddedEngine.cs similarity index 100% rename from src/Ombi.Core/Engine/IRecentlyAddedEngine.cs rename to src/Ombi.Core/Engine/Interfaces/IRecentlyAddedEngine.cs diff --git a/src/Ombi.Core/Engine/IUserStatsEngine.cs b/src/Ombi.Core/Engine/Interfaces/IUserStatsEngine.cs similarity index 100% rename from src/Ombi.Core/Engine/IUserStatsEngine.cs rename to src/Ombi.Core/Engine/Interfaces/IUserStatsEngine.cs diff --git a/src/Ombi.Core/Engine/MusicSearchEngine.cs b/src/Ombi.Core/Engine/MusicSearchEngine.cs index 38d137485..63c3eed77 100644 --- a/src/Ombi.Core/Engine/MusicSearchEngine.cs +++ b/src/Ombi.Core/Engine/MusicSearchEngine.cs @@ -24,7 +24,7 @@ using Ombi.Store.Repository; namespace Ombi.Core.Engine { - public class MusicSearchEngine : BaseMediaEngine + public class MusicSearchEngine : BaseMediaEngine, IMusicSearchEngine { public MusicSearchEngine(IPrincipal identity, IRequestServiceMain service, ILidarrApi lidarrApi, IMapper mapper, ILogger logger, IRuleEvaluator r, OmbiUserManager um, ICacheService mem, ISettingsService s, IRepository sub, @@ -60,12 +60,42 @@ namespace Ombi.Core.Engine /// /// The search. /// - public async Task> SearchArtist(string search) + public async Task> SearchArtist(string search) { var settings = await GetSettings(); var result = await _lidarrApi.ArtistLookup(search, settings.ApiKey, settings.FullUri); - return result; + var vm = new List(); + foreach (var r in result) + { + vm.Add(MapIntoArtistVm(r)); + } + + return vm; + } + + private SearchArtistViewModel MapIntoArtistVm(ArtistLookup a) + { + var vm = new SearchArtistViewModel + { + ArtistName = a.artistName, + ArtistType = a.artistType, + Banner = a.images?.FirstOrDefault(x => x.coverType.Equals("banner"))?.url, + Logo = a.images?.FirstOrDefault(x => x.coverType.Equals("logo"))?.url, + CleanName = a.cleanName, + Disambiguation = a.disambiguation, + ForignArtistId = a.foreignArtistId, + Links = a.links, + Overview = a.overview, + }; + + var poster = a.images?.FirstOrDefault(x => x.coverType.Equals("poaster")); + if (poster == null) + { + vm.Poster = a.remotePoster; + } + + return vm; } /// @@ -73,7 +103,7 @@ namespace Ombi.Core.Engine /// /// /// - public async Task GetArtistAlbums(string foreignArtistId) + public async Task GetArtistAlbums(string foreignArtistId) { var settings = await GetSettings(); return await _lidarrApi.GetArtistByForignId(foreignArtistId, settings.ApiKey, settings.FullUri); @@ -82,11 +112,12 @@ namespace Ombi.Core.Engine /// /// Returns the artist that produced the album /// - /// + /// /// - public async Task GetAlbumArtist(string foreignArtistId) + public async Task GetAlbumArtist(string foreignArtistId) { - throw new NotImplementedException(); + var settings = await GetSettings(); + return await _lidarrApi.GetArtistByForignId(foreignArtistId, settings.ApiKey, settings.FullUri); } public async Task GetArtist(int artistId) diff --git a/src/Ombi.Core/Models/Search/SearchArtistViewModel.cs b/src/Ombi.Core/Models/Search/SearchArtistViewModel.cs new file mode 100644 index 000000000..da1cc892f --- /dev/null +++ b/src/Ombi.Core/Models/Search/SearchArtistViewModel.cs @@ -0,0 +1,21 @@ +using Ombi.Api.Lidarr.Models; + +namespace Ombi.Core.Models.Search +{ + public class SearchArtistViewModel + { + public string ArtistName { get; set; } + public string ForignArtistId { get; set; } + public string Overview { get; set; } + public string Disambiguation { get; set; } + public string Banner { get; set; } + public string Poster { get; set; } + public string Logo { get; set; } + public bool Monitored { get; set; } + public bool Available { get; set; } + public bool Requested { get; set; } + public string ArtistType { get; set; } + public string CleanName { get; set; } + public Link[] Links { get; set; } // Couldn't be bothered to map it + } +} \ No newline at end of file diff --git a/src/Ombi.DependencyInjection/IocExtensions.cs b/src/Ombi.DependencyInjection/IocExtensions.cs index d0a56bbcd..80565a0c8 100644 --- a/src/Ombi.DependencyInjection/IocExtensions.cs +++ b/src/Ombi.DependencyInjection/IocExtensions.cs @@ -83,6 +83,7 @@ namespace Ombi.DependencyInjection services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/src/Ombi/ClientApp/app/search/moviesearch.component.html b/src/Ombi/ClientApp/app/search/moviesearch.component.html index 44dc345bc..2cd7e2499 100644 --- a/src/Ombi/ClientApp/app/search/moviesearch.component.html +++ b/src/Ombi/ClientApp/app/search/moviesearch.component.html @@ -83,7 +83,7 @@ + {{ 'Common.Request' | translate }} diff --git a/src/Ombi/ClientApp/app/search/music/musicsearch.component.ts b/src/Ombi/ClientApp/app/search/music/musicsearch.component.ts index 2d1becf3a..bf739f783 100644 --- a/src/Ombi/ClientApp/app/search/music/musicsearch.component.ts +++ b/src/Ombi/ClientApp/app/search/music/musicsearch.component.ts @@ -4,13 +4,13 @@ import { TranslateService } from "@ngx-translate/core"; import { Subject } from "rxjs"; import { debounceTime, distinctUntilChanged } from "rxjs/operators"; -import { AuthService } from "../auth/auth.service"; -import { IIssueCategory, IRequestEngineResult, ISearchMovieResult } from "../interfaces"; -import { NotificationService, RequestService, SearchService } from "../services"; +import { AuthService } from "../../auth/auth.service"; +import { IIssueCategory, IRequestEngineResult, ISearchMovieResult } from "../../interfaces"; +import { NotificationService, RequestService, SearchService } from "../../services"; @Component({ selector: "music-search", - templateUrl: "./music.component.html", + templateUrl: "./musicsearch.component.html", }) export class MusicSearchComponent implements OnInit { @@ -19,6 +19,7 @@ export class MusicSearchComponent implements OnInit { public movieResults: ISearchMovieResult[]; public result: IRequestEngineResult; public searchApplied = false; + public searchArtist: boolean; @Input() public issueCategories: IIssueCategory[]; @Input() public issuesEnabled: boolean; @@ -44,11 +45,20 @@ export class MusicSearchComponent implements OnInit { this.clearResults(); return; } - this.searchService.searchMusic(this.searchText) + if(this.searchArtist) { + this.searchService.searchArtist(this.searchText) .subscribe(x => { this.movieResults = x; this.searchApplied = true; }); + } else { + this.searchService.searchAlbum(this.searchText) + .subscribe(x => { + this.movieResults = x; + this.searchApplied = true; + }); + } + }); this.defaultPoster = "../../../images/default_movie_poster.png"; const base = this.platformLocation.getBaseHrefFromDOM(); @@ -65,7 +75,6 @@ export class MusicSearchComponent implements OnInit { result: false, errorMessage: "", }; - this.popularMovies(); } public search(text: any) { @@ -111,77 +120,6 @@ export class MusicSearchComponent implements OnInit { } } - public popularMovies() { - this.clearResults(); - this.searchService.popularMovies() - .subscribe(x => { - this.movieResults = x; - }); - } - public nowPlayingMovies() { - this.clearResults(); - this.searchService.nowPlayingMovies() - .subscribe(x => { - this.movieResults = x; - }); - } - public topRatedMovies() { - this.clearResults(); - this.searchService.topRatedMovies() - .subscribe(x => { - this.movieResults = x; - }); - } - public upcomingMovies() { - this.clearResults(); - this.searchService.upcomingMovies() - .subscribe(x => { - this.movieResults = x; - }); - } - - public reportIssue(catId: IIssueCategory, req: ISearchMovieResult) { - this.issueRequestId = req.id; - this.issueRequestTitle = req.title + `(${req.releaseDate.getFullYear})`; - this.issueCategorySelected = catId; - this.issuesBarVisible = true; - this.issueProviderId = req.id.toString(); - } - - public similarMovies(theMovieDbId: number) { - this.clearResults(); - this.searchService.similarMovies(theMovieDbId) - .subscribe(x => { - this.movieResults = x; - this.getExtraInfo(); - }); - } - - public subscribe(r: ISearchMovieResult) { - r.subscribed = true; - this.requestService.subscribeToMovie(r.requestId) - .subscribe(x => { - this.notificationService.success("Subscribed To Movie!"); - }); - } - - public unSubscribe(r: ISearchMovieResult) { - r.subscribed = false; - this.requestService.unSubscribeToMovie(r.requestId) - .subscribe(x => { - this.notificationService.success("Unsubscribed Movie!"); - }); - } - - private updateItem(key: ISearchMovieResult, updated: ISearchMovieResult) { - const index = this.movieResults.indexOf(key, 0); - if (index > -1) { - const copy = { ...this.movieResults[index] }; - this.movieResults[index] = updated; - this.movieResults[index].background = copy.background; - this.movieResults[index].posterPath = copy.posterPath; - } - } private clearResults() { this.movieResults = []; this.searchApplied = false; diff --git a/src/Ombi/ClientApp/app/search/search.component.html b/src/Ombi/ClientApp/app/search/search.component.html index 398bfd311..046635812 100644 --- a/src/Ombi/ClientApp/app/search/search.component.html +++ b/src/Ombi/ClientApp/app/search/search.component.html @@ -13,6 +13,9 @@
  • {{ 'Search.TvTab' | translate }}
  • +
  • + {{ 'Search.MusicTab' | translate }} +
  • @@ -25,6 +28,9 @@
    +
    + +
    diff --git a/src/Ombi/ClientApp/app/search/search.component.ts b/src/Ombi/ClientApp/app/search/search.component.ts index 4f1c6c3ad..74221e71c 100644 --- a/src/Ombi/ClientApp/app/search/search.component.ts +++ b/src/Ombi/ClientApp/app/search/search.component.ts @@ -9,8 +9,10 @@ import { IssuesService, SettingsService } from "../services"; export class SearchComponent implements OnInit { public showTv: boolean; public showMovie: boolean; + public showMusic: boolean; public issueCategories: IIssueCategory[]; public issuesEnabled = false; + public musicEnabled: boolean; constructor(private issuesService: IssuesService, private settingsService: SettingsService) { @@ -18,8 +20,10 @@ export class SearchComponent implements OnInit { } public ngOnInit() { + this.settingsService.getLidarr().subscribe(x => this.musicEnabled = x.enabled); this.showMovie = true; this.showTv = false; + this.showMusic = false; this.issuesService.getCategories().subscribe(x => this.issueCategories = x); this.settingsService.getIssueSettings().subscribe(x => this.issuesEnabled = x.enabled); } @@ -27,10 +31,17 @@ export class SearchComponent implements OnInit { public selectMovieTab() { this.showMovie = true; this.showTv = false; + this.showMusic = false; } public selectTvTab() { this.showMovie = false; this.showTv = true; + this.showMusic = false; + } + public selectMusicTab() { + this.showMovie = false; + this.showTv = false; + this.showMusic = true; } } diff --git a/src/Ombi/ClientApp/app/search/search.module.ts b/src/Ombi/ClientApp/app/search/search.module.ts index 855207616..3e8181807 100644 --- a/src/Ombi/ClientApp/app/search/search.module.ts +++ b/src/Ombi/ClientApp/app/search/search.module.ts @@ -7,6 +7,7 @@ import { NgbModule } from "@ng-bootstrap/ng-bootstrap"; import { MovieSearchComponent } from "./moviesearch.component"; import { MovieSearchGridComponent } from "./moviesearchgrid.component"; +import { MusicSearchComponent } from "./music/musicsearch.component"; import { SearchComponent } from "./search.component"; import { SeriesInformationComponent } from "./seriesinformation.component"; import { TvSearchComponent } from "./tvsearch.component"; @@ -41,6 +42,7 @@ const routes: Routes = [ TvSearchComponent, SeriesInformationComponent, MovieSearchGridComponent, + MusicSearchComponent, ], exports: [ RouterModule, diff --git a/src/Ombi/ClientApp/app/services/search.service.ts b/src/Ombi/ClientApp/app/services/search.service.ts index e0da44613..7d2783dd9 100644 --- a/src/Ombi/ClientApp/app/services/search.service.ts +++ b/src/Ombi/ClientApp/app/services/search.service.ts @@ -69,7 +69,10 @@ export class SearchService extends ServiceHelpers { return this.http.get(`${this.url}/Tv/trending`, {headers: this.headers}); } // Music - public searchMusic(searchTerm: string): Observable { - return this.http.get(`${this.url}/Music/` + searchTerm); + public searchArtist(searchTerm: string): Observable { + return this.http.get(`${this.url}/Music/Artist/` + searchTerm); + } + public searchAlbum(searchTerm: string): Observable { + return this.http.get(`${this.url}/Music/Album/` + searchTerm); } } diff --git a/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.ts b/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.ts index 7e5571f14..91d7ead80 100644 --- a/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.ts +++ b/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.ts @@ -3,8 +3,7 @@ import { FormBuilder, FormGroup, Validators } from "@angular/forms"; import { ILidarrSettings, IMinimumAvailability, IRadarrProfile, IRadarrRootFolder } from "../../interfaces"; import { IRadarrSettings } from "../../interfaces"; -import { RadarrService } from "../../services"; -import { TesterService } from "../../services"; +import { LidarrService, TesterService } from "../../services"; import { NotificationService } from "../../services"; import { SettingsService } from "../../services"; @@ -22,7 +21,7 @@ export class LidarrComponent implements OnInit { public form: FormGroup; constructor(private settingsService: SettingsService, - private radarrService: RadarrService, + private lidarrService: LidarrService, private notificationService: NotificationService, private fb: FormBuilder, private testerService: TesterService) { } @@ -59,7 +58,7 @@ export class LidarrComponent implements OnInit { public getProfiles(form: FormGroup) { this.profilesRunning = true; - this.radarrService.getQualityProfiles(form.value).subscribe(x => { + this.lidarrService.getQualityProfiles(form.value).subscribe(x => { this.qualities = x; this.qualities.unshift({ name: "Please Select", id: -1 }); @@ -70,7 +69,7 @@ export class LidarrComponent implements OnInit { public getRootFolders(form: FormGroup) { this.rootFoldersRunning = true; - this.radarrService.getRootFolders(form.value).subscribe(x => { + this.lidarrService.getRootFolders(form.value).subscribe(x => { this.rootFolders = x; this.rootFolders.unshift({ path: "Please Select", id: -1 }); diff --git a/src/Ombi/ClientApp/app/settings/settingsmenu.component.html b/src/Ombi/ClientApp/app/settings/settingsmenu.component.html index a3e5a16e7..a8d89ab1c 100644 --- a/src/Ombi/ClientApp/app/settings/settingsmenu.component.html +++ b/src/Ombi/ClientApp/app/settings/settingsmenu.component.html @@ -50,7 +50,7 @@