mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Tags
New: Ability to tag series New: Use tags to control which series use which notification channels
This commit is contained in:
@@ -2,10 +2,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.MediaFiles.Events;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Notifications
|
||||
@@ -65,6 +67,27 @@ namespace NzbDrone.Core.Notifications
|
||||
qualityString);
|
||||
}
|
||||
|
||||
private bool ShouldHandleSeries(ProviderDefinition definition, Series series)
|
||||
{
|
||||
var notificationDefinition = (NotificationDefinition) definition;
|
||||
|
||||
if (notificationDefinition.Tags.Empty())
|
||||
{
|
||||
_logger.Debug("No tags set for this notification.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (notificationDefinition.Tags.Intersect(series.Tags).Any())
|
||||
{
|
||||
_logger.Debug("Notification and series have one or more matching tags.");
|
||||
return true;
|
||||
}
|
||||
|
||||
//TODO: this message could be more clear
|
||||
_logger.Debug("{0} does not have any tags that match {1}'s tags", notificationDefinition.Name, series.Title);
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Handle(EpisodeGrabbedEvent message)
|
||||
{
|
||||
var messageBody = GetMessage(message.Episode.Series, message.Episode.Episodes, message.Episode.ParsedEpisodeInfo.Quality);
|
||||
@@ -73,6 +96,7 @@ namespace NzbDrone.Core.Notifications
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ShouldHandleSeries(notification.Definition, message.Episode.Series)) continue;
|
||||
notification.OnGrab(messageBody);
|
||||
}
|
||||
|
||||
@@ -95,12 +119,13 @@ namespace NzbDrone.Core.Notifications
|
||||
{
|
||||
try
|
||||
{
|
||||
if (downloadMessage.OldFiles.Any() && !((NotificationDefinition) notification.Definition).OnUpgrade)
|
||||
if (ShouldHandleSeries(notification.Definition, message.Episode.Series))
|
||||
{
|
||||
continue;
|
||||
if (downloadMessage.OldFiles.Empty() || ((NotificationDefinition)notification.Definition).OnUpgrade)
|
||||
{
|
||||
notification.OnDownload(downloadMessage);
|
||||
}
|
||||
}
|
||||
|
||||
notification.OnDownload(downloadMessage);
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
@@ -116,7 +141,10 @@ namespace NzbDrone.Core.Notifications
|
||||
{
|
||||
try
|
||||
{
|
||||
notification.AfterRename(message.Series);
|
||||
if (ShouldHandleSeries(notification.Definition, message.Series))
|
||||
{
|
||||
notification.AfterRename(message.Series);
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
|
Reference in New Issue
Block a user