Added BuildInfo.AppName to centralize 'Sonarr'

This commit is contained in:
Taloth Saldono 2019-08-24 22:43:33 +02:00
parent c89ff93be4
commit e126c45fb3
11 changed files with 21 additions and 15 deletions

View File

@ -27,6 +27,8 @@ namespace NzbDrone.Common.EnvironmentInfo
Release = $"{Version}-{Branch}"; Release = $"{Version}-{Branch}";
} }
public static string AppName { get; } = "Sonarr";
public static Version Version { get; } public static Version Version { get; }
public static String Branch { get; } public static String Branch { get; }
public static string Release { get; } public static string Release { get; }

View File

@ -24,7 +24,7 @@ namespace NzbDrone.Common.Http
public HttpProvider(Logger logger) public HttpProvider(Logger logger)
{ {
_logger = logger; _logger = logger;
_userAgent = string.Format("Sonarr {0}", BuildInfo.Version); _userAgent = $"{BuildInfo.AppName}/{BuildInfo.Version.ToString(2)}";
ServicePointManager.Expect100Continue = false; ServicePointManager.Expect100Continue = false;
} }

View File

@ -33,8 +33,8 @@ namespace NzbDrone.Common.Http
var osVersion = osInfo.Version?.ToLower(); var osVersion = osInfo.Version?.ToLower();
_userAgent = $"Sonarr/{BuildInfo.Version} ({osName} {osVersion})"; _userAgent = $"{BuildInfo.AppName}/{BuildInfo.Version} ({osName} {osVersion})";
_userAgentSimplified = $"Sonarr/{BuildInfo.Version.ToString(2)}"; _userAgentSimplified = $"{BuildInfo.AppName}/{BuildInfo.Version.ToString(2)}";
} }
} }
} }

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http; using NzbDrone.Common.Http;
using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.IndexerSearch.Definitions;
@ -114,7 +115,7 @@ namespace NzbDrone.Core.Indexers.Rarbg
requestBuilder.AddQueryParam("limit", "100"); requestBuilder.AddQueryParam("limit", "100");
requestBuilder.AddQueryParam("token", _tokenProvider.GetToken(Settings)); requestBuilder.AddQueryParam("token", _tokenProvider.GetToken(Settings));
requestBuilder.AddQueryParam("format", "json_extended"); requestBuilder.AddQueryParam("format", "json_extended");
requestBuilder.AddQueryParam("app_id", "Sonarr"); requestBuilder.AddQueryParam("app_id", BuildInfo.AppName);
yield return new IndexerRequest(requestBuilder.Build()); yield return new IndexerRequest(requestBuilder.Build());
} }

View File

