parent
0bc16efe26
commit
ff3327483a
|
@ -15,6 +15,7 @@ namespace NzbDrone.Core.ImportLists.Sonarr
|
||||||
public string TitleSlug { get; set; }
|
public string TitleSlug { get; set; }
|
||||||
public int QualityProfileId { get; set; }
|
public int QualityProfileId { get; set; }
|
||||||
public int LanguageProfileId { get; set; }
|
public int LanguageProfileId { get; set; }
|
||||||
|
public string RootFolderPath { get; set; }
|
||||||
public HashSet<int> Tags { get; set; }
|
public HashSet<int> Tags { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,4 +30,10 @@ namespace NzbDrone.Core.ImportLists.Sonarr
|
||||||
public string Label { get; set; }
|
public string Label { get; set; }
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SonarrRootFolder
|
||||||
|
{
|
||||||
|
public string Path { get; set; }
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,17 +39,32 @@ 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.LanguageProfileIds.Any() || Settings.LanguageProfileIds.Contains(item.LanguageProfileId)) &&
|
|
||||||
(!Settings.TagIds.Any() || Settings.TagIds.Any(tagId => item.Tags.Any(itemTagId => itemTagId == tagId))))
|
|
||||||
{
|
{
|
||||||
|
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
|
series.Add(new ImportListItemInfo
|
||||||
{
|
{
|
||||||
TvdbId = item.TvdbId,
|
TvdbId = item.TvdbId,
|
||||||
Title = item.Title
|
Title = item.Title
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_importListStatusService.RecordSuccess(Definition.Id);
|
_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 { };
|
return new { };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,13 @@ namespace NzbDrone.Core.ImportLists.Sonarr
|
||||||
ProfileIds = Array.Empty<int>();
|
ProfileIds = Array.Empty<int>();
|
||||||
LanguageProfileIds = Array.Empty<int>();
|
LanguageProfileIds = Array.Empty<int>();
|
||||||
TagIds = 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; }
|
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; }
|
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")]
|
[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")]
|
[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 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()
|
public NzbDroneValidationResult Validate()
|
||||||
{
|
{
|
||||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace NzbDrone.Core.ImportLists.Sonarr
|
||||||
List<SonarrSeries> GetSeries(SonarrSettings settings);
|
List<SonarrSeries> GetSeries(SonarrSettings settings);
|
||||||
List<SonarrProfile> GetQualityProfiles(SonarrSettings settings);
|
List<SonarrProfile> GetQualityProfiles(SonarrSettings settings);
|
||||||
List<SonarrProfile> GetLanguageProfiles(SonarrSettings settings);
|
List<SonarrProfile> GetLanguageProfiles(SonarrSettings settings);
|
||||||
|
List<SonarrRootFolder> GetRootFolders(SonarrSettings settings);
|
||||||
List<SonarrTag> GetTags(SonarrSettings settings);
|
List<SonarrTag> GetTags(SonarrSettings settings);
|
||||||
ValidationFailure Test(SonarrSettings settings);
|
ValidationFailure Test(SonarrSettings settings);
|
||||||
}
|
}
|
||||||
|
@ -44,6 +45,11 @@ namespace NzbDrone.Core.ImportLists.Sonarr
|
||||||
return Execute<SonarrProfile>("/api/v3/languageprofile", settings);
|
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)
|
public List<SonarrTag> GetTags(SonarrSettings settings)
|
||||||
{
|
{
|
||||||
return Execute<SonarrTag>("/api/v3/tag", settings);
|
return Execute<SonarrTag>("/api/v3/tag", settings);
|
||||||
|
|
Loading…
Reference in New Issue