mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-30 11:48:26 -07:00
New: Filter Sonarr synchronization based on Root Folders
Closes #3569 (cherry picked from commit ff3327483a233ebe54d8f178c355abaeb6f9d11e)
This commit is contained in:
parent
f026fea211
commit
bfe917a09e
4 changed files with 60 additions and 10 deletions
|
@ -11,6 +11,7 @@ namespace NzbDrone.Core.ImportLists.Lidarr
|
|||
public List<MediaCover.MediaCover> Images { get; set; }
|
||||
public bool Monitored { get; set; }
|
||||
public int QualityProfileId { get; set; }
|
||||
public string RootFolderPath { get; set; }
|
||||
public HashSet<int> Tags { get; set; }
|
||||
}
|
||||
|
||||
|
@ -36,4 +37,10 @@ namespace NzbDrone.Core.ImportLists.Lidarr
|
|||
public string Label { get; set; }
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
public class LidarrRootFolder
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,18 +42,34 @@ namespace NzbDrone.Core.ImportLists.Lidarr
|
|||
foreach (var remoteAlbum in remoteAlbums)
|
||||
{
|
||||
var remoteArtist = artistDict[remoteAlbum.ArtistId];
|
||||
if ((!Settings.ProfileIds.Any() || Settings.ProfileIds.Contains(remoteArtist.QualityProfileId)) &&
|
||||
(!Settings.TagIds.Any() || Settings.TagIds.Any(x => remoteArtist.Tags.Any(y => y == x))) &&
|
||||
remoteAlbum.Monitored && remoteArtist.Monitored)
|
||||
|
||||
if (Settings.ProfileIds.Any() && !Settings.ProfileIds.Contains(remoteArtist.QualityProfileId))
|
||||
{
|
||||
artistsAndAlbums.Add(new ImportListItemInfo
|
||||
{
|
||||
ArtistMusicBrainzId = remoteArtist.ForeignArtistId,
|
||||
Artist = remoteArtist.ArtistName,
|
||||
AlbumMusicBrainzId = remoteAlbum.ForeignAlbumId,
|
||||
Album = remoteAlbum.Title
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Settings.TagIds.Any() && !Settings.TagIds.Any(x => remoteArtist.Tags.Any(y => y == x)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Settings.RootFolderPaths.Any() && !Settings.RootFolderPaths.Any(rootFolderPath => remoteArtist.RootFolderPath.ContainsIgnoreCase(rootFolderPath)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!remoteAlbum.Monitored || !remoteArtist.Monitored)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
artistsAndAlbums.Add(new ImportListItemInfo
|
||||
{
|
||||
ArtistMusicBrainzId = remoteArtist.ForeignArtistId,
|
||||
Artist = remoteArtist.ArtistName,
|
||||
AlbumMusicBrainzId = remoteAlbum.ForeignAlbumId,
|
||||
Album = remoteAlbum.Title
|
||||
});
|
||||
}
|
||||
|
||||
_importListStatusService.RecordSuccess(Definition.Id);
|
||||
|
@ -109,6 +125,23 @@ namespace NzbDrone.Core.ImportLists.Lidarr
|
|||
};
|
||||
}
|
||||
|
||||
if (action == "getRootFolders")
|
||||
{
|
||||
Settings.Validate().Filter("ApiKey").ThrowOnError();
|
||||
|
||||
var remoteRootfolders = _lidarrV1Proxy.GetRootFolders(Settings);
|
||||
|
||||
return new
|
||||
{
|
||||
options = remoteRootfolders.OrderBy(d => d.Path, StringComparer.InvariantCultureIgnoreCase)
|
||||
.Select(d => new
|
||||
{
|
||||
value = d.Path,
|
||||
name = d.Path
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
return new { };
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace NzbDrone.Core.ImportLists.Lidarr
|
|||
ApiKey = "";
|
||||
ProfileIds = Array.Empty<int>();
|
||||
TagIds = Array.Empty<int>();
|
||||
RootFolderPaths = Array.Empty<string>();
|
||||
}
|
||||
|
||||
[FieldDefinition(0, Label = "Full URL", HelpText = "URL, including port, of the Lidarr instance to import from")]
|
||||
|
@ -39,6 +40,9 @@ namespace NzbDrone.Core.ImportLists.Lidarr
|
|||
[FieldDefinition(3, Type = FieldType.Select, SelectOptionsProviderAction = "getTags", Label = "Tags", HelpText = "Tags from the source instance to import from")]
|
||||
public IEnumerable<int> TagIds { get; set; }
|
||||
|
||||
[FieldDefinition(4, 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.Lidarr
|
|||
List<LidarrArtist> GetArtists(LidarrSettings settings);
|
||||
List<LidarrAlbum> GetAlbums(LidarrSettings settings);
|
||||
List<LidarrProfile> GetProfiles(LidarrSettings settings);
|
||||
List<LidarrRootFolder> GetRootFolders(LidarrSettings settings);
|
||||
List<LidarrTag> GetTags(LidarrSettings settings);
|
||||
ValidationFailure Test(LidarrSettings settings);
|
||||
}
|
||||
|
@ -44,6 +45,11 @@ namespace NzbDrone.Core.ImportLists.Lidarr
|
|||
return Execute<LidarrProfile>("/api/v1/qualityprofile", settings);
|
||||
}
|
||||
|
||||
public List<LidarrRootFolder> GetRootFolders(LidarrSettings settings)
|
||||
{
|
||||
return Execute<LidarrRootFolder>("api/v1/rootfolder", settings);
|
||||
}
|
||||
|
||||
public List<LidarrTag> GetTags(LidarrSettings settings)
|
||||
{
|
||||
return Execute<LidarrTag>("/api/v1/tag", settings);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue