New: Sonarr Sync on Language Profile

pull/5062/head
Qstick 2 years ago committed by Mark McDowall
parent 0991cfe27e
commit 41a821352e

@ -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
})
};
}

@ -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<int> 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<int> LanguageProfileIds { get; set; }
[FieldDefinition(4, Type = FieldType.Select, SelectOptionsProviderAction = "getTags", Label = "Tags", HelpText = "Tags from the source instance to import from")]
public IEnumerable<int> TagIds { get; set; }
public NzbDroneValidationResult Validate()

@ -12,7 +12,8 @@ namespace NzbDrone.Core.ImportLists.Sonarr
public interface ISonarrV3Proxy
{
List<SonarrSeries> GetSeries(SonarrSettings settings);
List<SonarrProfile> GetProfiles(SonarrSettings settings);
List<SonarrProfile> GetQualityProfiles(SonarrSettings settings);
List<SonarrProfile> GetLanguageProfiles(SonarrSettings settings);
List<SonarrTag> GetTags(SonarrSettings settings);
ValidationFailure Test(SonarrSettings settings);
}
@ -33,11 +34,16 @@ namespace NzbDrone.Core.ImportLists.Sonarr
return Execute<SonarrSeries>("/api/v3/series", settings);
}
public List<SonarrProfile> GetProfiles(SonarrSettings settings)
public List<SonarrProfile> GetQualityProfiles(SonarrSettings settings)
{
return Execute<SonarrProfile>("/api/v3/qualityprofile", settings);
}
public List<SonarrProfile> GetLanguageProfiles(SonarrSettings settings)
{
return Execute<SonarrProfile>("/api/v3/languageprofile", settings);
}
public List<SonarrTag> GetTags(SonarrSettings settings)
{
return Execute<SonarrTag>("/api/v3/tag", settings);

Loading…
Cancel
Save