You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.2 KiB
39 lines
1.2 KiB
using System;
|
|
using System.Reactive.Concurrency;
|
|
using System.Reactive.Linq;
|
|
using Flurl.Http;
|
|
using TrashLib.Config.Services;
|
|
|
|
namespace TrashLib.Sonarr;
|
|
|
|
public class SonarrCompatibility : ISonarrCompatibility
|
|
{
|
|
public SonarrCompatibility(IServerInfo serverInfo)
|
|
{
|
|
Capabilities = Observable.FromAsync(
|
|
async () => await serverInfo.BuildRequest()
|
|
.AppendPathSegment("system/status")
|
|
.GetJsonAsync(), NewThreadScheduler.Default)
|
|
.Timeout(TimeSpan.FromSeconds(15))
|
|
.Select(x => new Version(x.version))
|
|
.Select(BuildCapabilitiesObject)
|
|
.Replay(1)
|
|
.AutoConnect();
|
|
}
|
|
|
|
public IObservable<SonarrCapabilities> Capabilities { get; }
|
|
public Version MinimumVersion => new("3.0.4.1098");
|
|
|
|
private SonarrCapabilities BuildCapabilitiesObject(Version version)
|
|
{
|
|
return new SonarrCapabilities(version)
|
|
{
|
|
SupportsNamedReleaseProfiles =
|
|
version >= MinimumVersion,
|
|
|
|
ArraysNeededForReleaseProfileRequiredAndIgnored =
|
|
version >= new Version("3.0.6.1355")
|
|
};
|
|
}
|
|
}
|