mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Better notification messages
This commit is contained in:
parent
125deb3931
commit
eaa7b39025
@ -102,6 +102,13 @@ public void should_try_other_notifiers_when_one_fails()
|
||||
.With(p => p.EpisodeNumbers = new int[] {1})
|
||||
.Build();
|
||||
|
||||
var localEpisode = Builder<LocalEpisode>.CreateNew()
|
||||
.With(e => e.Series = series)
|
||||
.With(e => e.ParsedEpisodeInfo = parsedEpisodeInfo)
|
||||
.With(e => e.Episodes = Builder<Episode>.CreateListOfSize(1)
|
||||
.Build().ToList())
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<INotificationRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(notifications);
|
||||
@ -111,7 +118,7 @@ public void should_try_other_notifiers_when_one_fails()
|
||||
.Setup(s => s.OnDownload(It.IsAny<string>(), series))
|
||||
.Throws(new SocketException());
|
||||
|
||||
Subject.Handle(new EpisodeDownloadedEvent(parsedEpisodeInfo, series));
|
||||
Subject.Handle(new EpisodeDownloadedEvent(localEpisode));
|
||||
|
||||
Mocker.GetMock<Notifications.Xbmc.Xbmc>()
|
||||
.Verify(v => v.OnDownload(It.IsAny<string>(), series), Times.Once());
|
||||
|
@ -77,7 +77,7 @@ public EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, LocalEpisode localEp
|
||||
var destinationFilename = _buildFileNames.BuildFilePath(localEpisode.Series, localEpisode.SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
|
||||
episodeFile = MoveFile(episodeFile, destinationFilename);
|
||||
|
||||
_messageAggregator.PublishEvent(new EpisodeDownloadedEvent(localEpisode.ParsedEpisodeInfo, localEpisode.Series));
|
||||
_messageAggregator.PublishEvent(new EpisodeDownloadedEvent(localEpisode));
|
||||
|
||||
return episodeFile;
|
||||
}
|
||||
|
@ -6,13 +6,11 @@ namespace NzbDrone.Core.MediaFiles.Events
|
||||
{
|
||||
public class EpisodeDownloadedEvent : IEvent
|
||||
{
|
||||
public ParsedEpisodeInfo ParsedEpisodeInfo { get; private set; }
|
||||
public Series Series { get; set; }
|
||||
public LocalEpisode Episode { get; private set; }
|
||||
|
||||
public EpisodeDownloadedEvent(ParsedEpisodeInfo parsedEpisodeInfo, Series series)
|
||||
public EpisodeDownloadedEvent(LocalEpisode episode)
|
||||
{
|
||||
ParsedEpisodeInfo = parsedEpisodeInfo;
|
||||
Series = series;
|
||||
Episode = episode;
|
||||
}
|
||||
}
|
||||
}
|
@ -135,24 +135,35 @@ private INotification GetInstance(NotificationDefinition indexerDefinition)
|
||||
return instance;
|
||||
}
|
||||
|
||||
private string GetMessage(ParsedEpisodeInfo parsedEpisodeInfo, Series series)
|
||||
private string GetMessage(Series series, List<Episode> episodes, QualityModel quality)
|
||||
{
|
||||
if (series.SeriesType == SeriesTypes.Daily)
|
||||
{
|
||||
return String.Format("{0} - {1}",
|
||||
var episode = episodes.First();
|
||||
|
||||
return String.Format("{0} - {1} - {2} [{3}]",
|
||||
series.Title,
|
||||
parsedEpisodeInfo.AirDate.Value.ToString(Episode.AIR_DATE_FORMAT));
|
||||
episode.AirDate,
|
||||
episode.Title,
|
||||
quality);
|
||||
}
|
||||
|
||||
return String.Format("{0} - {1}{2}",
|
||||
var episodeNumbers = String.Concat(episodes.Select(e => e.EpisodeNumber)
|
||||
.Select(i => String.Format("x{0:00}", i)));
|
||||
|
||||
var episodeTitles = String.Join(" + ", episodes.Select(e => e.Title));
|
||||
|
||||
return String.Format("{0} - {1}{2} - {3} {4}",
|
||||
series.Title,
|
||||
parsedEpisodeInfo.SeasonNumber,
|
||||
String.Concat(parsedEpisodeInfo.EpisodeNumbers.Select(i => String.Format("x{0:00}", i))));
|
||||
episodes.First().SeasonNumber,
|
||||
episodeNumbers,
|
||||
episodeTitles,
|
||||
quality);
|
||||
}
|
||||
|
||||
public void Handle(EpisodeGrabbedEvent message)
|
||||
{
|
||||
var messageBody = GetMessage(message.Episode.ParsedEpisodeInfo, message.Episode.Series);
|
||||
var messageBody = GetMessage(message.Episode.Series, message.Episode.Episodes, message.Episode.ParsedEpisodeInfo.Quality);
|
||||
|
||||
foreach (var notification in All().Where(n => n.OnGrab))
|
||||
{
|
||||
@ -170,13 +181,13 @@ public void Handle(EpisodeGrabbedEvent message)
|
||||
|
||||
public void Handle(EpisodeDownloadedEvent message)
|
||||
{
|
||||
var messageBody = GetMessage(message.ParsedEpisodeInfo, message.Series);
|
||||
var messageBody = GetMessage(message.Episode.Series, message.Episode.Episodes, message.Episode.ParsedEpisodeInfo.Quality);
|
||||
|
||||
foreach (var notification in All().Where(n => n.OnDownload))
|
||||
{
|
||||
try
|
||||
{
|
||||
notification.Instance.OnDownload(messageBody, message.Series);
|
||||
notification.Instance.OnDownload(messageBody, message.Episode.Series);
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
|
Loading…
Reference in New Issue
Block a user