@ -4,6 +4,7 @@ using FluentValidation.Results;
using NLog; using NLog;
using RestSharp; using RestSharp;
using NzbDrone.Core.Rest; using NzbDrone.Core.Rest;
using NzbDrone.Common.EnvironmentInfo;
namespace NzbDrone.Core.Notifications.Boxcar namespace NzbDrone.Core.Notifications.Boxcar
{ {
@ -75,7 +76,7 @@ namespace NzbDrone.Core.Notifications.Boxcar
request.AddParameter("user_credentials", settings.Token); request.AddParameter("user_credentials", settings.Token);
request.AddParameter("notification[title]", title); request.AddParameter("notification[title]", title);
request.AddParameter("notification[long_message]", message); request.AddParameter("notification[long_message]", message);
request.AddParameter("notification[source_name]", "Sonarr"); request.AddParameter("notification[source_name]", BuildInfo.AppName);
request.AddParameter("notification[icon_url]", "https://raw.githubusercontent.com/Sonarr/Sonarr/7818f0c59b787312f0bcbc5c0eafc3c9dd7e5451/Logo/64.png"); request.AddParameter("notification[icon_url]", "https://raw.githubusercontent.com/Sonarr/Sonarr/7818f0c59b787312f0bcbc5c0eafc3c9dd7e5451/Logo/64.png");
client.ExecuteAndValidate(request); client.ExecuteAndValidate(request);

View File

@ -43,10 +43,10 @@ namespace NzbDrone.Core.Notifications.Plex.PlexTv
var requestBuilder = new HttpRequestBuilder("https://plex.tv") var requestBuilder = new HttpRequestBuilder("https://plex.tv")
.Accept(HttpAccept.Json) .Accept(HttpAccept.Json)
.AddQueryParam("X-Plex-Client-Identifier", clientIdentifier) .AddQueryParam("X-Plex-Client-Identifier", clientIdentifier)
.AddQueryParam("X-Plex-Product", "Sonarr") .AddQueryParam("X-Plex-Product", BuildInfo.AppName)
.AddQueryParam("X-Plex-Platform", "Windows") .AddQueryParam("X-Plex-Platform", "Windows")
.AddQueryParam("X-Plex-Platform-Version", "7") .AddQueryParam("X-Plex-Platform-Version", "7")
.AddQueryParam("X-Plex-Device-Name", "Sonarr") .AddQueryParam("X-Plex-Device-Name", BuildInfo.AppName)
.AddQueryParam("X-Plex-Version", BuildInfo.Version.ToString()); .AddQueryParam("X-Plex-Version", BuildInfo.Version.ToString());
return requestBuilder; return requestBuilder;

View File

@ -31,10 +31,10 @@ namespace NzbDrone.Core.Notifications.Plex.PlexTv
var requestBuilder = new HttpRequestBuilder("https://plex.tv/api/v2/pins") var requestBuilder = new HttpRequestBuilder("https://plex.tv/api/v2/pins")
.Accept(HttpAccept.Json) .Accept(HttpAccept.Json)
.AddQueryParam("X-Plex-Client-Identifier", clientIdentifier) .AddQueryParam("X-Plex-Client-Identifier", clientIdentifier)
.AddQueryParam("X-Plex-Product", "Sonarr") .AddQueryParam("X-Plex-Product", BuildInfo.AppName)
.AddQueryParam("X-Plex-Platform", "Windows") .AddQueryParam("X-Plex-Platform", "Windows")
.AddQueryParam("X-Plex-Platform-Version", "7") .AddQueryParam("X-Plex-Platform-Version", "7")
.AddQueryParam("X-Plex-Device-Name", "Sonarr") .AddQueryParam("X-Plex-Device-Name", BuildInfo.AppName)
.AddQueryParam("X-Plex-Version", BuildInfo.Version.ToString()) .AddQueryParam("X-Plex-Version", BuildInfo.Version.ToString())
.AddQueryParam("strong", true); .AddQueryParam("strong", true);
@ -57,7 +57,7 @@ namespace NzbDrone.Core.Notifications.Plex.PlexTv
.AddQueryParam("clientID", clientIdentifier) .AddQueryParam("clientID", clientIdentifier)
.AddQueryParam("forwardUrl", callbackUrl) .AddQueryParam("forwardUrl", callbackUrl)
.AddQueryParam("code", pinCode) .AddQueryParam("code", pinCode)
.AddQueryParam("context[device][product]", "Sonarr") .AddQueryParam("context[device][product]", BuildInfo.AppName)
.AddQueryParam("context[device][platform]", "Windows") .AddQueryParam("context[device][platform]", "Windows")
.AddQueryParam("context[device][platformVersion]", "7") .AddQueryParam("context[device][platformVersion]", "7")
.AddQueryParam("context[device][version]", BuildInfo.Version.ToString()); .AddQueryParam("context[device][version]", BuildInfo.Version.ToString());

View File

@ -155,10 +155,10 @@ namespace NzbDrone.Core.Notifications.Plex.Server
var requestBuilder = new HttpRequestBuilder($"{scheme}://{settings.Host}:{settings.Port}") var requestBuilder = new HttpRequestBuilder($"{scheme}://{settings.Host}:{settings.Port}")
.Accept(HttpAccept.Json) .Accept(HttpAccept.Json)
.AddQueryParam("X-Plex-Client-Identifier", _configService.PlexClientIdentifier) .AddQueryParam("X-Plex-Client-Identifier", _configService.PlexClientIdentifier)
.AddQueryParam("X-Plex-Product", "Sonarr") .AddQueryParam("X-Plex-Product", BuildInfo.AppName)
.AddQueryParam("X-Plex-Platform", "Windows") .AddQueryParam("X-Plex-Platform", "Windows")
.AddQueryParam("X-Plex-Platform-Version", "7") .AddQueryParam("X-Plex-Platform-Version", "7")
.AddQueryParam("X-Plex-Device-Name", "Sonarr") .AddQueryParam("X-Plex-Device-Name", BuildInfo.AppName)
.AddQueryParam("X-Plex-Version", BuildInfo.Version.ToString()); .AddQueryParam("X-Plex-Version", BuildInfo.Version.ToString());
if (settings.AuthToken.IsNotNullOrWhiteSpace()) if (settings.AuthToken.IsNotNullOrWhiteSpace())

View File

@ -1,6 +1,7 @@
using System; using System;
using FluentValidation.Results; using FluentValidation.Results;
using NLog; using NLog;
using NzbDrone.Common.EnvironmentInfo;
using Prowlin; using Prowlin;
namespace NzbDrone.Core.Notifications.Prowl namespace NzbDrone.Core.Notifications.Prowl
@ -26,7 +27,7 @@ namespace NzbDrone.Core.Notifications.Prowl
{ {
var notification = new Prowlin.Notification var notification = new Prowlin.Notification
{ {
Application = "Sonarr", Application = BuildInfo.AppName,
Description = message, Description = message,
Event = title, Event = title,
Priority = priority, Priority = priority,

View File

@ -9,7 +9,7 @@ namespace NzbDrone.Core.Rest
{ {
var restClient = new RestClient(baseUrl) var restClient = new RestClient(baseUrl)
{ {
UserAgent = $"Sonarr/{BuildInfo.Version} ({OsInfo.Os})" UserAgent = $"{BuildInfo.AppName}/{BuildInfo.Version} ({OsInfo.Os})"
}; };

View File

@ -8,6 +8,7 @@ using Microsoft.Owin.Hosting.Engine;
using Microsoft.Owin.Hosting.Services; using Microsoft.Owin.Hosting.Services;
using Microsoft.Owin.Hosting.Tracing; using Microsoft.Owin.Hosting.Tracing;
using NLog; using NLog;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Host.Owin.MiddleWare; using NzbDrone.Host.Owin.MiddleWare;
using Owin; using Owin;
@ -70,7 +71,7 @@ namespace NzbDrone.Host.Owin
private void BuildApp(IAppBuilder appBuilder) private void BuildApp(IAppBuilder appBuilder)
{ {
appBuilder.Properties["host.AppName"] = "Sonarr"; appBuilder.Properties["host.AppName"] = BuildInfo.AppName;
foreach (var middleWare in _owinMiddleWares.OrderBy(c => c.Order)) foreach (var middleWare in _owinMiddleWares.OrderBy(c => c.Order))
{ {