diff --git a/src/Ombi.Core.Tests/Rule/Search/CouchPotatoCacheRuleTests.cs b/src/Ombi.Core.Tests/Rule/Search/CouchPotatoCacheRuleTests.cs index 56524522b..2a8f7a520 100644 --- a/src/Ombi.Core.Tests/Rule/Search/CouchPotatoCacheRuleTests.cs +++ b/src/Ombi.Core.Tests/Rule/Search/CouchPotatoCacheRuleTests.cs @@ -18,13 +18,13 @@ namespace Ombi.Core.Tests.Rule.Search [SetUp] public void Setup() { - ContextMock = new Mock>(); + ContextMock = new Mock>(); Rule = new CouchPotatoCacheRule(ContextMock.Object); } private CouchPotatoCacheRule Rule { get; set; } - private Mock> ContextMock { get; set; } + private Mock> ContextMock { get; set; } [Test] public async Task Should_ReturnApproved_WhenMovieIsInCouchPotato() diff --git a/src/Ombi.Core.Tests/Rule/Search/RadarrCacheRuleTests.cs b/src/Ombi.Core.Tests/Rule/Search/RadarrCacheRuleTests.cs index 914112d5b..94efe89a2 100644 --- a/src/Ombi.Core.Tests/Rule/Search/RadarrCacheRuleTests.cs +++ b/src/Ombi.Core.Tests/Rule/Search/RadarrCacheRuleTests.cs @@ -15,13 +15,13 @@ namespace Ombi.Core.Tests.Rule.Search [SetUp] public void Setup() { - ContextMock = new Mock>(); + ContextMock = new Mock>(); Rule = new RadarrCacheRule(ContextMock.Object); } private RadarrCacheRule Rule { get; set; } - private Mock> ContextMock { get; set; } + private Mock> ContextMock { get; set; } [Test] public async Task Should_ReturnApproved_WhenMovieIsInRadarr() diff --git a/src/Ombi.Core/Senders/TvSender.cs b/src/Ombi.Core/Senders/TvSender.cs index 1b3ed9461..b6c2aa8af 100644 --- a/src/Ombi.Core/Senders/TvSender.cs +++ b/src/Ombi.Core/Senders/TvSender.cs @@ -21,11 +21,12 @@ namespace Ombi.Core.Senders { public class TvSender : ITvSender { - public TvSender(ISonarrApi sonarrApi, ILogger log, ISettingsService sonarrSettings, + public TvSender(ISonarrApi sonarrApi, ISonarrV3Api sonarrV3Api, ILogger log, ISettingsService sonarrSettings, ISettingsService dog, IDogNzbApi dogApi, ISettingsService srSettings, ISickRageApi srApi, IRepository userProfiles) { SonarrApi = sonarrApi; + SonarrV3Api = sonarrV3Api; Logger = log; SonarrSettings = sonarrSettings; DogNzbSettings = dog; @@ -36,6 +37,7 @@ namespace Ombi.Core.Senders } private ISonarrApi SonarrApi { get; } + private ISonarrV3Api SonarrV3Api { get; } private IDogNzbApi DogNzbApi { get; } private ISickRageApi SickRageApi { get; } private ILogger Logger { get; } @@ -175,6 +177,16 @@ namespace Ombi.Core.Senders qualityToUse = model.ParentRequest.QualityOverride.Value; } + + // Are we using v3 sonarr? + var sonarrV3 = s.V3; + var languageProfileId = 0; + if (sonarrV3) + { + languageProfileId = s.LanguageProfile; + } + + try { // Does the series actually exist? diff --git a/src/Ombi.Settings/Settings/Models/External/SonarrSettings.cs b/src/Ombi.Settings/Settings/Models/External/SonarrSettings.cs index 81df73aad..bbbe58fd3 100644 --- a/src/Ombi.Settings/Settings/Models/External/SonarrSettings.cs +++ b/src/Ombi.Settings/Settings/Models/External/SonarrSettings.cs @@ -19,5 +19,6 @@ public string RootPathAnime { get; set; } public bool AddOnly { get; set; } public bool V3 { get; set; } + public int LanguageProfile { get; set; } } } \ No newline at end of file diff --git a/src/Ombi/ClientApp/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/app/interfaces/ISettings.ts index f1934a994..99662088e 100644 --- a/src/Ombi/ClientApp/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/app/interfaces/ISettings.ts @@ -72,6 +72,8 @@ export interface ISonarrSettings extends IExternalSettings { rootPathAnime: string; fullRootPath: string; addOnly: boolean; + v3: boolean; + languageProfile: number; } export interface IRadarrSettings extends IExternalSettings { diff --git a/src/Ombi/ClientApp/app/interfaces/ISonarr.ts b/src/Ombi/ClientApp/app/interfaces/ISonarr.ts index 3c71b835c..ffe9e9b6d 100644 --- a/src/Ombi/ClientApp/app/interfaces/ISonarr.ts +++ b/src/Ombi/ClientApp/app/interfaces/ISonarr.ts @@ -7,3 +7,8 @@ export interface ISonarrProfile { name: string; id: number; } + +export interface ILanguageProfiles { + name: string; + id: number; +} diff --git a/src/Ombi/ClientApp/app/services/applications/sonarr.service.ts b/src/Ombi/ClientApp/app/services/applications/sonarr.service.ts index 756c6ea6c..bce47acf9 100644 --- a/src/Ombi/ClientApp/app/services/applications/sonarr.service.ts +++ b/src/Ombi/ClientApp/app/services/applications/sonarr.service.ts @@ -5,7 +5,7 @@ import { HttpClient } from "@angular/common/http"; import { Observable } from "rxjs"; import { ISonarrSettings } from "../../interfaces"; -import { ISonarrProfile, ISonarrRootFolder } from "../../interfaces"; +import { ILanguageProfiles, ISonarrProfile, ISonarrRootFolder } from "../../interfaces"; import { ServiceHelpers } from "../service.helpers"; @Injectable() @@ -27,4 +27,8 @@ export class SonarrService extends ServiceHelpers { public getQualityProfilesWithoutSettings(): Observable { return this.http.get(`${this.url}/Profiles/`, {headers: this.headers}); } + + public getV3LanguageProfiles(settings: ISonarrSettings): Observable { + return this.http.post(`${this.url}/v3/languageprofiles/`, JSON.stringify(settings), {headers: this.headers}); + } } diff --git a/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.html b/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.html index 6a419feab..91385c353 100644 --- a/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.html +++ b/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.html @@ -1,5 +1,4 @@ - - +
Sonarr Settings @@ -10,33 +9,47 @@
-
-
- - +
+
+
+ + +
+
+
+ +
+
+
+ + +
- - - The IP/Hostname is required + + + The IP/Hostname is required
- - The Port is required + + The Port is required
- - - The API Key is required + + + The API Key is required
@@ -48,63 +61,80 @@
- +
-
-
- + + +
+ +
+ + + A Default Quality + Profile is required +
-
-
- -
- -
- A Default Quality Profile is required - -
-
+ +
- +
-
-
- -
-
-
+
- + + A Default Root Path + is + required
- A Default Root Path is required -
-
+ +
-
- +
+
+ +
+ + -
+ A Default + Langauage Profile is required +
+
+ + +
@@ -112,26 +142,27 @@
-
+
-
-
- +
+
+ +
-
- -
+
- +
+
-
+ \ No newline at end of file diff --git a/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.ts b/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.ts index 4af2c490e..ee2438f1b 100644 --- a/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.ts +++ b/src/Ombi/ClientApp/app/settings/sonarr/sonarr.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit } from "@angular/core"; import { FormBuilder, FormGroup, Validators } from "@angular/forms"; -import { ISonarrProfile, ISonarrRootFolder } from "../../interfaces"; +import { ILanguageProfiles, ISonarrProfile, ISonarrRootFolder } from "../../interfaces"; import { ISonarrSettings } from "../../interfaces"; import { SonarrService } from "../../services"; @@ -18,10 +18,13 @@ export class SonarrComponent implements OnInit { public qualitiesAnime: ISonarrProfile[]; public rootFolders: ISonarrRootFolder[]; public rootFoldersAnime: ISonarrRootFolder[]; + public languageProfiles: ILanguageProfiles[]; public selectedRootFolder: ISonarrRootFolder; public selectedQuality: ISonarrProfile; + public selectedLanguageProfiles: ILanguageProfiles; public profilesRunning: boolean; public rootFoldersRunning: boolean; + public langRunning: boolean; public form: FormGroup; public advanced = false; @@ -48,6 +51,7 @@ export class SonarrComponent implements OnInit { addOnly: [x.addOnly], seasonFolders: [x.seasonFolders], v3: [x.v3], + langaugeProfile: [x.languageProfile], }); if (x.qualityProfile) { @@ -56,11 +60,16 @@ export class SonarrComponent implements OnInit { if (x.rootPath) { this.getRootFolders(this.form); } + if(x.languageProfile) { + this.getLanguageProfiles(this.form); + } }); this.rootFolders = []; this.qualities = []; + this.languageProfiles = []; this.rootFolders.push({ path: "Please Select", id: -1 }); this.qualities.push({ name: "Please Select", id: -1 }); + this.languageProfiles.push({ name: "Please Select", id: -1 }); } public getProfiles(form: FormGroup) { @@ -89,6 +98,18 @@ export class SonarrComponent implements OnInit { }); } + public getLanguageProfiles(form: FormGroup) { + this.langRunning = true; + this.sonarrService.getV3LanguageProfiles(form.value) + .subscribe(x => { + this.languageProfiles = x; + this.languageProfiles.unshift({ name: "Please Select", id: -1 }); + + this.langRunning = false; + this.notificationService.success("Successfully retrieved the Languge Profiles"); + }); + } + public test(form: FormGroup) { if (form.invalid) { this.notificationService.error("Please check your entered values"); diff --git a/src/Ombi/Controllers/External/SonarrController.cs b/src/Ombi/Controllers/External/SonarrController.cs index c3401736d..bc2534ab8 100644 --- a/src/Ombi/Controllers/External/SonarrController.cs +++ b/src/Ombi/Controllers/External/SonarrController.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Ombi.Api.Sonarr; using Ombi.Api.Sonarr.Models; +using Ombi.Api.Sonarr.Models.V3; using Ombi.Attributes; using Ombi.Core.Settings; using Ombi.Core.Settings.Models.External; @@ -16,14 +17,16 @@ namespace Ombi.Controllers.External [Produces("application/json")] public class SonarrController : Controller { - public SonarrController(ISonarrApi sonarr, ISettingsService settings) + public SonarrController(ISonarrApi sonarr, ISonarrV3Api sonarrv3, ISettingsService settings) { SonarrApi = sonarr; + SonarrV3Api = sonarrv3; SonarrSettings = settings; SonarrSettings.ClearCache(); } private ISonarrApi SonarrApi { get; } + private ISonarrV3Api SonarrV3Api { get; } private ISettingsService SonarrSettings { get; } /// @@ -82,5 +85,36 @@ namespace Ombi.Controllers.External return null; } + + /// + /// Gets the Sonarr V3 language profiles + /// + /// + [HttpGet("v3/LanguageProfiles")] + [PowerUser] + public async Task> GetLanguageProfiles() + { + var settings = await SonarrSettings.GetSettingsAsync(); + if (settings.Enabled) + { + return await SonarrV3Api.LanguageProfiles(settings.ApiKey, settings.FullUri); + } + + return null; + } + + + /// + /// Gets the Sonarr V3 language profiles + /// + /// The settings. + /// + [HttpPost("v3/LanguageProfiles")] + [PowerUser] + public async Task> GetLanguageProfiles([FromBody] SonarrSettings settings) + { + return await SonarrV3Api.LanguageProfiles(settings.ApiKey, settings.FullUri); + } + } } \ No newline at end of file