mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 21:43:33 -07:00
Restrict nzbs based on release group, server side
New: Only grab NZBs if release group is wanted (configurable)
This commit is contained in:
parent
2a316e0b98
commit
67064ec495
7 changed files with 132 additions and 2 deletions
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using Ninject;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
|
||||
namespace NzbDrone.Core.Providers.DecisionEngine
|
||||
{
|
||||
public class AllowedReleaseGroupSpecification
|
||||
{
|
||||
private readonly ConfigProvider _configProvider;
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
[Inject]
|
||||
public AllowedReleaseGroupSpecification(ConfigProvider configProvider)
|
||||
{
|
||||
_configProvider = configProvider;
|
||||
}
|
||||
|
||||
public AllowedReleaseGroupSpecification()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
|
||||
{
|
||||
logger.Trace("Beginning release group check for: {0}", subject);
|
||||
|
||||
var allowed = _configProvider.AllowedReleaseGroups;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(allowed))
|
||||
return true;
|
||||
|
||||
foreach(var group in allowed.Trim(',', ' ').Split(','))
|
||||
{
|
||||
if (subject.ReleaseGroup.Equals(group.Trim(' '), StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
logger.Trace("Item: {0}'s release group is wanted: {1}", subject, subject.ReleaseGroup);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
logger.Trace("Item: {0}'s release group is not wanted: {1}", subject, subject.ReleaseGroup);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue