-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: Include Path/Relative Path for on download Webhooks New: IsUpgrade flag for on download Webhooks
- Loading branch information
Showing
10 changed files
with
214 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/NzbDrone.Core/Notifications/Webhook/WebhookEpisodeFile.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using NzbDrone.Core.MediaFiles; | ||
|
||
namespace NzbDrone.Core.Notifications.Webhook | ||
{ | ||
public class WebhookEpisodeFile | ||
{ | ||
public WebhookEpisodeFile() { } | ||
|
||
public WebhookEpisodeFile(EpisodeFile episodeFile) | ||
{ | ||
Id = episodeFile.Id; | ||
RelativePath = episodeFile.RelativePath; | ||
Path = episodeFile.Path; | ||
Quality = episodeFile.Quality.Quality.Name; | ||
QualityVersion = episodeFile.Quality.Revision.Version; | ||
ReleaseGroup = episodeFile.ReleaseGroup; | ||
SceneName = episodeFile.SceneName; | ||
} | ||
|
||
public int Id { get; set; } | ||
public string RelativePath { get; set; } | ||
public string Path { get; set; } | ||
public string Quality { get; set; } | ||
public int QualityVersion { get; set; } | ||
public string ReleaseGroup { get; set; } | ||
public string SceneName { get; set; } | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/NzbDrone.Core/Notifications/Webhook/WebhookGrabPayload.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace NzbDrone.Core.Notifications.Webhook | ||
{ | ||
public class WebhookGrabPayload : WebhookPayload | ||
{ | ||
public List<WebhookEpisode> Episodes { get; set; } | ||
public WebhookRelease Release { get; set; } | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace NzbDrone.Core.Notifications.Webhook | ||
{ | ||
public class WebhookImportPayload : WebhookPayload | ||
{ | ||
public List<WebhookEpisode> Episodes { get; set; } | ||
public WebhookEpisodeFile EpisodeFile { get; set; } | ||
public bool IsUpgrade { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
namespace NzbDrone.Core.Notifications.Webhook | ||
using NzbDrone.Common.Http; | ||
|
||
namespace NzbDrone.Core.Notifications.Webhook | ||
{ | ||
public enum WebhookMethod | ||
{ | ||
POST = RestSharp.Method.POST, | ||
PUT = RestSharp.Method.PUT | ||
POST = HttpMethod.POST, | ||
PUT = HttpMethod.PUT | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace NzbDrone.Core.Notifications.Webhook | ||
namespace NzbDrone.Core.Notifications.Webhook | ||
{ | ||
public class WebhookPayload | ||
{ | ||
public string EventType { get; set; } | ||
public WebhookSeries Series { get; set; } | ||
public List<WebhookEpisode> Episodes { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using NzbDrone.Common.Http; | ||
using NzbDrone.Common.Serializer; | ||
using NzbDrone.Core.Rest; | ||
|
||
namespace NzbDrone.Core.Notifications.Webhook | ||
{ | ||
public interface IWebhookProxy | ||
{ | ||
void SendWebhook(WebhookPayload payload, WebhookSettings settings); | ||
} | ||
|
||
public class WebhookProxy : IWebhookProxy | ||
{ | ||
private readonly IHttpClient _httpClient; | ||
|
||
public WebhookProxy(IHttpClient httpClient) | ||
{ | ||
_httpClient = httpClient; | ||
} | ||
|
||
public void SendWebhook(WebhookPayload body, WebhookSettings settings) | ||
{ | ||
try | ||
{ | ||
var request = new HttpRequestBuilder(settings.Url) | ||
.Accept(HttpAccept.Json) | ||
.Build(); | ||
|
||
request.Method = (HttpMethod)settings.Method; | ||
request.Headers.ContentType = "application/json"; | ||
request.SetContent(body.ToJson()); | ||
|
||
_httpClient.Execute(request); | ||
} | ||
catch (RestException ex) | ||
{ | ||
throw new WebhookException("Unable to post to webhook: {0}", ex, ex.Message); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using NzbDrone.Core.Parser.Model; | ||
using NzbDrone.Core.Qualities; | ||
|
||
namespace NzbDrone.Core.Notifications.Webhook | ||
{ | ||
public class WebhookRelease | ||
{ | ||
public WebhookRelease() { } | ||
|
||
public WebhookRelease(QualityModel quality, RemoteEpisode remoteEpisode) | ||
{ | ||
Quality = quality.Quality.Name; | ||
QualityVersion = quality.Revision.Version; | ||
ReleaseGroup = remoteEpisode.ParsedEpisodeInfo.ReleaseGroup; | ||
ReleaseTitle = remoteEpisode.Release.Title; | ||
Indexer = remoteEpisode.Release.Indexer; | ||
Size = remoteEpisode.Release.Size; | ||
} | ||
|
||
public string Quality { get; set; } | ||
public int QualityVersion { get; set; } | ||
public string ReleaseGroup { get; set; } | ||
public string ReleaseTitle { get; set; } | ||
public string Indexer { get; set; } | ||
public long Size { get; set; } | ||
} | ||
} |
Oops, something went wrong.