You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Common.Http
|
|
|
|
|
{
|
|
|
|
|
public interface IUserAgentBuilder
|
|
|
|
|
{
|
|
|
|
|
string GetUserAgent(bool simplified = false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class UserAgentBuilder : IUserAgentBuilder
|
|
|
|
|
{
|
|
|
|
|
private readonly string _userAgentSimplified;
|
|
|
|
|
private readonly string _userAgent;
|
|
|
|
|
|
|
|
|
|
public string GetUserAgent(bool simplified)
|
|
|
|
|
{
|
|
|
|
|
if (simplified)
|
|
|
|
|
{
|
|
|
|
|
return _userAgentSimplified;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _userAgent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UserAgentBuilder(IOsInfo osInfo)
|
|
|
|
|
{
|
|
|
|
|
var osName = OsInfo.Os.ToString();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(osInfo.Name))
|
|
|
|
|
{
|
|
|
|
|
osName = osInfo.Name.ToLower();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var osVersion = osInfo.Version?.ToLower();
|
|
|
|
|
|
|
|
|
|
_userAgent = $"Lidarr/{BuildInfo.Version} ({osName} {osVersion})";
|
|
|
|
|
_userAgentSimplified = $"Lidarr/{BuildInfo.Version.ToString(2)}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|