Skip to content

Commit 0e41f61

Browse files
author
Meyn
committed
Fix FlexiblePluginService
1 parent ad16cf9 commit 0e41f61

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

Tubifarry/Core/Utilities/FlexiblePluginService.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
using NzbDrone.Core.Plugins;
55
using NzbDrone.Core.Plugins.Resources;
66
using System.Text.RegularExpressions;
7+
78
namespace Tubifarry.Core.Utilities
89
{
910
public class FlexiblePluginService : PluginService, IPluginService
1011
{
11-
private static readonly Regex MinVersionRegex = new(@"\**Minimum Lidarr Version: (?<version>\d+\.\d+\.\d+\.\d+)\**", RegexOptions.Compiled);
12-
private static readonly Regex RepoRegex = new(@"https://github\.com/(?<owner>[^/]+)/(?<name>[^/]+)(/tree/(?<branch>[^/]+))?", RegexOptions.Compiled);
12+
private static readonly Regex MinVersionRegex = new(@"Minimum Lidarr Version:?\s*(?:\*\*)?[\s]*(?<version>\d+\.\d+\.\d+\.\d+)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
13+
private static readonly Regex RepoRegex = new(@"https://github\.com/(?<owner>[^/]+)/(?<name>[^/]+)(?:/tree/(?<branch>[^/\s]+))?", RegexOptions.Compiled);
1314
private readonly Logger _logger;
1415
private readonly IHttpClient _httpClient;
1516

@@ -33,19 +34,19 @@ public FlexiblePluginService(IHttpClient httpClient,
3334
return null;
3435
}
3536

36-
Release? latest = releases?.OrderByDescending(x => x.PublishedAt).FirstOrDefault(x => IsSupported(x, branch));
37+
var framework = branch == null ? "net6.0" : $"net6.0-{branch}";
38+
39+
releases = releases!.Where(release => release.Assets.Any(asset => asset.Name.EndsWith($"{framework}.zip"))).ToList();
40+
var latest = releases.OrderByDescending(x => x.PublishedAt).FirstOrDefault(x => IsSupported(x, branch));
3741

3842
if (latest == null)
3943
{
4044
_logger.Warn($"Plugin {name} requires newer version of Lidarr");
4145
return null;
4246
}
4347

44-
45-
Version version = Version.Parse(latest.TagName.TrimStart('v'));
46-
string framework = branch == null ? "net6.0" : $"net6.0-{branch}";
47-
48-
Asset? asset = latest.Assets.FirstOrDefault(x => x.Name.EndsWith($"{framework}.zip"));
48+
var version = Version.Parse(latest.TagName.TrimStart('v'));
49+
var asset = latest.Assets.FirstOrDefault(x => x.Name.EndsWith($"{framework}.zip"));
4950

5051
if (asset == null)
5152
{
@@ -83,7 +84,7 @@ private static bool IsSupported(Release release, string? branch)
8384
if (match.Success)
8485
{
8586
Version minVersion = Version.Parse(match.Groups["version"].Value);
86-
if (minVersion > BuildInfo.Version && minVersion < new Version(100, 0))
87+
if (minVersion > BuildInfo.Version)
8788
return false;
8889
}
8990
Version version = Version.Parse(release.TagName.TrimStart('v'));

0 commit comments

Comments
 (0)