New: Filter Sonarr synchronization based on Root Folders

Closes #4835
pull/5578/head
Lars 1 year ago committed by GitHub
parent 0bc16efe26
commit ff3327483a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -15,6 +15,7 @@ namespace NzbDrone.Core.ImportLists.Sonarr
public string TitleSlug { get; set; }
public int QualityProfileId { get; set; }
public int LanguageProfileId { get; set; }
public string RootFolderPath { get; set; }
public HashSet<int> Tags { get; set; }
}
@ -29,4 +30,10 @@ namespace NzbDrone.Core.ImportLists.Sonarr
public string Label { get; set; }
public int Id { get; set; }
}
public class SonarrRootFolder
{
public string Path { get; set; }
public int Id { get; set; }
}
}

@ -39,16 +39,31 @@ 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.LanguageProfileId)) &&
(!Settings.TagIds.Any() || Settings.TagIds.Any(tagId => item.Tags.Any(itemTagId => itemTagId == tagId))))
if (Settings.ProfileIds.Any() && !Settings.ProfileIds.Contains(item.QualityProfileId))
{
series.Add(new ImportListItemInfo
{
TvdbId = item.TvdbId,
Title = item.Title
});
continue;
}
if (Settings.LanguageProfileIds.Any() && !Settings.LanguageProfileIds.Contains(item.LanguageProfileId))
{
continue;
}
if (Settings.TagIds.Any() && !Settings.TagIds.Any(tagId => item.Tags.Any(itemTagId => itemTagId == tagId)))
{
continue;
}
if (Settings.RootFolderPaths.Any() && !Settings.RootFolderPaths.Any(rootFolderPath => item.RootFolderPath.ContainsIgnoreCase(rootFolderPath)))
{
continue;
}
series.Add(new ImportListItemInfo
{
TvdbId = item.TvdbId,
Title = item.Title
});
}
_importListStatusService.RecordSuccess(Definition.Id);
@ -121,6 +136,23 @@ namespace NzbDrone.Core.ImportLists.Sonarr
};
}
if (action == "getRootFolders")
{
Settings.Validate().Filter("ApiKey").ThrowOnError();
var remoteRootfolders = _sonarrV3Proxy.GetRootFolders(Settings);
return new
{
options = remoteRootfolders.OrderBy(d => d.Path, StringComparer.InvariantCultureIgnoreCase)
.Select(d => new
{
value = d.Path,
name = d.Path
})
};
}
return new { };
}

@ -26,12 +26,13 @@ namespace NzbDrone.Core.ImportLists.Sonarr
ProfileIds = Array.Empty<int>();
LanguageProfileIds = Array.Empty<int>();
TagIds = Array.Empty<int>();
RootFolderPaths = Array.Empty<string>();
}
[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 instance to import from")]
public string BaseUrl { get; set; }
[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 instance to import from")]
public string ApiKey { get; set; }
[FieldDefinition(2, Type = FieldType.Select, SelectOptionsProviderAction = "getProfiles", Label = "Quality Profiles", HelpText = "Quality Profiles from the source instance to import from")]
@ -43,6 +44,9 @@ namespace NzbDrone.Core.ImportLists.Sonarr
[FieldDefinition(4, Type = FieldType.Select, SelectOptionsProviderAction = "getTags", Label = "Tags", HelpText = "Tags from the source instance to import from")]
public IEnumerable<int> TagIds { get; set; }
[FieldDefinition(5, Type = FieldType.Select, SelectOptionsProviderAction = "getRootFolders", Label = "Root Folders", HelpText = "Root Folders from the source instance to import from")]
public IEnumerable<string> RootFolderPaths { get; set; }
public NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));

@ -14,6 +14,7 @@ namespace NzbDrone.Core.ImportLists.Sonarr
List<SonarrSeries> GetSeries(SonarrSettings settings);
List<SonarrProfile> GetQualityProfiles(SonarrSettings settings);
List<SonarrProfile> GetLanguageProfiles(SonarrSettings settings);
List<SonarrRootFolder> GetRootFolders(SonarrSettings settings);
List<SonarrTag> GetTags(SonarrSettings settings);
ValidationFailure Test(SonarrSettings settings);
}
@ -44,6 +45,11 @@ namespace NzbDrone.Core.ImportLists.Sonarr
return Execute<SonarrProfile>("/api/v3/languageprofile", settings);
}
public List<SonarrRootFolder> GetRootFolders(SonarrSettings settings)
{
return Execute<SonarrRootFolder>("api/v3/rootfolder", settings);
}
public List<SonarrTag> GetTags(SonarrSettings settings)
{
return Execute<SonarrTag>("/api/v3/tag", settings);

Loading…
Cancel
Save