mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
Convert onGrab from passing a string to passing an object with series and episode information
Use object initalizer instead of creation of OnGrab/grabmessage
This commit is contained in:
parent
d41dd05d00
commit
d3b9ebf86c
@ -19,11 +19,11 @@ public override string Link
|
|||||||
get { return "https://boxcar.io/client"; }
|
get { return "https://boxcar.io/client"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGrab(string message)
|
public override void OnGrab(GrabMessage grabMessage)
|
||||||
{
|
{
|
||||||
const string title = "Episode Grabbed";
|
const string title = "Episode Grabbed";
|
||||||
|
|
||||||
_proxy.SendNotification(title, message, Settings);
|
_proxy.SendNotification(title, grabMessage.Message, Settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDownload(DownloadMessage message)
|
public override void OnDownload(DownloadMessage message)
|
||||||
|
@ -18,7 +18,7 @@ public override string Link
|
|||||||
get { return "https://github.com/Sonarr/Sonarr/wiki/Custom-Post-Processing-Scripts"; }
|
get { return "https://github.com/Sonarr/Sonarr/wiki/Custom-Post-Processing-Scripts"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGrab(string message)
|
public override void OnGrab(GrabMessage grabMessage)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,10 +20,10 @@ public override string Link
|
|||||||
get { return null; }
|
get { return null; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGrab(string message)
|
public override void OnGrab(GrabMessage grabMessage)
|
||||||
{
|
{
|
||||||
const string subject = "Sonarr [TV] - Grabbed";
|
const string subject = "Sonarr [TV] - Grabbed";
|
||||||
var body = String.Format("{0} sent to queue.", message);
|
var body = String.Format("{0} sent to queue.", grabMessage.Message);
|
||||||
|
|
||||||
_emailService.SendEmail(Settings, subject, body);
|
_emailService.SendEmail(Settings, subject, body);
|
||||||
}
|
}
|
||||||
|
22
src/NzbDrone.Core/Notifications/GrabMessage.cs
Normal file
22
src/NzbDrone.Core/Notifications/GrabMessage.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using NzbDrone.Core.MediaFiles;
|
||||||
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
|
using NzbDrone.Core.Tv;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Notifications
|
||||||
|
{
|
||||||
|
public class GrabMessage
|
||||||
|
{
|
||||||
|
public String Message { get; set; }
|
||||||
|
public Series Series { get; set; }
|
||||||
|
public RemoteEpisode Episode { get; set; }
|
||||||
|
public QualityModel Quality { get; set; }
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -19,11 +19,11 @@ public override string Link
|
|||||||
get { return "http://growl.info/"; }
|
get { return "http://growl.info/"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGrab(string message)
|
public override void OnGrab(GrabMessage grabMessage)
|
||||||
{
|
{
|
||||||
const string title = "Episode Grabbed";
|
const string title = "Episode Grabbed";
|
||||||
|
|
||||||
_growlService.SendNotification(title, message, "GRAB", Settings.Host, Settings.Port, Settings.Password);
|
_growlService.SendNotification(title, grabMessage.Message, "GRAB", Settings.Host, Settings.Port, Settings.Password);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDownload(DownloadMessage message)
|
public override void OnDownload(DownloadMessage message)
|
||||||
|
@ -7,7 +7,7 @@ public interface INotification : IProvider
|
|||||||
{
|
{
|
||||||
string Link { get; }
|
string Link { get; }
|
||||||
|
|
||||||
void OnGrab(string message);
|
void OnGrab(GrabMessage grabMessage);
|
||||||
void OnDownload(DownloadMessage message);
|
void OnDownload(DownloadMessage message);
|
||||||
void OnRename(Series series);
|
void OnRename(Series series);
|
||||||
bool SupportsOnGrab { get; }
|
bool SupportsOnGrab { get; }
|
||||||
|
@ -20,13 +20,13 @@ public override string Link
|
|||||||
get { return "http://mediabrowser.tv/"; }
|
get { return "http://mediabrowser.tv/"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGrab(String message)
|
public override void OnGrab(GrabMessage grabMessage)
|
||||||
{
|
{
|
||||||
const string title = "Sonarr - Grabbed";
|
const string title = "Sonarr - Grabbed";
|
||||||
|
|
||||||
if (Settings.Notify)
|
if (Settings.Notify)
|
||||||
{
|
{
|
||||||
_mediaBrowserService.Notify(Settings, title, message);
|
_mediaBrowserService.Notify(Settings, title, grabMessage.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public IEnumerable<ProviderDefinition> DefaultDefinitions
|
|||||||
|
|
||||||
public abstract string Link { get; }
|
public abstract string Link { get; }
|
||||||
|
|
||||||
public abstract void OnGrab(string message);
|
public abstract void OnGrab(GrabMessage grabMessage);
|
||||||
public abstract void OnDownload(DownloadMessage message);
|
public abstract void OnDownload(DownloadMessage message);
|
||||||
public abstract void OnRename(Series series);
|
public abstract void OnRename(Series series);
|
||||||
|
|
||||||
|
@ -90,14 +90,19 @@ private bool ShouldHandleSeries(ProviderDefinition definition, Series series)
|
|||||||
|
|
||||||
public void Handle(EpisodeGrabbedEvent message)
|
public void Handle(EpisodeGrabbedEvent message)
|
||||||
{
|
{
|
||||||
var messageBody = GetMessage(message.Episode.Series, message.Episode.Episodes, message.Episode.ParsedEpisodeInfo.Quality);
|
var grabMessage = new GrabMessage {
|
||||||
|
Message = GetMessage(message.Episode.Series, message.Episode.Episodes, message.Episode.ParsedEpisodeInfo.Quality),
|
||||||
|
Series = message.Episode.Series,
|
||||||
|
Quality = message.Episode.ParsedEpisodeInfo.Quality,
|
||||||
|
Episode = message.Episode
|
||||||
|
};
|
||||||
|
|
||||||
foreach (var notification in _notificationFactory.OnGrabEnabled())
|
foreach (var notification in _notificationFactory.OnGrabEnabled())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!ShouldHandleSeries(notification.Definition, message.Episode.Series)) continue;
|
if (!ShouldHandleSeries(notification.Definition, message.Episode.Series)) continue;
|
||||||
notification.OnGrab(messageBody);
|
notification.OnGrab(grabMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -20,11 +20,11 @@ public override string Link
|
|||||||
get { return "http://www.notifymyandroid.com/"; }
|
get { return "http://www.notifymyandroid.com/"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGrab(string message)
|
public override void OnGrab(GrabMessage grabMessage)
|
||||||
{
|
{
|
||||||
const string title = "Episode Grabbed";
|
const string title = "Episode Grabbed";
|
||||||
|
|
||||||
_proxy.SendNotification(title, message, Settings.ApiKey, (NotifyMyAndroidPriority)Settings.Priority);
|
_proxy.SendNotification(title, grabMessage.Message, Settings.ApiKey, (NotifyMyAndroidPriority)Settings.Priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDownload(DownloadMessage message)
|
public override void OnDownload(DownloadMessage message)
|
||||||
|
@ -19,10 +19,10 @@ public override string Link
|
|||||||
get { return "http://www.plexapp.com/"; }
|
get { return "http://www.plexapp.com/"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGrab(string message)
|
public override void OnGrab(GrabMessage grabMessage)
|
||||||
{
|
{
|
||||||
const string header = "Sonarr [TV] - Grabbed";
|
const string header = "Sonarr [TV] - Grabbed";
|
||||||
_plexClientService.Notify(Settings, header, message);
|
_plexClientService.Notify(Settings, header, grabMessage.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDownload(DownloadMessage message)
|
public override void OnDownload(DownloadMessage message)
|
||||||
|
@ -25,11 +25,11 @@ public override string Link
|
|||||||
get { return "https://plex.tv/"; }
|
get { return "https://plex.tv/"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGrab(string message)
|
public override void OnGrab(GrabMessage grabMessage)
|
||||||
{
|
{
|
||||||
const string header = "Sonarr - Grabbed";
|
const string header = "Sonarr - Grabbed";
|
||||||
|
|
||||||
Notify(Settings, header, message);
|
Notify(Settings, header, grabMessage.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDownload(DownloadMessage message)
|
public override void OnDownload(DownloadMessage message)
|
||||||
|
@ -19,7 +19,7 @@ public override string Link
|
|||||||
get { return "http://www.plexapp.com/"; }
|
get { return "http://www.plexapp.com/"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGrab(string message)
|
public override void OnGrab(GrabMessage grabMessage)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,11 +20,11 @@ public override string Link
|
|||||||
get { return "http://www.prowlapp.com/"; }
|
get { return "http://www.prowlapp.com/"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGrab(string message)
|
public override void OnGrab(GrabMessage grabMessage)
|
||||||
{
|
{
|
||||||
const string title = "Episode Grabbed";
|
const string title = "Episode Grabbed";
|
||||||
|
|
||||||
_prowlService.SendNotification(title, message, Settings.ApiKey, (NotificationPriority)Settings.Priority);
|
_prowlService.SendNotification(title, grabMessage.Message, Settings.ApiKey, (NotificationPriority)Settings.Priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDownload(DownloadMessage message)
|
public override void OnDownload(DownloadMessage message)
|
||||||
|
@ -19,11 +19,11 @@ public override string Link
|
|||||||
get { return "https://www.pushbullet.com/"; }
|
get { return "https://www.pushbullet.com/"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGrab(string message)
|
public override void OnGrab(GrabMessage grabMessage)
|
||||||
{
|
{
|
||||||
const string title = "Sonarr - Episode Grabbed";
|
const string title = "Sonarr - Episode Grabbed";
|
||||||
|
|
||||||
_proxy.SendNotification(title, message, Settings);
|
_proxy.SendNotification(title, grabMessage.Message, Settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDownload(DownloadMessage message)
|
public override void OnDownload(DownloadMessage message)
|
||||||
|
@ -20,11 +20,11 @@ public override string Link
|
|||||||
get { return "https://www.Pushalot.com/"; }
|
get { return "https://www.Pushalot.com/"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGrab(String message)
|
public override void OnGrab(GrabMessage grabMessage)
|
||||||
{
|
{
|
||||||
const string title = "Episode Grabbed";
|
const string title = "Episode Grabbed";
|
||||||
|
|
||||||
_proxy.SendNotification(title, message, Settings);
|
_proxy.SendNotification(title, grabMessage.Message, Settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDownload(DownloadMessage message)
|
public override void OnDownload(DownloadMessage message)
|
||||||
|
@ -19,11 +19,11 @@ public override string Link
|
|||||||
get { return "https://pushover.net/"; }
|
get { return "https://pushover.net/"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGrab(string message)
|
public override void OnGrab(GrabMessage grabMessage)
|
||||||
{
|
{
|
||||||
const string title = "Episode Grabbed";
|
const string title = "Episode Grabbed";
|
||||||
|
|
||||||
_proxy.SendNotification(title, message, Settings.ApiKey, Settings.UserKey, (PushoverPriority)Settings.Priority, Settings.Sound);
|
_proxy.SendNotification(title, grabMessage.Message, Settings.ApiKey, Settings.UserKey, (PushoverPriority)Settings.Priority, Settings.Sound);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDownload(DownloadMessage message)
|
public override void OnDownload(DownloadMessage message)
|
||||||
|
@ -21,7 +21,7 @@ public override string Link
|
|||||||
get { return "http://www.synology.com"; }
|
get { return "http://www.synology.com"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGrab(string message)
|
public override void OnGrab(GrabMessage grabMessage)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,9 @@ public override string Link
|
|||||||
get { return "https://twitter.com/"; }
|
get { return "https://twitter.com/"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGrab(string message)
|
public override void OnGrab(GrabMessage grabMessage)
|
||||||
{
|
{
|
||||||
_twitterService.SendNotification(message, Settings);
|
_twitterService.SendNotification(grabMessage.Message, Settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDownload(DownloadMessage message)
|
public override void OnDownload(DownloadMessage message)
|
||||||
|
@ -25,11 +25,11 @@ public override string Link
|
|||||||
get { return "http://xbmc.org/"; }
|
get { return "http://xbmc.org/"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGrab(string message)
|
public override void OnGrab(GrabMessage grabMessage)
|
||||||
{
|
{
|
||||||
const string header = "Sonarr - Grabbed";
|
const string header = "Sonarr - Grabbed";
|
||||||
|
|
||||||
Notify(Settings, header, message);
|
Notify(Settings, header, grabMessage.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDownload(DownloadMessage message)
|
public override void OnDownload(DownloadMessage message)
|
||||||
|
@ -728,6 +728,7 @@
|
|||||||
<Compile Include="Notifications\Boxcar\BoxcarException.cs" />
|
<Compile Include="Notifications\Boxcar\BoxcarException.cs" />
|
||||||
<Compile Include="Notifications\Boxcar\BoxcarProxy.cs" />
|
<Compile Include="Notifications\Boxcar\BoxcarProxy.cs" />
|
||||||
<Compile Include="Notifications\Boxcar\BoxcarSettings.cs" />
|
<Compile Include="Notifications\Boxcar\BoxcarSettings.cs" />
|
||||||
|
<Compile Include="Notifications\GrabMessage.cs" />
|
||||||
<Compile Include="Notifications\Plex\Models\PlexIdentity.cs" />
|
<Compile Include="Notifications\Plex\Models\PlexIdentity.cs" />
|
||||||
<Compile Include="Notifications\Plex\Models\PlexPreferences.cs" />
|
<Compile Include="Notifications\Plex\Models\PlexPreferences.cs" />
|
||||||
<Compile Include="Notifications\Plex\Models\PlexSectionItem.cs" />
|
<Compile Include="Notifications\Plex\Models\PlexSectionItem.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user