mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Parse and Store App from UA for Nab Requests Stats
This commit is contained in:
@@ -92,6 +92,7 @@ namespace NzbDrone.Core.History
|
|||||||
history.Data.Add("ElapsedTime", message.Time.ToString());
|
history.Data.Add("ElapsedTime", message.Time.ToString());
|
||||||
history.Data.Add("Query", message.Query.SearchTerm ?? string.Empty);
|
history.Data.Add("Query", message.Query.SearchTerm ?? string.Empty);
|
||||||
history.Data.Add("Categories", string.Join(",", message.Query.Categories) ?? string.Empty);
|
history.Data.Add("Categories", string.Join(",", message.Query.Categories) ?? string.Empty);
|
||||||
|
history.Data.Add("Source", message.Query.Source ?? string.Empty);
|
||||||
history.Data.Add("Successful", message.Successful.ToString());
|
history.Data.Add("Successful", message.Successful.ToString());
|
||||||
history.Data.Add("QueryResults", message.Results.HasValue ? message.Results.ToString() : null);
|
history.Data.Add("QueryResults", message.Results.HasValue ? message.Results.ToString() : null);
|
||||||
|
|
||||||
|
@@ -19,5 +19,6 @@ namespace NzbDrone.Core.IndexerSearch.Definitions
|
|||||||
public string SearchType { get; set; }
|
public string SearchType { get; set; }
|
||||||
public int? Limit { get; set; }
|
public int? Limit { get; set; }
|
||||||
public int? Offset { get; set; }
|
public int? Offset { get; set; }
|
||||||
|
public string Source { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,5 +26,6 @@ namespace NzbDrone.Core.IndexerSearch
|
|||||||
public string author { get; set; }
|
public string author { get; set; }
|
||||||
public string title { get; set; }
|
public string title { get; set; }
|
||||||
public string configured { get; set; }
|
public string configured { get; set; }
|
||||||
|
public string source { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -121,6 +121,7 @@ namespace NzbDrone.Core.IndexerSearch
|
|||||||
spec.SearchType = query.t;
|
spec.SearchType = query.t;
|
||||||
spec.Limit = query.limit;
|
spec.Limit = query.limit;
|
||||||
spec.Offset = query.offset;
|
spec.Offset = query.offset;
|
||||||
|
spec.Source = query.source;
|
||||||
|
|
||||||
spec.IndexerIds = indexerIds;
|
spec.IndexerIds = indexerIds;
|
||||||
|
|
||||||
|
21
src/NzbDrone.Core/Parser/UserAgentParser.cs
Normal file
21
src/NzbDrone.Core/Parser/UserAgentParser.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Parser
|
||||||
|
{
|
||||||
|
public static class UserAgentParser
|
||||||
|
{
|
||||||
|
private static readonly Regex AppSourceRegex = new Regex(@"(?<agent>.*)\/.*\(.*\)",
|
||||||
|
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
|
public static string ParseSource(string userAgent)
|
||||||
|
{
|
||||||
|
var match = AppSourceRegex.Match(userAgent);
|
||||||
|
|
||||||
|
if (match.Groups["agent"].Success)
|
||||||
|
{
|
||||||
|
return match.Groups["agent"].Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Other";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -4,6 +4,7 @@ using Nancy.ModelBinding;
|
|||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Indexers;
|
using NzbDrone.Core.Indexers;
|
||||||
using NzbDrone.Core.IndexerSearch;
|
using NzbDrone.Core.IndexerSearch;
|
||||||
|
using NzbDrone.Core.Parser;
|
||||||
using Prowlarr.Http.REST;
|
using Prowlarr.Http.REST;
|
||||||
|
|
||||||
namespace Prowlarr.Api.V1.Indexers
|
namespace Prowlarr.Api.V1.Indexers
|
||||||
@@ -41,6 +42,7 @@ namespace Prowlarr.Api.V1.Indexers
|
|||||||
private object GetNewznabResponse(NewznabRequest request)
|
private object GetNewznabResponse(NewznabRequest request)
|
||||||
{
|
{
|
||||||
var requestType = request.t;
|
var requestType = request.t;
|
||||||
|
request.source = UserAgentParser.ParseSource(Request.Headers.UserAgent);
|
||||||
|
|
||||||
if (requestType.IsNullOrWhiteSpace())
|
if (requestType.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user