mirror of https://github.com/lidarr/Lidarr
Initial Notification Support, XBMC and PLEX still need work.
This commit is contained in:
parent
56e8f5c730
commit
864549b1f3
|
@ -1,10 +1,10 @@
|
|||
using System;
|
||||
using System;
|
||||
using FluentAssertions;
|
||||
using FluentValidation.Results;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Notifications;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Validation;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
|
@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.NotificationTests
|
|||
TestLogger.Info("OnDownload was called");
|
||||
}
|
||||
|
||||
public override void OnRename(Series series)
|
||||
public override void OnRename(Artist artist)
|
||||
{
|
||||
TestLogger.Info("OnRename was called");
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Notifications;
|
||||
using NzbDrone.Core.Notifications.Synology;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.NotificationTests
|
||||
|
@ -13,33 +13,33 @@ namespace NzbDrone.Core.Test.NotificationTests
|
|||
[TestFixture]
|
||||
public class SynologyIndexerFixture : CoreTest<SynologyIndexer>
|
||||
{
|
||||
private Series _series;
|
||||
private Artist _artist;
|
||||
private DownloadMessage _upgrade;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_series = new Series()
|
||||
_artist = new Artist()
|
||||
{
|
||||
Path = @"C:\Test\".AsOsAgnostic()
|
||||
};
|
||||
|
||||
_upgrade = new DownloadMessage()
|
||||
{
|
||||
Series = _series,
|
||||
Artist = _artist,
|
||||
|
||||
EpisodeFile = new EpisodeFile
|
||||
TrackFile = new TrackFile
|
||||
{
|
||||
RelativePath = "file1.S01E01E02.mkv"
|
||||
},
|
||||
|
||||
OldFiles = new List<EpisodeFile>
|
||||
OldFiles = new List<TrackFile>
|
||||
{
|
||||
new EpisodeFile
|
||||
new TrackFile
|
||||
{
|
||||
RelativePath = "file1.S01E01.mkv"
|
||||
},
|
||||
new EpisodeFile
|
||||
new TrackFile
|
||||
{
|
||||
RelativePath = "file1.S01E02.mkv"
|
||||
}
|
||||
|
@ -60,10 +60,10 @@ namespace NzbDrone.Core.Test.NotificationTests
|
|||
{
|
||||
(Subject.Definition.Settings as SynologyIndexerSettings).UpdateLibrary = false;
|
||||
|
||||
Subject.OnRename(_series);
|
||||
Subject.OnRename(_artist);
|
||||
|
||||
Mocker.GetMock<ISynologyIndexerProxy>()
|
||||
.Verify(v => v.UpdateFolder(_series.Path), Times.Never());
|
||||
.Verify(v => v.UpdateFolder(_artist.Path), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -90,7 +90,7 @@ namespace NzbDrone.Core.Test.NotificationTests
|
|||
[Test]
|
||||
public void should_update_entire_series_folder_on_rename()
|
||||
{
|
||||
Subject.OnRename(_series);
|
||||
Subject.OnRename(_artist);
|
||||
|
||||
Mocker.GetMock<ISynologyIndexerProxy>()
|
||||
.Verify(v => v.UpdateFolder(@"C:\Test\".AsOsAgnostic()), Times.Once());
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
using FluentAssertions;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Notifications.Xbmc;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http
|
|||
public class GetSeriesPathFixture : CoreTest<HttpApiProvider>
|
||||
{
|
||||
private XbmcSettings _settings;
|
||||
private Series _series;
|
||||
private Artist _artist;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
|
@ -27,10 +27,10 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http
|
|||
UpdateLibrary = true
|
||||
};
|
||||
|
||||
_series = new Series
|
||||
_artist = new Artist
|
||||
{
|
||||
TvdbId = 79488,
|
||||
Title = "30 Rock"
|
||||
ForeignArtistId = "123d45d-d154f5d-1f5d1-5df18d5",
|
||||
Name = "30 Rock"
|
||||
};
|
||||
|
||||
const string setResponseUrl = "http://localhost:8080/xbmcCmds/xbmcHttp?command=SetResponseFormat(webheader;false;webfooter;false;header;<xml>;footer;</xml>;opentag;<tag>;closetag;</tag>;closefinaltag;false)";
|
||||
|
@ -57,7 +57,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http
|
|||
.Setup(s => s.DownloadString(query, _settings.Username, _settings.Password))
|
||||
.Returns(queryResult);
|
||||
|
||||
Subject.GetSeriesPath(_settings, _series)
|
||||
Subject.GetSeriesPath(_settings, _artist)
|
||||
.Should().Be("smb://xbmc:xbmc@HOMESERVER/TV/30 Rock/");
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http
|
|||
.Returns(queryResult);
|
||||
|
||||
|
||||
Subject.GetSeriesPath(_settings, _series)
|
||||
Subject.GetSeriesPath(_settings, _artist)
|
||||
.Should().BeNull();
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http
|
|||
.Returns(queryResult);
|
||||
|
||||
|
||||
Subject.GetSeriesPath(_settings, _series)
|
||||
Subject.GetSeriesPath(_settings, _artist)
|
||||
.Should().Be("smb://xbmc:xbmc@HOMESERVER/TV/Law & Order- Special Victims Unit/");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
using FizzWare.NBuilder;
|
||||
using FizzWare.NBuilder;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Notifications.Xbmc;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http
|
|||
{
|
||||
private XbmcSettings _settings;
|
||||
private string _seriesQueryUrl = "http://localhost:8080/xbmcCmds/xbmcHttp?command=QueryVideoDatabase(select path.strPath from path, tvshow, tvshowlinkpath where tvshow.c12 = 79488 and tvshowlinkpath.idShow = tvshow.idShow and tvshowlinkpath.idPath = path.idPath)";
|
||||
private Series _fakeSeries;
|
||||
private Artist _fakeSeries;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
|
@ -28,9 +28,9 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http
|
|||
UpdateLibrary = true
|
||||
};
|
||||
|
||||
_fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(s => s.TvdbId = 79488)
|
||||
.With(s => s.Title = "30 Rock")
|
||||
_fakeSeries = Builder<Artist>.CreateNew()
|
||||
.With(s => s.ForeignArtistId = "79488")
|
||||
.With(s => s.Name = "30 Rock")
|
||||
.Build();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
|
@ -6,16 +6,16 @@ using NUnit.Framework;
|
|||
using NzbDrone.Core.Notifications.Xbmc;
|
||||
using NzbDrone.Core.Notifications.Xbmc.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
||||
{
|
||||
[TestFixture]
|
||||
public class GetSeriesPathFixture : CoreTest<JsonApiProvider>
|
||||
{
|
||||
private const int TVDB_ID = 5;
|
||||
private const string MB_ID = "5";
|
||||
private XbmcSettings _settings;
|
||||
private Series _series;
|
||||
private Artist _artist;
|
||||
private List<TvShow> _xbmcSeries;
|
||||
|
||||
[SetUp]
|
||||
|
@ -28,39 +28,39 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|||
.All()
|
||||
.With(s => s.ImdbNumber = "0")
|
||||
.TheFirst(1)
|
||||
.With(s => s.ImdbNumber = TVDB_ID.ToString())
|
||||
.With(s => s.ImdbNumber = MB_ID.ToString())
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
Mocker.GetMock<IXbmcJsonApiProxy>()
|
||||
.Setup(s => s.GetSeries(_settings))
|
||||
.Setup(s => s.GetArtist(_settings))
|
||||
.Returns(_xbmcSeries);
|
||||
}
|
||||
|
||||
private void GivenMatchingTvdbId()
|
||||
{
|
||||
_series = new Series
|
||||
{
|
||||
TvdbId = TVDB_ID,
|
||||
Title = "TV Show"
|
||||
_artist = new Artist
|
||||
{
|
||||
ForeignArtistId = MB_ID,
|
||||
Name = "TV Show"
|
||||
};
|
||||
}
|
||||
|
||||
private void GivenMatchingTitle()
|
||||
{
|
||||
_series = new Series
|
||||
_artist = new Artist
|
||||
{
|
||||
TvdbId = 1000,
|
||||
Title = _xbmcSeries.First().Label
|
||||
ForeignArtistId = "1000",
|
||||
Name = _xbmcSeries.First().Label
|
||||
};
|
||||
}
|
||||
|
||||
private void GivenMatchingSeries()
|
||||
{
|
||||
_series = new Series
|
||||
_artist = new Artist
|
||||
{
|
||||
TvdbId = 1000,
|
||||
Title = "Does not exist"
|
||||
ForeignArtistId = "1000",
|
||||
Name = "Does not exist"
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|||
{
|
||||
GivenMatchingSeries();
|
||||
|
||||
Subject.GetSeriesPath(_settings, _series).Should().BeNull();
|
||||
Subject.GetSeriesPath(_settings, _artist).Should().BeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -77,7 +77,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|||
{
|
||||
GivenMatchingTvdbId();
|
||||
|
||||
Subject.GetSeriesPath(_settings, _series).Should().Be(_xbmcSeries.First().File);
|
||||
Subject.GetSeriesPath(_settings, _artist).Should().Be(_xbmcSeries.First().File);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -85,7 +85,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|||
{
|
||||
GivenMatchingTitle();
|
||||
|
||||
Subject.GetSeriesPath(_settings, _series).Should().Be(_xbmcSeries.First().File);
|
||||
Subject.GetSeriesPath(_settings, _artist).Should().Be(_xbmcSeries.First().File);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -94,13 +94,13 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|||
GivenMatchingTvdbId();
|
||||
|
||||
_xbmcSeries.ForEach(s => s.ImdbNumber = "tt12345");
|
||||
_xbmcSeries.Last().ImdbNumber = TVDB_ID.ToString();
|
||||
_xbmcSeries.Last().ImdbNumber = MB_ID.ToString();
|
||||
|
||||
Mocker.GetMock<IXbmcJsonApiProxy>()
|
||||
.Setup(s => s.GetSeries(_settings))
|
||||
.Setup(s => s.GetArtist(_settings))
|
||||
.Returns(_xbmcSeries);
|
||||
|
||||
Subject.GetSeriesPath(_settings, _series).Should().NotBeNull();
|
||||
Subject.GetSeriesPath(_settings, _artist).Should().NotBeNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
|
@ -6,16 +6,16 @@ using NUnit.Framework;
|
|||
using NzbDrone.Core.Notifications.Xbmc;
|
||||
using NzbDrone.Core.Notifications.Xbmc.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
||||
{
|
||||
[TestFixture]
|
||||
public class UpdateFixture : CoreTest<JsonApiProvider>
|
||||
{
|
||||
private const int TVDB_ID = 5;
|
||||
private const string MB_ID = "5";
|
||||
private XbmcSettings _settings;
|
||||
private List<TvShow> _xbmcSeries;
|
||||
private List<TvShow> _xbmcArtist;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
|
@ -23,15 +23,15 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|||
_settings = Builder<XbmcSettings>.CreateNew()
|
||||
.Build();
|
||||
|
||||
_xbmcSeries = Builder<TvShow>.CreateListOfSize(3)
|
||||
_xbmcArtist = Builder<TvShow>.CreateListOfSize(3)
|
||||
.TheFirst(1)
|
||||
.With(s => s.ImdbNumber = TVDB_ID.ToString())
|
||||
.With(s => s.ImdbNumber = MB_ID.ToString())
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
Mocker.GetMock<IXbmcJsonApiProxy>()
|
||||
.Setup(s => s.GetSeries(_settings))
|
||||
.Returns(_xbmcSeries);
|
||||
.Setup(s => s.GetArtist(_settings))
|
||||
.Returns(_xbmcArtist);
|
||||
|
||||
Mocker.GetMock<IXbmcJsonApiProxy>()
|
||||
.Setup(s => s.GetActivePlayers(_settings))
|
||||
|
@ -41,8 +41,8 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|||
[Test]
|
||||
public void should_update_using_series_path()
|
||||
{
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(s => s.TvdbId = TVDB_ID)
|
||||
var series = Builder<Artist>.CreateNew()
|
||||
.With(s => s.ForeignArtistId = MB_ID)
|
||||
.Build();
|
||||
|
||||
Subject.Update(_settings, series);
|
||||
|
@ -54,9 +54,9 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
|
|||
[Test]
|
||||
public void should_update_all_paths_when_series_path_not_found()
|
||||
{
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(s => s.TvdbId = 1000)
|
||||
.With(s => s.Title = "Not 30 Rock")
|
||||
var fakeSeries = Builder<Artist>.CreateNew()
|
||||
.With(s => s.ForeignArtistId = "1000")
|
||||
.With(s => s.Name = "Not 30 Rock")
|
||||
.Build();
|
||||
|
||||
Subject.Update(_settings, fakeSeries);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
|
@ -7,7 +7,7 @@ using NzbDrone.Core.MediaFiles;
|
|||
using NzbDrone.Core.Notifications;
|
||||
using NzbDrone.Core.Notifications.Xbmc;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Test.NotificationTests.Xbmc
|
||||
{
|
||||
|
@ -19,16 +19,16 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc
|
|||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var series = Builder<Series>.CreateNew()
|
||||
var artist = Builder<Artist>.CreateNew()
|
||||
.Build();
|
||||
|
||||
var episodeFile = Builder<EpisodeFile>.CreateNew()
|
||||
var trackFile = Builder<TrackFile>.CreateNew()
|
||||
.Build();
|
||||
|
||||
_downloadMessage = Builder<DownloadMessage>.CreateNew()
|
||||
.With(d => d.Series = series)
|
||||
.With(d => d.EpisodeFile = episodeFile)
|
||||
.With(d => d.OldFiles = new List<EpisodeFile>())
|
||||
.With(d => d.Artist = artist)
|
||||
.With(d => d.TrackFile = trackFile)
|
||||
.With(d => d.OldFiles = new List<TrackFile>())
|
||||
.Build();
|
||||
|
||||
Subject.Definition = new NotificationDefinition();
|
||||
|
@ -40,7 +40,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc
|
|||
|
||||
private void GivenOldFiles()
|
||||
{
|
||||
_downloadMessage.OldFiles = Builder<EpisodeFile>.CreateListOfSize(1)
|
||||
_downloadMessage.OldFiles = Builder<TrackFile>.CreateListOfSize(1)
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
|
|
|
@ -18,12 +18,12 @@ namespace NzbDrone.Core.Notifications.Boxcar
|
|||
|
||||
public override void OnGrab(GrabMessage grabMessage)
|
||||
{
|
||||
_proxy.SendNotification(EPISODE_GRABBED_TITLE, grabMessage.Message, Settings);
|
||||
_proxy.SendNotification(ALBUM_GRABBED_TITLE, grabMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
{
|
||||
_proxy.SendNotification(EPISODE_DOWNLOADED_TITLE , message.Message, Settings);
|
||||
_proxy.SendNotification(TRACK_DOWNLOADED_TITLE , message.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
|
|
|
@ -6,7 +6,7 @@ using FluentValidation.Results;
|
|||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Processes;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.CustomScript
|
||||
|
@ -30,27 +30,24 @@ namespace NzbDrone.Core.Notifications.CustomScript
|
|||
|
||||
public override void OnGrab(GrabMessage message)
|
||||
{
|
||||
var series = message.Series;
|
||||
var remoteEpisode = message.Episode;
|
||||
var releaseGroup = remoteEpisode.ParsedEpisodeInfo.ReleaseGroup;
|
||||
var artist = message.Artist;
|
||||
var remoteAlbum = message.Album;
|
||||
var releaseGroup = remoteAlbum.ParsedAlbumInfo.ReleaseGroup;
|
||||
var environmentVariables = new StringDictionary();
|
||||
|
||||
environmentVariables.Add("Lidarr_EventType", "Grab");
|
||||
environmentVariables.Add("Lidarr_Series_Id", series.Id.ToString());
|
||||
environmentVariables.Add("Lidarr_Series_Title", series.Title);
|
||||
environmentVariables.Add("Lidarr_Series_TvdbId", series.TvdbId.ToString());
|
||||
environmentVariables.Add("Lidarr_Series_Type", series.SeriesType.ToString());
|
||||
environmentVariables.Add("Lidarr_Release_EpisodeCount", remoteEpisode.Episodes.Count.ToString());
|
||||
environmentVariables.Add("Lidarr_Release_SeasonNumber", remoteEpisode.ParsedEpisodeInfo.SeasonNumber.ToString());
|
||||
environmentVariables.Add("Lidarr_Release_EpisodeNumbers", string.Join(",", remoteEpisode.Episodes.Select(e => e.EpisodeNumber)));
|
||||
environmentVariables.Add("Lidarr_Release_EpisodeAirDates", string.Join(",", remoteEpisode.Episodes.Select(e => e.AirDate)));
|
||||
environmentVariables.Add("Lidarr_Release_EpisodeAirDatesUtc", string.Join(",", remoteEpisode.Episodes.Select(e => e.AirDateUtc)));
|
||||
environmentVariables.Add("Lidarr_Release_EpisodeTitles", string.Join("|", remoteEpisode.Episodes.Select(e => e.Title)));
|
||||
environmentVariables.Add("Lidarr_Release_Title", remoteEpisode.Release.Title);
|
||||
environmentVariables.Add("Lidarr_Release_Indexer", remoteEpisode.Release.Indexer);
|
||||
environmentVariables.Add("Lidarr_Release_Size", remoteEpisode.Release.Size.ToString());
|
||||
environmentVariables.Add("Lidarr_Release_Quality", remoteEpisode.ParsedEpisodeInfo.Quality.Quality.Name);
|
||||
environmentVariables.Add("Lidarr_Release_QualityVersion", remoteEpisode.ParsedEpisodeInfo.Quality.Revision.Version.ToString());
|
||||
environmentVariables.Add("Lidarr_Artist_Id", artist.Id.ToString());
|
||||
environmentVariables.Add("Lidarr_Artist_Name", artist.Name);
|
||||
environmentVariables.Add("Lidarr_Artist_MBId", artist.ForeignArtistId.ToString());
|
||||
//environmentVariables.Add("Lidarr_Artist_Type", artist.SeriesType.ToString());
|
||||
environmentVariables.Add("Lidarr_Release_AlbumCount", remoteAlbum.Albums.Count.ToString());
|
||||
environmentVariables.Add("Lidarr_Release_AlbumReleaseDates", string.Join(",", remoteAlbum.Albums.Select(e => e.ReleaseDate)));
|
||||
environmentVariables.Add("Lidarr_Release_AlbumTitles", string.Join("|", remoteAlbum.Albums.Select(e => e.Title)));
|
||||
environmentVariables.Add("Lidarr_Release_Title", remoteAlbum.Release.Title);
|
||||
environmentVariables.Add("Lidarr_Release_Indexer", remoteAlbum.Release.Indexer);
|
||||
environmentVariables.Add("Lidarr_Release_Size", remoteAlbum.Release.Size.ToString());
|
||||
environmentVariables.Add("Lidarr_Release_Quality", remoteAlbum.ParsedAlbumInfo.Quality.Quality.Name);
|
||||
environmentVariables.Add("Lidarr_Release_QualityVersion", remoteAlbum.ParsedAlbumInfo.Quality.Revision.Version.ToString());
|
||||
environmentVariables.Add("Lidarr_Release_ReleaseGroup", releaseGroup);
|
||||
|
||||
ExecuteScript(environmentVariables);
|
||||
|
@ -58,53 +55,51 @@ namespace NzbDrone.Core.Notifications.CustomScript
|
|||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
{
|
||||
var series = message.Series;
|
||||
var episodeFile = message.EpisodeFile;
|
||||
var artist = message.Artist;
|
||||
var trackFile = message.TrackFile;
|
||||
var sourcePath = message.SourcePath;
|
||||
var environmentVariables = new StringDictionary();
|
||||
|
||||
environmentVariables.Add("Lidarr_EventType", "Download");
|
||||
environmentVariables.Add("LIdarr_IsUpgrade", message.OldFiles.Any().ToString());
|
||||
environmentVariables.Add("Lidarr_Series_Id", series.Id.ToString());
|
||||
environmentVariables.Add("Lidarr_Series_Title", series.Title);
|
||||
environmentVariables.Add("Lidarr_Series_Path", series.Path);
|
||||
environmentVariables.Add("Lidarr_Series_TvdbId", series.TvdbId.ToString());
|
||||
environmentVariables.Add("Lidarr_Series_Type", series.SeriesType.ToString());
|
||||
environmentVariables.Add("Lidarr_EpisodeFile_Id", episodeFile.Id.ToString());
|
||||
environmentVariables.Add("Lidarr_EpisodeFile_EpisodeCount", episodeFile.Episodes.Value.Count.ToString());
|
||||
environmentVariables.Add("Lidarr_EpisodeFile_RelativePath", episodeFile.RelativePath);
|
||||
environmentVariables.Add("Lidarr_EpisodeFile_Path", Path.Combine(series.Path, episodeFile.RelativePath));
|
||||
environmentVariables.Add("Lidarr_EpisodeFile_SeasonNumber", episodeFile.SeasonNumber.ToString());
|
||||
environmentVariables.Add("Lidarr_EpisodeFile_EpisodeNumbers", string.Join(",", episodeFile.Episodes.Value.Select(e => e.EpisodeNumber)));
|
||||
environmentVariables.Add("Lidarr_EpisodeFile_EpisodeAirDates", string.Join(",", episodeFile.Episodes.Value.Select(e => e.AirDate)));
|
||||
environmentVariables.Add("Lidarr_EpisodeFile_EpisodeAirDatesUtc", string.Join(",", episodeFile.Episodes.Value.Select(e => e.AirDateUtc)));
|
||||
environmentVariables.Add("Lidarr_EpisodeFile_EpisodeTitles", string.Join("|", episodeFile.Episodes.Value.Select(e => e.Title)));
|
||||
environmentVariables.Add("Lidarr_EpisodeFile_Quality", episodeFile.Quality.Quality.Name);
|
||||
environmentVariables.Add("Lidarr_EpisodeFile_QualityVersion", episodeFile.Quality.Revision.Version.ToString());
|
||||
environmentVariables.Add("Lidarr_EpisodeFile_ReleaseGroup", episodeFile.ReleaseGroup ?? string.Empty);
|
||||
environmentVariables.Add("Lidarr_EpisodeFile_SceneName", episodeFile.SceneName ?? string.Empty);
|
||||
environmentVariables.Add("Lidarr_EpisodeFile_SourcePath", sourcePath);
|
||||
environmentVariables.Add("Lidarr_EpisodeFile_SourceFolder", Path.GetDirectoryName(sourcePath));
|
||||
environmentVariables.Add("Lidarr_Artist_Id", artist.Id.ToString());
|
||||
environmentVariables.Add("Lidarr_Artist_Name", artist.Name);
|
||||
environmentVariables.Add("Lidarr_Artist_Path", artist.Path);
|
||||
environmentVariables.Add("Lidarr_Artist_MBId", artist.ForeignArtistId.ToString());
|
||||
//environmentVariables.Add("Lidarr_Artist_Type", artist.SeriesType.ToString());
|
||||
environmentVariables.Add("Lidarr_TrackFile_Id", trackFile.Id.ToString());
|
||||
environmentVariables.Add("Lidarr_TrackFile_EpisodeCount", trackFile.Tracks.Value.Count.ToString());
|
||||
environmentVariables.Add("Lidarr_TrackFile_RelativePath", trackFile.RelativePath);
|
||||
environmentVariables.Add("Lidarr_TrackFile_Path", Path.Combine(artist.Path, trackFile.RelativePath));
|
||||
environmentVariables.Add("Lidarr_TrackFile_TrackNumbers", string.Join(",", trackFile.Tracks.Value.Select(e => e.TrackNumber)));
|
||||
environmentVariables.Add("Lidarr_TrackFile_TrackReleaseDates", string.Join(",", trackFile.Tracks.Value.Select(e => e.Album.ReleaseDate)));
|
||||
environmentVariables.Add("Lidarr_TrackFile_TrackTitles", string.Join("|", trackFile.Tracks.Value.Select(e => e.Title)));
|
||||
environmentVariables.Add("Lidarr_TrackFile_Quality", trackFile.Quality.Quality.Name);
|
||||
environmentVariables.Add("Lidarr_TrackFile_QualityVersion", trackFile.Quality.Revision.Version.ToString());
|
||||
environmentVariables.Add("Lidarr_TrackFile_ReleaseGroup", trackFile.ReleaseGroup ?? string.Empty);
|
||||
environmentVariables.Add("Lidarr_TrackFile_SceneName", trackFile.SceneName ?? string.Empty);
|
||||
environmentVariables.Add("Lidarr_TrackFile_SourcePath", sourcePath);
|
||||
environmentVariables.Add("Lidarr_TrackFile_SourceFolder", Path.GetDirectoryName(sourcePath));
|
||||
|
||||
if (message.OldFiles.Any())
|
||||
{
|
||||
environmentVariables.Add("Lidarr_DeletedRelativePaths", string.Join("|", message.OldFiles.Select(e => e.RelativePath)));
|
||||
environmentVariables.Add("Lidarr_DeletedPaths", string.Join("|", message.OldFiles.Select(e => Path.Combine(series.Path, e.RelativePath))));
|
||||
environmentVariables.Add("Lidarr_DeletedPaths", string.Join("|", message.OldFiles.Select(e => Path.Combine(artist.Path, e.RelativePath))));
|
||||
}
|
||||
|
||||
ExecuteScript(environmentVariables);
|
||||
}
|
||||
|
||||
public override void OnRename(Series series)
|
||||
public override void OnRename(Artist artist)
|
||||
{
|
||||
var environmentVariables = new StringDictionary();
|
||||
|
||||
environmentVariables.Add("Lidarr_EventType", "Rename");
|
||||
environmentVariables.Add("Lidarr_Series_Id", series.Id.ToString());
|
||||
environmentVariables.Add("Lidarr_Series_Title", series.Title);
|
||||
environmentVariables.Add("Lidarr_Series_Path", series.Path);
|
||||
environmentVariables.Add("Lidarr_Series_TvdbId", series.TvdbId.ToString());
|
||||
environmentVariables.Add("Lidarr_Series_Type", series.SeriesType.ToString());
|
||||
environmentVariables.Add("Lidarr_Artist_Id", artist.Id.ToString());
|
||||
environmentVariables.Add("Lidarr_Artist_Title", artist.Name);
|
||||
environmentVariables.Add("Lidarr_Artist_Path", artist.Path);
|
||||
environmentVariables.Add("Lidarr_Artist_TvdbId", artist.ForeignArtistId.ToString());
|
||||
//environmentVariables.Add("Lidarr_Artist_Type", artist.SeriesType.ToString());
|
||||
|
||||
ExecuteScript(environmentVariables);
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Notifications
|
||||
{
|
||||
public class DownloadMessage
|
||||
{
|
||||
public string Message { get; set; }
|
||||
public Series Series { get; set; }
|
||||
public EpisodeFile EpisodeFile { get; set; }
|
||||
public List<EpisodeFile> OldFiles { get; set; }
|
||||
public Artist Artist { get; set; }
|
||||
public TrackFile TrackFile { get; set; }
|
||||
public List<TrackFile> OldFiles { get; set; }
|
||||
public string SourcePath { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
@ -23,14 +23,14 @@ namespace NzbDrone.Core.Notifications.Email
|
|||
{
|
||||
var body = $"{grabMessage.Message} sent to queue.";
|
||||
|
||||
_emailService.SendEmail(Settings, EPISODE_GRABBED_TITLE_BRANDED, body);
|
||||
_emailService.SendEmail(Settings, ALBUM_GRABBED_TITLE_BRANDED, body);
|
||||
}
|
||||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
{
|
||||
var body = $"{message.Message} Downloaded and sorted.";
|
||||
|
||||
_emailService.SendEmail(Settings, EPISODE_DOWNLOADED_TITLE_BRANDED, body);
|
||||
_emailService.SendEmail(Settings, TRACK_DOWNLOADED_TITLE_BRANDED, body);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Notifications
|
||||
{
|
||||
public class GrabMessage
|
||||
{
|
||||
public string Message { get; set; }
|
||||
public Series Series { get; set; }
|
||||
public RemoteEpisode Episode { get; set; }
|
||||
public Artist Artist { get; set; }
|
||||
public RemoteAlbum Album { get; set; }
|
||||
public QualityModel Quality { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
@ -21,12 +21,12 @@ namespace NzbDrone.Core.Notifications.Growl
|
|||
|
||||
public override void OnGrab(GrabMessage grabMessage)
|
||||
{
|
||||
_growlService.SendNotification(EPISODE_GRABBED_TITLE, grabMessage.Message, "GRAB", Settings.Host, Settings.Port, Settings.Password);
|
||||
_growlService.SendNotification(ALBUM_GRABBED_TITLE, grabMessage.Message, "GRAB", Settings.Host, Settings.Port, Settings.Password);
|
||||
}
|
||||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
{
|
||||
_growlService.SendNotification(EPISODE_DOWNLOADED_TITLE, message.Message, "DOWNLOAD", Settings.Host, Settings.Port, Settings.Password);
|
||||
_growlService.SendNotification(TRACK_DOWNLOADED_TITLE, message.Message, "DOWNLOAD", Settings.Host, Settings.Port, Settings.Password);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Notifications
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ namespace NzbDrone.Core.Notifications
|
|||
|
||||
void OnGrab(GrabMessage grabMessage);
|
||||
void OnDownload(DownloadMessage message);
|
||||
void OnRename(Series series);
|
||||
void OnRename(Artist artist);
|
||||
bool SupportsOnGrab { get; }
|
||||
bool SupportsOnDownload { get; }
|
||||
bool SupportsOnUpgrade { get; }
|
||||
|
|
|
@ -19,12 +19,12 @@ namespace NzbDrone.Core.Notifications.Join
|
|||
|
||||
public override void OnGrab(GrabMessage message)
|
||||
{
|
||||
_proxy.SendNotification(EPISODE_GRABBED_TITLE_BRANDED, message.Message, Settings);
|
||||
_proxy.SendNotification(ALBUM_GRABBED_TITLE_BRANDED, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
{
|
||||
_proxy.SendNotification(EPISODE_DOWNLOADED_TITLE_BRANDED, message.Message, Settings);
|
||||
_proxy.SendNotification(TRACK_DOWNLOADED_TITLE_BRANDED, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using FluentValidation.Results;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Emby
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ namespace NzbDrone.Core.Notifications.Emby
|
|||
{
|
||||
if (Settings.Notify)
|
||||
{
|
||||
_mediaBrowserService.Notify(Settings, EPISODE_GRABBED_TITLE_BRANDED, grabMessage.Message);
|
||||
_mediaBrowserService.Notify(Settings, ALBUM_GRABBED_TITLE_BRANDED, grabMessage.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,20 +30,20 @@ namespace NzbDrone.Core.Notifications.Emby
|
|||
{
|
||||
if (Settings.Notify)
|
||||
{
|
||||
_mediaBrowserService.Notify(Settings, EPISODE_DOWNLOADED_TITLE_BRANDED, message.Message);
|
||||
_mediaBrowserService.Notify(Settings, TRACK_DOWNLOADED_TITLE_BRANDED, message.Message);
|
||||
}
|
||||
|
||||
if (Settings.UpdateLibrary)
|
||||
{
|
||||
_mediaBrowserService.Update(Settings, message.Series);
|
||||
_mediaBrowserService.Update(Settings, message.Artist);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnRename(Series series)
|
||||
public override void OnRename(Artist artist)
|
||||
{
|
||||
if (Settings.UpdateLibrary)
|
||||
{
|
||||
_mediaBrowserService.Update(Settings, series);
|
||||
_mediaBrowserService.Update(Settings, artist);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using NLog;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Common.Serializer;
|
||||
|
||||
|
@ -31,9 +31,9 @@ namespace NzbDrone.Core.Notifications.Emby
|
|||
ProcessRequest(request, settings);
|
||||
}
|
||||
|
||||
public void Update(MediaBrowserSettings settings, int tvdbId)
|
||||
public void Update(MediaBrowserSettings settings, string mbId)
|
||||
{
|
||||
var path = string.Format("/Library/Series/Updated?tvdbid={0}", tvdbId);
|
||||
var path = string.Format("/Library/Artist/Updated?tvdbid={0}", mbId); //TODO: Get Emby to add a new Library Route
|
||||
var request = BuildRequest(path, settings);
|
||||
request.Headers.Add("Content-Length", "0");
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Net;
|
||||
using FluentValidation.Results;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Rest;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Emby
|
||||
{
|
||||
public interface IMediaBrowserService
|
||||
{
|
||||
void Notify(MediaBrowserSettings settings, string title, string message);
|
||||
void Update(MediaBrowserSettings settings, Series series);
|
||||
void Update(MediaBrowserSettings settings, Artist artist);
|
||||
ValidationFailure Test(MediaBrowserSettings settings);
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,9 @@ namespace NzbDrone.Core.Notifications.Emby
|
|||
_proxy.Notify(settings, title, message);
|
||||
}
|
||||
|
||||
public void Update(MediaBrowserSettings settings, Series series)
|
||||
public void Update(MediaBrowserSettings settings, Artist artist)
|
||||
{
|
||||
_proxy.Update(settings, series.TvdbId);
|
||||
_proxy.Update(settings, artist.ForeignArtistId);
|
||||
}
|
||||
|
||||
public ValidationFailure Test(MediaBrowserSettings settings)
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FluentValidation.Results;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Notifications
|
||||
{
|
||||
public abstract class NotificationBase<TSettings> : INotification where TSettings : IProviderConfig, new()
|
||||
{
|
||||
protected const string EPISODE_GRABBED_TITLE = "Episode Grabbed";
|
||||
protected const string EPISODE_DOWNLOADED_TITLE = "Episode Downloaded";
|
||||
protected const string ALBUM_GRABBED_TITLE = "Album Grabbed";
|
||||
protected const string TRACK_DOWNLOADED_TITLE = "Track Downloaded";
|
||||
|
||||
protected const string EPISODE_GRABBED_TITLE_BRANDED = "Lidarr - " + EPISODE_GRABBED_TITLE;
|
||||
protected const string EPISODE_DOWNLOADED_TITLE_BRANDED = "Lidarr - " + EPISODE_DOWNLOADED_TITLE;
|
||||
protected const string ALBUM_GRABBED_TITLE_BRANDED = "Lidarr - " + ALBUM_GRABBED_TITLE;
|
||||
protected const string TRACK_DOWNLOADED_TITLE_BRANDED = "Lidarr - " + TRACK_DOWNLOADED_TITLE;
|
||||
|
||||
public abstract string Name { get; }
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace NzbDrone.Core.Notifications
|
|||
|
||||
}
|
||||
|
||||
public virtual void OnRename(Series series)
|
||||
public virtual void OnRename(Artist series)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -8,14 +8,14 @@ using NzbDrone.Core.MediaFiles.Events;
|
|||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Notifications
|
||||
{
|
||||
public class NotificationService
|
||||
: IHandle<EpisodeGrabbedEvent>,
|
||||
IHandle<EpisodeDownloadedEvent>,
|
||||
IHandle<SeriesRenamedEvent>
|
||||
: IHandle<AlbumGrabbedEvent>,
|
||||
IHandle<TrackDownloadedEvent>,
|
||||
IHandle<ArtistRenamedEvent>
|
||||
{
|
||||
private readonly INotificationFactory _notificationFactory;
|
||||
private readonly Logger _logger;
|
||||
|
@ -26,48 +26,43 @@ namespace NzbDrone.Core.Notifications
|
|||
_logger = logger;
|
||||
}
|
||||
|
||||
private string GetMessage(Series series, List<Episode> episodes, QualityModel quality)
|
||||
private string GetMessage(Artist artist, List<Album> albums, QualityModel quality)
|
||||
{
|
||||
var qualityString = quality.Quality.ToString();
|
||||
|
||||
if (quality.Revision.Version > 1)
|
||||
{
|
||||
if (series.SeriesType == SeriesTypes.Anime)
|
||||
{
|
||||
qualityString += " v" + quality.Revision.Version;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
qualityString += " Proper";
|
||||
}
|
||||
qualityString += " Proper";
|
||||
}
|
||||
|
||||
if (series.SeriesType == SeriesTypes.Daily)
|
||||
{
|
||||
var episode = episodes.First();
|
||||
|
||||
return string.Format("{0} - {1} - {2} [{3}]",
|
||||
series.Title,
|
||||
episode.AirDate,
|
||||
episode.Title,
|
||||
qualityString);
|
||||
}
|
||||
var albumTitles = string.Join(" + ", albums.Select(e => e.Title));
|
||||
|
||||
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,
|
||||
episodes.First().SeasonNumber,
|
||||
episodeNumbers,
|
||||
episodeTitles,
|
||||
return string.Format("{0} - {1} - [{4}]",
|
||||
artist.Name,
|
||||
albumTitles,
|
||||
qualityString);
|
||||
}
|
||||
|
||||
private bool ShouldHandleSeries(ProviderDefinition definition, Series series)
|
||||
private string GetTrackMessage(Artist artist, List<Track> tracks, QualityModel quality)
|
||||
{
|
||||
var qualityString = quality.Quality.ToString();
|
||||
|
||||
if (quality.Revision.Version > 1)
|
||||
{
|
||||
qualityString += " Proper";
|
||||
}
|
||||
|
||||
|
||||
var trackTitles = string.Join(" + ", tracks.Select(e => e.Title));
|
||||
|
||||
return string.Format("{0} - {1} - [{4}]",
|
||||
artist.Name,
|
||||
trackTitles,
|
||||
qualityString);
|
||||
}
|
||||
|
||||
private bool ShouldHandleArtist(ProviderDefinition definition, Artist artist)
|
||||
{
|
||||
if (definition.Tags.Empty())
|
||||
{
|
||||
|
@ -75,32 +70,32 @@ namespace NzbDrone.Core.Notifications
|
|||
return true;
|
||||
}
|
||||
|
||||
if (definition.Tags.Intersect(series.Tags).Any())
|
||||
if (definition.Tags.Intersect(artist.Tags).Any())
|
||||
{
|
||||
_logger.Debug("Notification and series have one or more intersecting tags.");
|
||||
return true;
|
||||
}
|
||||
|
||||
//TODO: this message could be more clear
|
||||
_logger.Debug("{0} does not have any intersecting tags with {1}. Notification will not be sent.", definition.Name, series.Title);
|
||||
_logger.Debug("{0} does not have any intersecting tags with {1}. Notification will not be sent.", definition.Name, artist.Name);
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Handle(EpisodeGrabbedEvent message)
|
||||
public void Handle(AlbumGrabbedEvent message)
|
||||
{
|
||||
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
|
||||
Message = GetMessage(message.Album.Artist, message.Album.Albums, message.Album.ParsedAlbumInfo.Quality),
|
||||
Artist = message.Album.Artist,
|
||||
Quality = message.Album.ParsedAlbumInfo.Quality,
|
||||
Album = message.Album
|
||||
};
|
||||
|
||||
foreach (var notification in _notificationFactory.OnGrabEnabled())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ShouldHandleSeries(notification.Definition, message.Episode.Series)) continue;
|
||||
if (!ShouldHandleArtist(notification.Definition, message.Album.Artist)) continue;
|
||||
notification.OnGrab(grabMessage);
|
||||
}
|
||||
|
||||
|
@ -111,20 +106,20 @@ namespace NzbDrone.Core.Notifications
|
|||
}
|
||||
}
|
||||
|
||||
public void Handle(EpisodeDownloadedEvent message)
|
||||
public void Handle(TrackDownloadedEvent message)
|
||||
{
|
||||
var downloadMessage = new DownloadMessage();
|
||||
downloadMessage.Message = GetMessage(message.Episode.Series, message.Episode.Episodes, message.Episode.Quality);
|
||||
downloadMessage.Series = message.Episode.Series;
|
||||
downloadMessage.EpisodeFile = message.EpisodeFile;
|
||||
downloadMessage.Message = GetTrackMessage(message.Track.Artist, message.Track.Tracks, message.Track.Quality);
|
||||
downloadMessage.Artist = message.Track.Artist;
|
||||
downloadMessage.TrackFile = message.TrackFile;
|
||||
downloadMessage.OldFiles = message.OldFiles;
|
||||
downloadMessage.SourcePath = message.Episode.Path;
|
||||
downloadMessage.SourcePath = message.Track.Path;
|
||||
|
||||
foreach (var notification in _notificationFactory.OnDownloadEnabled())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ShouldHandleSeries(notification.Definition, message.Episode.Series))
|
||||
if (ShouldHandleArtist(notification.Definition, message.Track.Artist))
|
||||
{
|
||||
if (downloadMessage.OldFiles.Empty() || ((NotificationDefinition)notification.Definition).OnUpgrade)
|
||||
{
|
||||
|
@ -140,15 +135,15 @@ namespace NzbDrone.Core.Notifications
|
|||
}
|
||||
}
|
||||
|
||||
public void Handle(SeriesRenamedEvent message)
|
||||
public void Handle(ArtistRenamedEvent message)
|
||||
{
|
||||
foreach (var notification in _notificationFactory.OnRenameEnabled())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ShouldHandleSeries(notification.Definition, message.Series))
|
||||
if (ShouldHandleArtist(notification.Definition, message.Artist))
|
||||
{
|
||||
notification.OnRename(message.Series);
|
||||
notification.OnRename(message.Artist);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,12 +18,12 @@ namespace NzbDrone.Core.Notifications.NotifyMyAndroid
|
|||
|
||||
public override void OnGrab(GrabMessage grabMessage)
|
||||
{
|
||||
_proxy.SendNotification(EPISODE_GRABBED_TITLE, grabMessage.Message, Settings.ApiKey, (NotifyMyAndroidPriority)Settings.Priority);
|
||||
_proxy.SendNotification(ALBUM_GRABBED_TITLE, grabMessage.Message, Settings.ApiKey, (NotifyMyAndroidPriority)Settings.Priority);
|
||||
}
|
||||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
{
|
||||
_proxy.SendNotification(EPISODE_DOWNLOADED_TITLE, message.Message, Settings.ApiKey, (NotifyMyAndroidPriority)Settings.Priority);
|
||||
_proxy.SendNotification(TRACK_DOWNLOADED_TITLE, message.Message, Settings.ApiKey, (NotifyMyAndroidPriority)Settings.Priority);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
|
|
|
@ -19,12 +19,12 @@ namespace NzbDrone.Core.Notifications.Plex
|
|||
|
||||
public override void OnGrab(GrabMessage grabMessage)
|
||||
{
|
||||
_plexClientService.Notify(Settings, EPISODE_GRABBED_TITLE_BRANDED, grabMessage.Message);
|
||||
_plexClientService.Notify(Settings, ALBUM_GRABBED_TITLE_BRANDED, grabMessage.Message);
|
||||
}
|
||||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
{
|
||||
_plexClientService.Notify(Settings, EPISODE_DOWNLOADED_TITLE_BRANDED, message.Message);
|
||||
_plexClientService.Notify(Settings, TRACK_DOWNLOADED_TITLE_BRANDED, message.Message);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -24,12 +24,12 @@ namespace NzbDrone.Core.Notifications.Plex
|
|||
|
||||
public override void OnGrab(GrabMessage grabMessage)
|
||||
{
|
||||
Notify(Settings, EPISODE_GRABBED_TITLE_BRANDED, grabMessage.Message);
|
||||
Notify(Settings, ALBUM_GRABBED_TITLE_BRANDED, grabMessage.Message);
|
||||
}
|
||||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
{
|
||||
Notify(Settings, EPISODE_DOWNLOADED_TITLE_BRANDED, message.Message);
|
||||
Notify(Settings, TRACK_DOWNLOADED_TITLE_BRANDED, message.Message);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using FluentValidation.Results;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Plex
|
||||
{
|
||||
|
@ -19,19 +19,19 @@ namespace NzbDrone.Core.Notifications.Plex
|
|||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
{
|
||||
UpdateIfEnabled(message.Series);
|
||||
UpdateIfEnabled(message.Artist);
|
||||
}
|
||||
|
||||
public override void OnRename(Series series)
|
||||
public override void OnRename(Artist artist)
|
||||
{
|
||||
UpdateIfEnabled(series);
|
||||
UpdateIfEnabled(artist);
|
||||
}
|
||||
|
||||
private void UpdateIfEnabled(Series series)
|
||||
private void UpdateIfEnabled(Artist artist)
|
||||
{
|
||||
if (Settings.UpdateLibrary)
|
||||
{
|
||||
_plexServerService.UpdateLibrary(series, Settings);
|
||||
_plexServerService.UpdateLibrary(artist, Settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
@ -21,7 +21,7 @@ namespace NzbDrone.Core.Notifications.Plex
|
|||
void UpdateSeries(int metadataId, PlexServerSettings settings);
|
||||
string Version(PlexServerSettings settings);
|
||||
List<PlexPreference> Preferences(PlexServerSettings settings);
|
||||
int? GetMetadataId(int sectionId, int tvdbId, string language, PlexServerSettings settings);
|
||||
int? GetMetadataId(int sectionId, string mdId, string language, PlexServerSettings settings);
|
||||
}
|
||||
|
||||
public class PlexServerProxy : IPlexServerProxy
|
||||
|
@ -128,9 +128,9 @@ namespace NzbDrone.Core.Notifications.Plex
|
|||
.Preferences;
|
||||
}
|
||||
|
||||
public int? GetMetadataId(int sectionId, int tvdbId, string language, PlexServerSettings settings)
|
||||
public int? GetMetadataId(int sectionId, string mbId, string language, PlexServerSettings settings)
|
||||
{
|
||||
var guid = string.Format("com.plexapp.agents.thetvdb://{0}?lang={1}", tvdbId, language);
|
||||
var guid = string.Format("com.plexapp.agents.lastfm://{0}?lang={1}", mbId, language); // TODO Plex Route for MB? LastFM?
|
||||
var resource = string.Format("library/sections/{0}/all?guid={1}", sectionId, System.Web.HttpUtility.UrlEncode(guid));
|
||||
var request = GetPlexServerRequest(resource, Method.GET, settings);
|
||||
var client = GetPlexServerClient(settings);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
@ -7,13 +7,13 @@ using NLog;
|
|||
using NzbDrone.Common.Cache;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Notifications.Plex.Models;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Plex
|
||||
{
|
||||
public interface IPlexServerService
|
||||
{
|
||||
void UpdateLibrary(Series series, PlexServerSettings settings);
|
||||
void UpdateLibrary(Artist artist, PlexServerSettings settings);
|
||||
ValidationFailure Test(PlexServerSettings settings);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ namespace NzbDrone.Core.Notifications.Plex
|
|||
_logger = logger;
|
||||
}
|
||||
|
||||
public void UpdateLibrary(Series series, PlexServerSettings settings)
|
||||
public void UpdateLibrary(Artist artist, PlexServerSettings settings)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ namespace NzbDrone.Core.Notifications.Plex
|
|||
|
||||
if (partialUpdates)
|
||||
{
|
||||
UpdatePartialSection(series, sections, settings);
|
||||
UpdatePartialSection(artist, sections, settings);
|
||||
}
|
||||
|
||||
else
|
||||
|
@ -130,17 +130,17 @@ namespace NzbDrone.Core.Notifications.Plex
|
|||
_plexServerProxy.Update(sectionId, settings);
|
||||
}
|
||||
|
||||
private void UpdatePartialSection(Series series, List<PlexSection> sections, PlexServerSettings settings)
|
||||
private void UpdatePartialSection(Artist artist, List<PlexSection> sections, PlexServerSettings settings)
|
||||
{
|
||||
var partiallyUpdated = false;
|
||||
|
||||
foreach (var section in sections)
|
||||
{
|
||||
var metadataId = GetMetadataId(section.Id, series, section.Language, settings);
|
||||
var metadataId = GetMetadataId(section.Id, artist, section.Language, settings);
|
||||
|
||||
if (metadataId.HasValue)
|
||||
{
|
||||
_logger.Debug("Updating Plex host: {0}, Section: {1}, Series: {2}", settings.Host, section.Id, series);
|
||||
_logger.Debug("Updating Plex host: {0}, Section: {1}, Artist: {2}", settings.Host, section.Id, artist);
|
||||
_plexServerProxy.UpdateSeries(metadataId.Value, settings);
|
||||
|
||||
partiallyUpdated = true;
|
||||
|
@ -150,16 +150,16 @@ namespace NzbDrone.Core.Notifications.Plex
|
|||
// Only update complete sections if all partial updates failed
|
||||
if (!partiallyUpdated)
|
||||
{
|
||||
_logger.Debug("Unable to update partial section, updating all TV sections");
|
||||
_logger.Debug("Unable to update partial section, updating all Music sections");
|
||||
sections.ForEach(s => UpdateSection(s.Id, settings));
|
||||
}
|
||||
}
|
||||
|
||||
private int? GetMetadataId(int sectionId, Series series, string language, PlexServerSettings settings)
|
||||
private int? GetMetadataId(int sectionId, Artist artist, string language, PlexServerSettings settings)
|
||||
{
|
||||
_logger.Debug("Getting metadata from Plex host: {0} for series: {1}", settings.Host, series);
|
||||
_logger.Debug("Getting metadata from Plex host: {0} for series: {1}", settings.Host, artist);
|
||||
|
||||
return _plexServerProxy.GetMetadataId(sectionId, series.TvdbId, language, settings);
|
||||
return _plexServerProxy.GetMetadataId(sectionId, artist.ForeignArtistId, language, settings);
|
||||
}
|
||||
|
||||
public ValidationFailure Test(PlexServerSettings settings)
|
||||
|
@ -170,7 +170,7 @@ namespace NzbDrone.Core.Notifications.Plex
|
|||
|
||||
if (sections.Empty())
|
||||
{
|
||||
return new ValidationFailure("Host", "At least one TV library is required");
|
||||
return new ValidationFailure("Host", "At least one Music library is required");
|
||||
}
|
||||
}
|
||||
catch(PlexAuthenticationException ex)
|
||||
|
|
|
@ -20,12 +20,12 @@ namespace NzbDrone.Core.Notifications.Prowl
|
|||
|
||||
public override void OnGrab(GrabMessage grabMessage)
|
||||
{
|
||||
_prowlService.SendNotification(EPISODE_GRABBED_TITLE, grabMessage.Message, Settings.ApiKey, (NotificationPriority)Settings.Priority);
|
||||
_prowlService.SendNotification(ALBUM_GRABBED_TITLE, grabMessage.Message, Settings.ApiKey, (NotificationPriority)Settings.Priority);
|
||||
}
|
||||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
{
|
||||
_prowlService.SendNotification(EPISODE_DOWNLOADED_TITLE, message.Message, Settings.ApiKey, (NotificationPriority)Settings.Priority);
|
||||
_prowlService.SendNotification(TRACK_DOWNLOADED_TITLE, message.Message, Settings.ApiKey, (NotificationPriority)Settings.Priority);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
|
|
|
@ -19,12 +19,12 @@ namespace NzbDrone.Core.Notifications.PushBullet
|
|||
|
||||
public override void OnGrab(GrabMessage grabMessage)
|
||||
{
|
||||
_proxy.SendNotification(EPISODE_GRABBED_TITLE_BRANDED, grabMessage.Message, Settings);
|
||||
_proxy.SendNotification(ALBUM_GRABBED_TITLE_BRANDED, grabMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
{
|
||||
_proxy.SendNotification(EPISODE_DOWNLOADED_TITLE_BRANDED, message.Message, Settings);
|
||||
_proxy.SendNotification(TRACK_DOWNLOADED_TITLE_BRANDED, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
|
|
|
@ -19,12 +19,12 @@ namespace NzbDrone.Core.Notifications.Pushalot
|
|||
|
||||
public override void OnGrab(GrabMessage grabMessage)
|
||||
{
|
||||
_proxy.SendNotification(EPISODE_GRABBED_TITLE, grabMessage.Message, Settings);
|
||||
_proxy.SendNotification(ALBUM_GRABBED_TITLE, grabMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
{
|
||||
_proxy.SendNotification(EPISODE_DOWNLOADED_TITLE, message.Message, Settings);
|
||||
_proxy.SendNotification(TRACK_DOWNLOADED_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,12 +18,12 @@ namespace NzbDrone.Core.Notifications.Pushover
|
|||
|
||||
public override void OnGrab(GrabMessage grabMessage)
|
||||
{
|
||||
_proxy.SendNotification(EPISODE_GRABBED_TITLE, grabMessage.Message, Settings);
|
||||
_proxy.SendNotification(ALBUM_GRABBED_TITLE, grabMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
{
|
||||
_proxy.SendNotification(EPISODE_DOWNLOADED_TITLE, message.Message, Settings);
|
||||
_proxy.SendNotification(TRACK_DOWNLOADED_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FluentValidation.Results;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Notifications.Slack.Payloads;
|
||||
using NzbDrone.Core.Rest;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Validation;
|
||||
using RestSharp;
|
||||
|
||||
|
@ -36,7 +36,7 @@ namespace NzbDrone.Core.Notifications.Slack
|
|||
new Attachment
|
||||
{
|
||||
Fallback = message.Message,
|
||||
Title = message.Series.Title,
|
||||
Title = message.Artist.Name,
|
||||
Text = message.Message,
|
||||
Color = "warning"
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ namespace NzbDrone.Core.Notifications.Slack
|
|||
new Attachment
|
||||
{
|
||||
Fallback = message.Message,
|
||||
Title = message.Series.Title,
|
||||
Title = message.Artist.Name,
|
||||
Text = message.Message,
|
||||
Color = "good"
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ namespace NzbDrone.Core.Notifications.Slack
|
|||
NotifySlack(payload);
|
||||
}
|
||||
|
||||
public override void OnRename(Series series)
|
||||
public override void OnRename(Artist artist)
|
||||
{
|
||||
var payload = new SlackPayload
|
||||
{
|
||||
|
@ -79,7 +79,7 @@ namespace NzbDrone.Core.Notifications.Slack
|
|||
{
|
||||
new Attachment
|
||||
{
|
||||
Title = series.Title,
|
||||
Title = artist.Name,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using FluentValidation.Results;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Synology
|
||||
{
|
||||
|
@ -26,24 +26,24 @@ namespace NzbDrone.Core.Notifications.Synology
|
|||
{
|
||||
foreach (var oldFile in message.OldFiles)
|
||||
{
|
||||
var fullPath = Path.Combine(message.Series.Path, oldFile.RelativePath);
|
||||
var fullPath = Path.Combine(message.Artist.Path, oldFile.RelativePath);
|
||||
|
||||
_indexerProxy.DeleteFile(fullPath);
|
||||
}
|
||||
|
||||
{
|
||||
var fullPath = Path.Combine(message.Series.Path, message.EpisodeFile.RelativePath);
|
||||
var fullPath = Path.Combine(message.Artist.Path, message.TrackFile.RelativePath);
|
||||
|
||||
_indexerProxy.AddFile(fullPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnRename(Series series)
|
||||
public override void OnRename(Artist artist)
|
||||
{
|
||||
if (Settings.UpdateLibrary)
|
||||
{
|
||||
_indexerProxy.UpdateFolder(series.Path);
|
||||
_indexerProxy.UpdateFolder(artist.Path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,12 +18,12 @@ namespace NzbDrone.Core.Notifications.Telegram
|
|||
|
||||
public override void OnGrab(GrabMessage grabMessage)
|
||||
{
|
||||
_proxy.SendNotification(EPISODE_GRABBED_TITLE, grabMessage.Message, Settings);
|
||||
_proxy.SendNotification(ALBUM_GRABBED_TITLE, grabMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
{
|
||||
_proxy.SendNotification(EPISODE_DOWNLOADED_TITLE, message.Message, Settings);
|
||||
_proxy.SendNotification(TRACK_DOWNLOADED_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
|
||||
using System.Collections.Generic;
|
||||
using FluentValidation.Results;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Webhook
|
||||
|
@ -19,17 +19,17 @@ namespace NzbDrone.Core.Notifications.Webhook
|
|||
|
||||
public override void OnGrab(GrabMessage message)
|
||||
{
|
||||
_service.OnGrab(message.Series, message.Episode, message.Quality, Settings);
|
||||
_service.OnGrab(message.Artist, message.Album, message.Quality, Settings);
|
||||
}
|
||||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
{
|
||||
_service.OnDownload(message.Series, message.EpisodeFile, Settings);
|
||||
_service.OnDownload(message.Artist, message.TrackFile, Settings);
|
||||
}
|
||||
|
||||
public override void OnRename(Series series)
|
||||
public override void OnRename(Artist artist)
|
||||
{
|
||||
_service.OnRename(series, Settings);
|
||||
_service.OnRename(artist, Settings);
|
||||
}
|
||||
|
||||
public override string Name => "Webhook";
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
using NzbDrone.Core.Music;
|
||||
using System;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Webhook
|
||||
{
|
||||
public class WebhookAlbum
|
||||
{
|
||||
public WebhookAlbum() { }
|
||||
|
||||
public WebhookAlbum(Album album)
|
||||
{
|
||||
Id = album.Id;
|
||||
Title = album.Title;
|
||||
ReleaseDate = album.ReleaseDate;
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public DateTime? ReleaseDate { get; set; }
|
||||
|
||||
public string Quality { get; set; }
|
||||
public int QualityVersion { get; set; }
|
||||
public string ReleaseGroup { get; set; }
|
||||
public string SceneName { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Webhook
|
||||
{
|
||||
public class WebhookArtist
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string MBId { get; set; }
|
||||
|
||||
public WebhookArtist() { }
|
||||
|
||||
public WebhookArtist(Artist artist)
|
||||
{
|
||||
Id = artist.Id;
|
||||
Title = artist.Name;
|
||||
Path = artist.Path;
|
||||
MBId = artist.ForeignArtistId;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
using NzbDrone.Core.Tv;
|
||||
using System;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Webhook
|
||||
{
|
||||
public class WebhookEpisode
|
||||
{
|
||||
public WebhookEpisode() { }
|
||||
|
||||
public WebhookEpisode(Episode episode)
|
||||
{
|
||||
Id = episode.Id;
|
||||
SeasonNumber = episode.SeasonNumber;
|
||||
EpisodeNumber = episode.EpisodeNumber;
|
||||
Title = episode.Title;
|
||||
AirDate = episode.AirDate;
|
||||
AirDateUtc = episode.AirDateUtc;
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
public int EpisodeNumber { get; set; }
|
||||
public int SeasonNumber { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string AirDate { get; set; }
|
||||
public DateTime? AirDateUtc { get; set; }
|
||||
|
||||
public string Quality { get; set; }
|
||||
public int QualityVersion { get; set; }
|
||||
public string ReleaseGroup { get; set; }
|
||||
public string SceneName { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Webhook
|
||||
{
|
||||
public class WebhookPayload
|
||||
{
|
||||
public string EventType { get; set; }
|
||||
public WebhookSeries Series { get; set; }
|
||||
public List<WebhookEpisode> Episodes { get; set; }
|
||||
public WebhookArtist Artist { get; set; }
|
||||
public List<WebhookAlbum> Albums { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Webhook
|
||||
{
|
||||
public class WebhookSeries
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Path { get; set; }
|
||||
public int TvdbId { get; set; }
|
||||
|
||||
public WebhookSeries() { }
|
||||
|
||||
public WebhookSeries(Series series)
|
||||
{
|
||||
Id = series.Id;
|
||||
Title = series.Title;
|
||||
Path = series.Path;
|
||||
TvdbId = series.TvdbId;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
using FluentValidation.Results;
|
||||
using FluentValidation.Results;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Validation;
|
||||
using NzbDrone.Core.Rest;
|
||||
using RestSharp;
|
||||
|
@ -12,53 +12,53 @@ namespace NzbDrone.Core.Notifications.Webhook
|
|||
{
|
||||
public interface IWebhookService
|
||||
{
|
||||
void OnDownload(Series series, EpisodeFile episodeFile, WebhookSettings settings);
|
||||
void OnRename(Series series, WebhookSettings settings);
|
||||
void OnGrab(Series series, RemoteEpisode episode, QualityModel quality, WebhookSettings settings);
|
||||
void OnDownload(Artist artist, TrackFile trackFile, WebhookSettings settings);
|
||||
void OnRename(Artist artist, WebhookSettings settings);
|
||||
void OnGrab(Artist artist, RemoteAlbum album, QualityModel quality, WebhookSettings settings);
|
||||
ValidationFailure Test(WebhookSettings settings);
|
||||
}
|
||||
|
||||
public class WebhookService : IWebhookService
|
||||
{
|
||||
public void OnDownload(Series series, EpisodeFile episodeFile, WebhookSettings settings)
|
||||
public void OnDownload(Artist artist, TrackFile trackFile, WebhookSettings settings)
|
||||
{
|
||||
var payload = new WebhookPayload
|
||||
{
|
||||
EventType = "Download",
|
||||
Series = new WebhookSeries(series),
|
||||
Episodes = episodeFile.Episodes.Value.ConvertAll(x => new WebhookEpisode(x) {
|
||||
Quality = episodeFile.Quality.Quality.Name,
|
||||
QualityVersion = episodeFile.Quality.Revision.Version,
|
||||
ReleaseGroup = episodeFile.ReleaseGroup,
|
||||
SceneName = episodeFile.SceneName
|
||||
Artist = new WebhookArtist(artist),
|
||||
Albums = trackFile.Tracks.Value.ConvertAll(x => new WebhookAlbum(x.Album) {
|
||||
Quality = trackFile.Quality.Quality.Name,
|
||||
QualityVersion = trackFile.Quality.Revision.Version,
|
||||
ReleaseGroup = trackFile.ReleaseGroup,
|
||||
SceneName = trackFile.SceneName
|
||||
})
|
||||
};
|
||||
|
||||
NotifyWebhook(payload, settings);
|
||||
}
|
||||
|
||||
public void OnRename(Series series, WebhookSettings settings)
|
||||
public void OnRename(Artist artist, WebhookSettings settings)
|
||||
{
|
||||
var payload = new WebhookPayload
|
||||
{
|
||||
EventType = "Rename",
|
||||
Series = new WebhookSeries(series)
|
||||
Artist = new WebhookArtist(artist)
|
||||
};
|
||||
|
||||
NotifyWebhook(payload, settings);
|
||||
}
|
||||
|
||||
public void OnGrab(Series series, RemoteEpisode episode, QualityModel quality, WebhookSettings settings)
|
||||
public void OnGrab(Artist artist, RemoteAlbum album, QualityModel quality, WebhookSettings settings)
|
||||
{
|
||||
var payload = new WebhookPayload
|
||||
{
|
||||
EventType = "Grab",
|
||||
Series = new WebhookSeries(series),
|
||||
Episodes = episode.Episodes.ConvertAll(x => new WebhookEpisode(x)
|
||||
Artist = new WebhookArtist(artist),
|
||||
Albums = album.Albums.ConvertAll(x => new WebhookAlbum(x)
|
||||
{
|
||||
Quality = quality.Quality.Name,
|
||||
QualityVersion = quality.Revision.Version,
|
||||
ReleaseGroup = episode.ParsedEpisodeInfo.ReleaseGroup
|
||||
ReleaseGroup = album.ParsedAlbumInfo.ReleaseGroup
|
||||
})
|
||||
};
|
||||
NotifyWebhook(payload, settings);
|
||||
|
@ -87,19 +87,17 @@ namespace NzbDrone.Core.Notifications.Webhook
|
|||
new WebhookPayload
|
||||
{
|
||||
EventType = "Test",
|
||||
Series = new WebhookSeries()
|
||||
Artist = new WebhookArtist()
|
||||
{
|
||||
Id = 1,
|
||||
Title = "Test Title",
|
||||
Path = "C:\\testpath",
|
||||
TvdbId = 1234
|
||||
MBId = "1234"
|
||||
},
|
||||
Episodes = new List<WebhookEpisode>() {
|
||||
new WebhookEpisode()
|
||||
Albums = new List<WebhookAlbum>() {
|
||||
new WebhookAlbum()
|
||||
{
|
||||
Id = 123,
|
||||
EpisodeNumber = 1,
|
||||
SeasonNumber = 1,
|
||||
Title = "Test title"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -6,7 +6,7 @@ using System.Xml.Linq;
|
|||
using NLog;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Notifications.Xbmc.Model;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Xbmc
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
|||
SendCommand(settings, command);
|
||||
}
|
||||
|
||||
public void Update(XbmcSettings settings, Series series)
|
||||
public void Update(XbmcSettings settings, Artist artist)
|
||||
{
|
||||
if (!settings.AlwaysUpdate)
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
|||
}
|
||||
}
|
||||
|
||||
UpdateLibrary(settings, series);
|
||||
UpdateLibrary(settings, artist);
|
||||
}
|
||||
|
||||
public void Clean(XbmcSettings settings)
|
||||
|
@ -80,12 +80,12 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
|||
return new List<ActivePlayer>();
|
||||
}
|
||||
|
||||
internal string GetSeriesPath(XbmcSettings settings, Series series)
|
||||
internal string GetSeriesPath(XbmcSettings settings, Artist artist)
|
||||
{
|
||||
var query =
|
||||
string.Format(
|
||||
"select path.strPath from path, tvshow, tvshowlinkpath where tvshow.c12 = {0} and tvshowlinkpath.idShow = tvshow.idShow and tvshowlinkpath.idPath = path.idPath",
|
||||
series.TvdbId);
|
||||
artist.ForeignArtistId);
|
||||
var command = string.Format("QueryVideoDatabase({0})", query);
|
||||
|
||||
const string setResponseCommand =
|
||||
|
@ -137,17 +137,17 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
|||
return false;
|
||||
}
|
||||
|
||||
private void UpdateLibrary(XbmcSettings settings, Series series)
|
||||
private void UpdateLibrary(XbmcSettings settings, Artist artist)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.Debug("Sending Update DB Request to XBMC Host: {0}", settings.Address);
|
||||
var xbmcSeriesPath = GetSeriesPath(settings, series);
|
||||
var xbmcSeriesPath = GetSeriesPath(settings, artist);
|
||||
|
||||
//If the path is found update it, else update the whole library
|
||||
if (!string.IsNullOrEmpty(xbmcSeriesPath))
|
||||
{
|
||||
_logger.Debug("Updating series [{0}] on XBMC host: {1}", series, settings.Address);
|
||||
_logger.Debug("Updating artist [{0}] on XBMC host: {1}", artist, settings.Address);
|
||||
var command = BuildExecBuiltInCommand(string.Format("UpdateLibrary(video,{0})", xbmcSeriesPath));
|
||||
SendCommand(settings, command);
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
|||
else
|
||||
{
|
||||
//Update the entire library
|
||||
_logger.Debug("Series [{0}] doesn't exist on XBMC host: {1}, Updating Entire Library", series, settings.Address);
|
||||
_logger.Debug("Artist [{0}] doesn't exist on XBMC host: {1}, Updating Entire Library", artist, settings.Address);
|
||||
var command = BuildExecBuiltInCommand("UpdateLibrary(video)");
|
||||
SendCommand(settings, command);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
using NzbDrone.Core.Notifications.Xbmc.Model;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Notifications.Xbmc.Model;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Xbmc
|
||||
{
|
||||
public interface IApiProvider
|
||||
{
|
||||
void Notify(XbmcSettings settings, string title, string message);
|
||||
void Update(XbmcSettings settings, Series series);
|
||||
void Update(XbmcSettings settings, Artist artist);
|
||||
void Clean(XbmcSettings settings);
|
||||
bool CanHandle(XbmcVersion version);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Notifications.Xbmc.Model;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Xbmc
|
||||
{
|
||||
|
@ -28,7 +28,7 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
|||
_proxy.Notify(settings, title, message);
|
||||
}
|
||||
|
||||
public void Update(XbmcSettings settings, Series series)
|
||||
public void Update(XbmcSettings settings, Artist artist)
|
||||
{
|
||||
if (!settings.AlwaysUpdate)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
|||
}
|
||||
}
|
||||
|
||||
UpdateLibrary(settings, series);
|
||||
UpdateLibrary(settings, artist);
|
||||
}
|
||||
|
||||
public void Clean(XbmcSettings settings)
|
||||
|
@ -55,22 +55,22 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
|||
return _proxy.GetActivePlayers(settings);
|
||||
}
|
||||
|
||||
public string GetSeriesPath(XbmcSettings settings, Series series)
|
||||
public string GetSeriesPath(XbmcSettings settings, Artist artist)
|
||||
{
|
||||
var allSeries = _proxy.GetSeries(settings);
|
||||
var allSeries = _proxy.GetArtist(settings);
|
||||
|
||||
if (!allSeries.Any())
|
||||
{
|
||||
_logger.Debug("No TV shows returned from XBMC");
|
||||
_logger.Debug("No Artists returned from XBMC");
|
||||
return null;
|
||||
}
|
||||
|
||||
var matchingSeries = allSeries.FirstOrDefault(s =>
|
||||
{
|
||||
var tvdbId = 0;
|
||||
int.TryParse(s.ImdbNumber, out tvdbId);
|
||||
var tvdbId = "0";
|
||||
//int.TryParse(s.ImdbNumber, out tvdbId);
|
||||
|
||||
return tvdbId == series.TvdbId || s.Label == series.Title;
|
||||
return tvdbId == artist.ForeignArtistId || s.Label == artist.Name;
|
||||
});
|
||||
|
||||
if (matchingSeries != null) return matchingSeries.File;
|
||||
|
@ -78,20 +78,20 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
|||
return null;
|
||||
}
|
||||
|
||||
private void UpdateLibrary(XbmcSettings settings, Series series)
|
||||
private void UpdateLibrary(XbmcSettings settings, Artist artist)
|
||||
{
|
||||
try
|
||||
{
|
||||
var seriesPath = GetSeriesPath(settings, series);
|
||||
var seriesPath = GetSeriesPath(settings, artist);
|
||||
|
||||
if (seriesPath != null)
|
||||
{
|
||||
_logger.Debug("Updating series {0} (Path: {1}) on XBMC host: {2}", series, seriesPath, settings.Address);
|
||||
_logger.Debug("Updating artist {0} (Path: {1}) on XBMC host: {2}", artist, seriesPath, settings.Address);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
_logger.Debug("Series {0} doesn't exist on XBMC host: {1}, Updating Entire Library", series,
|
||||
_logger.Debug("Artist {0} doesn't exist on XBMC host: {1}, Updating Entire Library", artist,
|
||||
settings.Address);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using FluentValidation.Results;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Xbmc
|
||||
{
|
||||
|
@ -33,12 +33,12 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
|||
const string header = "Lidarr - Downloaded";
|
||||
|
||||
Notify(Settings, header, message.Message);
|
||||
UpdateAndClean(message.Series, message.OldFiles.Any());
|
||||
UpdateAndClean(message.Artist, message.OldFiles.Any());
|
||||
}
|
||||
|
||||
public override void OnRename(Series series)
|
||||
public override void OnRename(Artist artist)
|
||||
{
|
||||
UpdateAndClean(series);
|
||||
UpdateAndClean(artist);
|
||||
}
|
||||
|
||||
public override string Name => "Kodi (XBMC)";
|
||||
|
@ -68,13 +68,13 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
|||
}
|
||||
}
|
||||
|
||||
private void UpdateAndClean(Series series, bool clean = true)
|
||||
private void UpdateAndClean(Artist artist, bool clean = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Settings.UpdateLibrary)
|
||||
{
|
||||
_xbmcService.Update(Settings, series);
|
||||
_xbmcService.Update(Settings, artist);
|
||||
}
|
||||
|
||||
if (clean && Settings.CleanLibrary)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Serializer;
|
||||
|
@ -16,7 +16,7 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
|||
string UpdateLibrary(XbmcSettings settings, string path);
|
||||
void CleanLibrary(XbmcSettings settings);
|
||||
List<ActivePlayer> GetActivePlayers(XbmcSettings settings);
|
||||
List<TvShow> GetSeries(XbmcSettings settings);
|
||||
List<TvShow> GetArtist(XbmcSettings settings);
|
||||
}
|
||||
|
||||
public class XbmcJsonApiProxy : IXbmcJsonApiProxy
|
||||
|
@ -79,7 +79,7 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
|||
return Json.Deserialize<ActivePlayersEdenResult>(response).Result;
|
||||
}
|
||||
|
||||
public List<TvShow> GetSeries(XbmcSettings settings)
|
||||
public List<TvShow> GetArtist(XbmcSettings settings)
|
||||
{
|
||||
var request = new RestRequest();
|
||||
var parameters = new Dictionary<string, object>();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentValidation.Results;
|
||||
|
@ -7,14 +7,14 @@ using NLog;
|
|||
using NzbDrone.Common.Cache;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Notifications.Xbmc.Model;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Xbmc
|
||||
{
|
||||
public interface IXbmcService
|
||||
{
|
||||
void Notify(XbmcSettings settings, string title, string message);
|
||||
void Update(XbmcSettings settings, Series series);
|
||||
void Update(XbmcSettings settings, Artist artist);
|
||||
void Clean(XbmcSettings settings);
|
||||
ValidationFailure Test(XbmcSettings settings, string message);
|
||||
}
|
||||
|
@ -45,10 +45,10 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
|||
provider.Notify(settings, title, message);
|
||||
}
|
||||
|
||||
public void Update(XbmcSettings settings, Series series)
|
||||
public void Update(XbmcSettings settings, Artist artist)
|
||||
{
|
||||
var provider = GetApiProvider(settings);
|
||||
provider.Update(settings, series);
|
||||
provider.Update(settings, artist);
|
||||
}
|
||||
|
||||
public void Clean(XbmcSettings settings)
|
||||
|
@ -122,4 +122,4 @@ namespace NzbDrone.Core.Notifications.Xbmc
|
|||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -936,11 +936,11 @@
|
|||
<Compile Include="Notifications\Telegram\TelegramSettings.cs" />
|
||||
<Compile Include="Notifications\Twitter\OAuthToken.cs" />
|
||||
<Compile Include="Notifications\Twitter\TwitterException.cs" />
|
||||
<Compile Include="Notifications\Webhook\WebhookEpisode.cs" />
|
||||
<Compile Include="Notifications\Webhook\WebhookAlbum.cs" />
|
||||
<Compile Include="Notifications\Webhook\WebhookException.cs" />
|
||||
<Compile Include="Notifications\Webhook\WebhookMethod.cs" />
|
||||
<Compile Include="Notifications\Webhook\WebhookPayload.cs" />
|
||||
<Compile Include="Notifications\Webhook\WebhookSeries.cs" />
|
||||
<Compile Include="Notifications\Webhook\WebhookArtist.cs" />
|
||||
<Compile Include="Notifications\Webhook\WebhookService.cs" />
|
||||
<Compile Include="Notifications\Webhook\WebhookSettings.cs" />
|
||||
<Compile Include="Notifications\Webhook\Webhook.cs" />
|
||||
|
|
Loading…
Reference in New Issue