(cherry picked from commit 33c7bd54b222c54ed7e505653793ddf962617d52)manual-intervention-notifications
parent
a3c33fe8cc
commit
e0ffb7d359
@ -0,0 +1,125 @@
|
||||
// using System.Collections.Generic;
|
||||
// using System.Linq;
|
||||
// using FizzWare.NBuilder;
|
||||
// using FluentAssertions;
|
||||
// using Moq;
|
||||
// using NUnit.Framework;
|
||||
// using NzbDrone.Common.Extensions;
|
||||
// using NzbDrone.Core.Download;
|
||||
// using NzbDrone.Core.History;
|
||||
// using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications;
|
||||
// using NzbDrone.Core.Music;
|
||||
// using NzbDrone.Core.Parser.Model;
|
||||
// using NzbDrone.Core.Test.Framework;
|
||||
// using NzbDrone.Test.Common;
|
||||
//
|
||||
// namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
|
||||
// {
|
||||
// [TestFixture]
|
||||
// public class MatchesGrabSpecificationFixture : CoreTest<MatchesGrabSpecification>
|
||||
// {
|
||||
// private Episode _episode1;
|
||||
// private Episode _episode2;
|
||||
// private Episode _episode3;
|
||||
// private LocalEpisode _localEpisode;
|
||||
// private DownloadClientItem _downloadClientItem;
|
||||
//
|
||||
// [SetUp]
|
||||
// public void Setup()
|
||||
// {
|
||||
// _episode1 = Builder<Episode>.CreateNew()
|
||||
// .With(e => e.Id = 1)
|
||||
// .Build();
|
||||
//
|
||||
// _episode2 = Builder<Episode>.CreateNew()
|
||||
// .With(e => e.Id = 2)
|
||||
// .Build();
|
||||
//
|
||||
// _episode3 = Builder<Episode>.CreateNew()
|
||||
// .With(e => e.Id = 3)
|
||||
// .Build();
|
||||
//
|
||||
// _localEpisode = Builder<LocalEpisode>.CreateNew()
|
||||
// .With(l => l.Path = @"C:\Test\Unsorted\Series.Title.S01E01.720p.HDTV-Sonarr\S01E05.mkv".AsOsAgnostic())
|
||||
// .With(l => l.Episodes = new List<Episode> { _episode1 })
|
||||
// .With(l => l.Release = null)
|
||||
// .Build();
|
||||
//
|
||||
// _downloadClientItem = Builder<DownloadClientItem>.CreateNew().Build();
|
||||
// }
|
||||
//
|
||||
// private void GivenHistoryForEpisodes(params Episode[] episodes)
|
||||
// {
|
||||
// if (episodes.Empty())
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// var grabbedHistories = Builder<EpisodeHistory>.CreateListOfSize(episodes.Length)
|
||||
// .All()
|
||||
// .With(h => h.EventType == EpisodeHistoryEventType.Grabbed)
|
||||
// .BuildList();
|
||||
//
|
||||
// for (var i = 0; i < grabbedHistories.Count; i++)
|
||||
// {
|
||||
// grabbedHistories[i].EpisodeId = episodes[i].Id;
|
||||
// }
|
||||
//
|
||||
// _localEpisode.Release = new GrabbedReleaseInfo(grabbedHistories);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void should_be_accepted_for_existing_file()
|
||||
// {
|
||||
// _localEpisode.ExistingFile = true;
|
||||
//
|
||||
// Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeTrue();
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void should_be_accepted_if_no_download_client_item()
|
||||
// {
|
||||
// Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeTrue();
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void should_be_accepted_if_no_grabbed_release_info()
|
||||
// {
|
||||
// GivenHistoryForEpisodes();
|
||||
//
|
||||
// Subject.IsSatisfiedBy(_localEpisode, _downloadClientItem).Accepted.Should().BeTrue();
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void should_be_accepted_if_file_episode_matches_single_grabbed_release_info()
|
||||
// {
|
||||
// GivenHistoryForEpisodes(_episode1);
|
||||
//
|
||||
// Subject.IsSatisfiedBy(_localEpisode, _downloadClientItem).Accepted.Should().BeTrue();
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void should_be_accepted_if_file_episode_is_in_multi_episode_grabbed_release_info()
|
||||
// {
|
||||
// GivenHistoryForEpisodes(_episode1, _episode2);
|
||||
//
|
||||
// Subject.IsSatisfiedBy(_localEpisode, _downloadClientItem).Accepted.Should().BeTrue();
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void should_be_rejected_if_file_episode_does_not_match_single_grabbed_release_info()
|
||||
// {
|
||||
// GivenHistoryForEpisodes(_episode2);
|
||||
//
|
||||
// Subject.IsSatisfiedBy(_localEpisode, _downloadClientItem).Accepted.Should().BeFalse();
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void should_be_rejected_if_file_episode_is_not_in_multi_episode_grabbed_release_info()
|
||||
// {
|
||||
// GivenHistoryForEpisodes(_episode2, _episode3);
|
||||
//
|
||||
// Subject.IsSatisfiedBy(_localEpisode, _downloadClientItem).Accepted.Should().BeFalse();
|
||||
// }
|
||||
// }
|
||||
// }
|
@ -0,0 +1,14 @@
|
||||
using FluentMigrator;
|
||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration
|
||||
{
|
||||
[Migration(067)]
|
||||
public class add_on_manual_interaction_required_to_notifications : NzbDroneMigrationBase
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Alter.Table("Notifications").AddColumn("OnManualInteractionRequired").AsBoolean().WithDefaultValue(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Download.TrackedDownloads;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.Download
|
||||
{
|
||||
public class ManualInteractionRequiredEvent : IEvent
|
||||
{
|
||||
public RemoteAlbum Album { get; private set; }
|
||||
public TrackedDownload TrackedDownload { get; private set; }
|
||||
public GrabbedReleaseInfo Release { get; private set; }
|
||||
|
||||
public ManualInteractionRequiredEvent(TrackedDownload trackedDownload, GrabbedReleaseInfo release)
|
||||
{
|
||||
TrackedDownload = trackedDownload;
|
||||
Album = trackedDownload.RemoteAlbum;
|
||||
Release = release;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.History;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators
|
||||
{
|
||||
// public class AggregateReleaseInfo : IAggregateLocalEpisode
|
||||
// {
|
||||
// private readonly IHistoryService _historyService;
|
||||
//
|
||||
// public AggregateReleaseInfo(IHistoryService historyService)
|
||||
// {
|
||||
// _historyService = historyService;
|
||||
// }
|
||||
//
|
||||
// public LocalTrack Aggregate(LocalTrack localTrack, DownloadClientItem downloadClientItem)
|
||||
// {
|
||||
// if (downloadClientItem == null)
|
||||
// {
|
||||
// return localTrack;
|
||||
// }
|
||||
//
|
||||
// var grabbedHistories = _historyService.FindByDownloadId(downloadClientItem.DownloadId)
|
||||
// .Where(h => h.EventType == TrackHistoryEventType.Grabbed)
|
||||
// .ToList();
|
||||
//
|
||||
// if (grabbedHistories.Empty())
|
||||
// {
|
||||
// return localTrack;
|
||||
// }
|
||||
//
|
||||
// localTrack.Release = new GrabbedReleaseInfo(grabbedHistories);
|
||||
//
|
||||
// return localTrack;
|
||||
// }
|
||||
// }
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using NzbDrone.Core.Download.TrackedDownloads;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
namespace NzbDrone.Core.Notifications
|
||||
{
|
||||
public class ManualInteractionRequiredMessage
|
||||
{
|
||||
public string Message { get; set; }
|
||||
public Artist Artist { get; set; }
|
||||
public RemoteAlbum RemoteAlbum { get; set; }
|
||||
public TrackedDownload TrackedDownload { get; set; }
|
||||
public QualityModel Quality { get; set; }
|
||||
public string DownloadClientType { get; set; }
|
||||
public string DownloadClientName { get; set; }
|
||||
public string DownloadId { get; set; }
|
||||
public GrabbedReleaseInfo Release { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Message;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Webhook
|
||||
{
|
||||
public class WebhookDownloadClientItem
|
||||
{
|
||||
public WebhookDownloadClientItem()
|
||||
{
|
||||
}
|
||||
|
||||
public WebhookDownloadClientItem(QualityModel quality, DownloadClientItem downloadClientItem)
|
||||
{
|
||||
Quality = quality.Quality.Name;
|
||||
QualityVersion = quality.Revision.Version;
|
||||
Title = downloadClientItem.Title;
|
||||
Size = downloadClientItem.TotalSize;
|
||||
}
|
||||
|
||||
public string Quality { get; set; }
|
||||
public int QualityVersion { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Indexer { get; set; }
|
||||
public long Size { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Webhook
|
||||
{
|
||||
public class WebhookManualInteractionPayload : WebhookPayload
|
||||
{
|
||||
public WebhookArtist Artist { get; set; }
|
||||
public List<WebhookAlbum> Albums { get; set; }
|
||||
public WebhookDownloadClientItem DownloadInfo { get; set; }
|
||||
public string DownloadClient { get; set; }
|
||||
public string DownloadClientType { get; set; }
|
||||
public string DownloadId { get; set; }
|
||||
|
||||
// public WebhookCustomFormatInfo CustomFormatInfo { get; set; }
|
||||
// public WebhookGrabbedRelease Release { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.History;
|
||||
|
||||
namespace NzbDrone.Core.Parser.Model
|
||||
{
|
||||
public class GrabbedReleaseInfo
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string Indexer { get; set; }
|
||||
public long Size { get; set; }
|
||||
|
||||
public List<int> AlbumsIds { get; set; }
|
||||
|
||||
public GrabbedReleaseInfo(List<EntityHistory> grabbedHistories)
|
||||
{
|
||||
var grabbedHistory = grabbedHistories.MaxBy(h => h.Date);
|
||||
var albumsIds = grabbedHistories.Select(h => h.AlbumId).Distinct().ToList();
|
||||
|
||||
grabbedHistory.Data.TryGetValue("indexer", out var indexer);
|
||||
grabbedHistory.Data.TryGetValue("size", out var sizeString);
|
||||
long.TryParse(sizeString, out var size);
|
||||
|
||||
Title = grabbedHistory.SourceTitle;
|
||||
Indexer = indexer;
|
||||
Size = size;
|
||||
AlbumsIds = albumsIds;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue