|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Common.Cloud;
|
|
|
|
|
using NzbDrone.Common.Http;
|
|
|
|
|
using NzbDrone.Common.Serializer;
|
|
|
|
@ -14,6 +16,7 @@ namespace NzbDrone.Core.IndexerSearch
|
|
|
|
|
private readonly IHttpClient _httpClient;
|
|
|
|
|
private readonly IHttpRequestBuilderFactory _requestBuilder;
|
|
|
|
|
private readonly IAnalyticsService _analyticsService;
|
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
|
public ReleaseAnalyticsService(IHttpClient httpClient, IProwlarrCloudRequestBuilder requestBuilder, IAnalyticsService analyticsService)
|
|
|
|
|
{
|
|
|
|
@ -24,7 +27,7 @@ namespace NzbDrone.Core.IndexerSearch
|
|
|
|
|
|
|
|
|
|
public void HandleAsync(IndexerQueryEvent message)
|
|
|
|
|
{
|
|
|
|
|
if (_analyticsService.IsEnabled)
|
|
|
|
|
if (_analyticsService.IsEnabled && message.QueryResult?.Releases != null)
|
|
|
|
|
{
|
|
|
|
|
var request = _requestBuilder.Create().Resource("release/push").Build();
|
|
|
|
|
request.Method = HttpMethod.Post;
|
|
|
|
@ -34,7 +37,7 @@ namespace NzbDrone.Core.IndexerSearch
|
|
|
|
|
var body = message.QueryResult.Releases.Select(x => new
|
|
|
|
|
{
|
|
|
|
|
Title = x.Title,
|
|
|
|
|
Categories = x.Categories.Where(c => c.Id < 10000).Select(c => c.Id),
|
|
|
|
|
Categories = x.Categories?.Where(c => c.Id < 10000).Select(c => c.Id) ?? new List<int>(),
|
|
|
|
|
Protocol = x.DownloadProtocol.ToString(),
|
|
|
|
|
Size = x.Size,
|
|
|
|
|
PublishDate = x.PublishDate
|
|
|
|
|