44using NzbDrone . Core . Plugins ;
55using NzbDrone . Core . Plugins . Resources ;
66using System . Text . RegularExpressions ;
7+
78namespace 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