parent
07c95f06d3
commit
519a5ca75c
|
@ -37,6 +37,7 @@ namespace NzbDrone.Core.Annotations
|
||||||
public int Order { get; private set; }
|
public int Order { get; private set; }
|
||||||
public string Label { get; set; }
|
public string Label { get; set; }
|
||||||
public string Hint { get; set; }
|
public string Hint { get; set; }
|
||||||
|
public string RequestAction { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FieldSelectOption
|
public class FieldSelectOption
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace NzbDrone.Core.ImportLists.Sonarr
|
||||||
public int Year { get; set; }
|
public int Year { get; set; }
|
||||||
public string TitleSlug { get; set; }
|
public string TitleSlug { get; set; }
|
||||||
public int QualityProfileId { get; set; }
|
public int QualityProfileId { get; set; }
|
||||||
|
public HashSet<int> Tags { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SonarrProfile
|
public class SonarrProfile
|
||||||
|
@ -21,4 +22,10 @@ namespace NzbDrone.Core.ImportLists.Sonarr
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SonarrTag
|
||||||
|
{
|
||||||
|
public string Label { get; set; }
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,8 @@ namespace NzbDrone.Core.ImportLists.Sonarr
|
||||||
|
|
||||||
foreach (var item in remoteSeries)
|
foreach (var item in remoteSeries)
|
||||||
{
|
{
|
||||||
if (!Settings.ProfileIds.Any() || Settings.ProfileIds.Contains(item.QualityProfileId))
|
if ((!Settings.ProfileIds.Any() || Settings.ProfileIds.Contains(item.QualityProfileId)) &&
|
||||||
|
(!Settings.TagIds.Any() || Settings.TagIds.Any(tagId => item.Tags.Any(itemTagId => itemTagId == tagId))))
|
||||||
{
|
{
|
||||||
series.Add(new ImportListItemInfo
|
series.Add(new ImportListItemInfo
|
||||||
{
|
{
|
||||||
|
@ -60,24 +61,24 @@ namespace NzbDrone.Core.ImportLists.Sonarr
|
||||||
|
|
||||||
public override object RequestAction(string action, IDictionary<string, string> query)
|
public override object RequestAction(string action, IDictionary<string, string> query)
|
||||||
{
|
{
|
||||||
if (action == "getDevices")
|
// Return early if there is not an API key
|
||||||
|
if (Settings.ApiKey.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
// Return early if there is not an API key
|
return new
|
||||||
if (Settings.ApiKey.IsNullOrWhiteSpace())
|
|
||||||
{
|
{
|
||||||
return new
|
devices = new List<object>()
|
||||||
{
|
};
|
||||||
devices = new List<object>()
|
}
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (action == "getProfiles")
|
||||||
|
{
|
||||||
Settings.Validate().Filter("ApiKey").ThrowOnError();
|
Settings.Validate().Filter("ApiKey").ThrowOnError();
|
||||||
|
|
||||||
var devices = _sonarrV3Proxy.GetProfiles(Settings);
|
var profiles = _sonarrV3Proxy.GetProfiles(Settings);
|
||||||
|
|
||||||
return new
|
return new
|
||||||
{
|
{
|
||||||
options = devices.OrderBy(d => d.Name, StringComparer.InvariantCultureIgnoreCase)
|
options = profiles.OrderBy(d => d.Name, StringComparer.InvariantCultureIgnoreCase)
|
||||||
.Select(d => new
|
.Select(d => new
|
||||||
{
|
{
|
||||||
id = d.Id,
|
id = d.Id,
|
||||||
|
@ -86,6 +87,21 @@ namespace NzbDrone.Core.ImportLists.Sonarr
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (action == "getTags")
|
||||||
|
{
|
||||||
|
var tags = _sonarrV3Proxy.GetTags(Settings);
|
||||||
|
|
||||||
|
return new
|
||||||
|
{
|
||||||
|
options = tags.OrderBy(d => d.Label, StringComparer.InvariantCultureIgnoreCase)
|
||||||
|
.Select(d => new
|
||||||
|
{
|
||||||
|
id = d.Id,
|
||||||
|
name = d.Label
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return new { };
|
return new { };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace NzbDrone.Core.ImportLists.Sonarr
|
||||||
BaseUrl = "";
|
BaseUrl = "";
|
||||||
ApiKey = "";
|
ApiKey = "";
|
||||||
ProfileIds = new int[] { };
|
ProfileIds = new int[] { };
|
||||||
|
TagIds = new int[] { };
|
||||||
}
|
}
|
||||||
|
|
||||||
[FieldDefinition(0, Label = "Full URL", HelpText = "URL, including port, of the Sonarr V3 instance to import from")]
|
[FieldDefinition(0, Label = "Full URL", HelpText = "URL, including port, of the Sonarr V3 instance to import from")]
|
||||||
|
@ -31,9 +32,12 @@ namespace NzbDrone.Core.ImportLists.Sonarr
|
||||||
[FieldDefinition(1, Label = "API Key", HelpText = "Apikey of the Sonarr V3 instance to import from")]
|
[FieldDefinition(1, Label = "API Key", HelpText = "Apikey of the Sonarr V3 instance to import from")]
|
||||||
public string ApiKey { get; set; }
|
public string ApiKey { get; set; }
|
||||||
|
|
||||||
[FieldDefinition(2, Type = FieldType.Device, Label = "Profiles", HelpText = "Profiles from the source instance to import from")]
|
[FieldDefinition(2, Type = FieldType.Select, SelectOptionsProviderAction = "getProfiles", Label = "Profiles", HelpText = "Profiles from the source instance to import from")]
|
||||||
public IEnumerable<int> ProfileIds { get; set; }
|
public IEnumerable<int> ProfileIds { get; set; }
|
||||||
|
|
||||||
|
[FieldDefinition(3, 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()
|
public NzbDroneValidationResult Validate()
|
||||||
{
|
{
|
||||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace NzbDrone.Core.ImportLists.Sonarr
|
||||||
{
|
{
|
||||||
List<SonarrSeries> GetSeries(SonarrSettings settings);
|
List<SonarrSeries> GetSeries(SonarrSettings settings);
|
||||||
List<SonarrProfile> GetProfiles(SonarrSettings settings);
|
List<SonarrProfile> GetProfiles(SonarrSettings settings);
|
||||||
|
List<SonarrTag> GetTags(SonarrSettings settings);
|
||||||
ValidationFailure Test(SonarrSettings settings);
|
ValidationFailure Test(SonarrSettings settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +38,11 @@ namespace NzbDrone.Core.ImportLists.Sonarr
|
||||||
return Execute<SonarrProfile>("/api/v3/qualityprofile", settings);
|
return Execute<SonarrProfile>("/api/v3/qualityprofile", settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<SonarrTag> GetTags(SonarrSettings settings)
|
||||||
|
{
|
||||||
|
return Execute<SonarrTag>("/api/v3/tag", settings);
|
||||||
|
}
|
||||||
|
|
||||||
public ValidationFailure Test(SonarrSettings settings)
|
public ValidationFailure Test(SonarrSettings settings)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
Loading…
Reference in New Issue