|
|
|
@ -1,9 +1,12 @@
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Parser
|
|
|
|
|
{
|
|
|
|
|
public static class UserAgentParser
|
|
|
|
|
{
|
|
|
|
|
private static readonly List<string> UserAgentWhiteList = new List<string> { "Radarr", "Sonarr", "Readarr", "Lidarr", "Prowlarr" };
|
|
|
|
|
|
|
|
|
|
private static readonly Regex AppSourceRegex = new Regex(@"(?<agent>.*)\/.*(\(.*\))?",
|
|
|
|
|
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
|
|
|
|
public static string ParseSource(string userAgent)
|
|
|
|
@ -12,7 +15,10 @@ namespace NzbDrone.Core.Parser
|
|
|
|
|
|
|
|
|
|
if (match.Groups["agent"].Success)
|
|
|
|
|
{
|
|
|
|
|
return match.Groups["agent"].Value;
|
|
|
|
|
if (UserAgentWhiteList.Contains(match.Groups["agent"].Value))
|
|
|
|
|
{
|
|
|
|
|
return match.Groups["agent"].Value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "Other";
|
|
|
|
|