diff --git a/src/NzbDrone.Core/ImportLists/Sonarr/SonarrImport.cs b/src/NzbDrone.Core/ImportLists/Sonarr/SonarrImport.cs index 846cf648d..540cb822f 100644 --- a/src/NzbDrone.Core/ImportLists/Sonarr/SonarrImport.cs +++ b/src/NzbDrone.Core/ImportLists/Sonarr/SonarrImport.cs @@ -39,6 +39,7 @@ namespace NzbDrone.Core.ImportLists.Sonarr foreach (var item in remoteSeries) { if ((!Settings.ProfileIds.Any() || Settings.ProfileIds.Contains(item.QualityProfileId)) && + (!Settings.LanguageProfileIds.Any() || Settings.LanguageProfileIds.Contains(item.QualityProfileId)) && (!Settings.TagIds.Any() || Settings.TagIds.Any(tagId => item.Tags.Any(itemTagId => itemTagId == tagId)))) { series.Add(new ImportListItemInfo @@ -74,16 +75,33 @@ namespace NzbDrone.Core.ImportLists.Sonarr { Settings.Validate().Filter("ApiKey").ThrowOnError(); - var profiles = _sonarrV3Proxy.GetProfiles(Settings); + var profiles = _sonarrV3Proxy.GetQualityProfiles(Settings); return new { options = profiles.OrderBy(d => d.Name, StringComparer.InvariantCultureIgnoreCase) - .Select(d => new - { - value = d.Id, - name = d.Name - }) + .Select(d => new + { + value = d.Id, + name = d.Name + }) + }; + } + + if (action == "getLanguageProfiles") + { + Settings.Validate().Filter("ApiKey").ThrowOnError(); + + var langProfiles = _sonarrV3Proxy.GetLanguageProfiles(Settings); + + return new + { + options = langProfiles.OrderBy(d => d.Name, StringComparer.InvariantCultureIgnoreCase) + .Select(d => new + { + value = d.Id, + name = d.Name + }) }; } diff --git a/src/NzbDrone.Core/ImportLists/Sonarr/SonarrSettings.cs b/src/NzbDrone.Core/ImportLists/Sonarr/SonarrSettings.cs index 2cc883b8f..3b607a2cf 100644 --- a/src/NzbDrone.Core/ImportLists/Sonarr/SonarrSettings.cs +++ b/src/NzbDrone.Core/ImportLists/Sonarr/SonarrSettings.cs @@ -23,6 +23,7 @@ namespace NzbDrone.Core.ImportLists.Sonarr BaseUrl = ""; ApiKey = ""; ProfileIds = new int[] { }; + LanguageProfileIds = new int[] { }; TagIds = new int[] { }; } @@ -32,10 +33,13 @@ namespace NzbDrone.Core.ImportLists.Sonarr [FieldDefinition(1, Label = "API Key", HelpText = "Apikey of the Sonarr V3 instance to import from")] public string ApiKey { get; set; } - [FieldDefinition(2, Type = FieldType.Select, SelectOptionsProviderAction = "getProfiles", Label = "Profiles", HelpText = "Profiles from the source instance to import from")] + [FieldDefinition(2, Type = FieldType.Select, SelectOptionsProviderAction = "getProfiles", Label = "Quality Profiles", HelpText = "Quality Profiles from the source instance to import from")] public IEnumerable ProfileIds { get; set; } - [FieldDefinition(3, Type = FieldType.Select, SelectOptionsProviderAction = "getTags", Label = "Tags", HelpText = "Tags from the source instance to import from")] + [FieldDefinition(3, Type = FieldType.Select, SelectOptionsProviderAction = "getLanguageProfiles", Label = "Language Profiles", HelpText = "Language Profiles from the source instance to import from")] + public IEnumerable LanguageProfileIds { get; set; } + + [FieldDefinition(4, Type = FieldType.Select, SelectOptionsProviderAction = "getTags", Label = "Tags", HelpText = "Tags from the source instance to import from")] public IEnumerable TagIds { get; set; } public NzbDroneValidationResult Validate() diff --git a/src/NzbDrone.Core/ImportLists/Sonarr/SonarrV3Proxy.cs b/src/NzbDrone.Core/ImportLists/Sonarr/SonarrV3Proxy.cs index 46038b491..3a53ad134 100644 --- a/src/NzbDrone.Core/ImportLists/Sonarr/SonarrV3Proxy.cs +++ b/src/NzbDrone.Core/ImportLists/Sonarr/SonarrV3Proxy.cs @@ -12,7 +12,8 @@ namespace NzbDrone.Core.ImportLists.Sonarr public interface ISonarrV3Proxy { List GetSeries(SonarrSettings settings); - List GetProfiles(SonarrSettings settings); + List GetQualityProfiles(SonarrSettings settings); + List GetLanguageProfiles(SonarrSettings settings); List GetTags(SonarrSettings settings); ValidationFailure Test(SonarrSettings settings); } @@ -33,11 +34,16 @@ namespace NzbDrone.Core.ImportLists.Sonarr return Execute("/api/v3/series", settings); } - public List GetProfiles(SonarrSettings settings) + public List GetQualityProfiles(SonarrSettings settings) { return Execute("/api/v3/qualityprofile", settings); } + public List GetLanguageProfiles(SonarrSettings settings) + { + return Execute("/api/v3/languageprofile", settings); + } + public List GetTags(SonarrSettings settings) { return Execute("/api/v3/tag", settings);