浏览代码

Added contact email to user agent

MusicBrainz request a contact email address is supplied in comment section of user agent field.
PloughPuff 6 年之前
父节点
当前提交
d125fbc43d

+ 6 - 0
Emby.Server.Implementations/ApplicationHost.cs

@@ -428,6 +428,12 @@ namespace Emby.Server.Implementations
         /// <value>The application user agent.</value>
         public string ApplicationUserAgent => Name.Replace(' ','-') + "/" + ApplicationVersion;
 
+        /// <summary>
+        /// Gets the email address for use within a comment section of a user agent field.
+        /// Presently used to provide contact information to MusicBrainz service.
+        /// </summary>
+        public string ApplicationUserAgentAddress { get; } = "team@jellyfin.org";
+
         private string _productName;
 
         /// <summary>

+ 6 - 0
MediaBrowser.Common/IApplicationHost.cs

@@ -71,6 +71,12 @@ namespace MediaBrowser.Common
         /// <value>The application user agent.</value>
         string ApplicationUserAgent { get; }
 
+        /// <summary>
+        /// Gets the email address for use within a comment section of a user agent field.
+        /// Presently used to provide contact information to MusicBrainz service.
+        /// </summary>
+        string ApplicationUserAgentAddress { get; }
+
         /// <summary>
         /// Gets the exports.
         /// </summary>

+ 3 - 2
MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs

@@ -1,7 +1,6 @@
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Globalization;
 using System.IO;
 using System.Linq;
 using System.Net;
@@ -735,7 +734,9 @@ namespace MediaBrowser.Providers.Music
             {
                 Url = MusicBrainzBaseUrl.TrimEnd('/') + url,
                 CancellationToken = cancellationToken,
-                UserAgent = _appHost.ApplicationUserAgent,
+                // MusicBrainz request a contact email address is supplied, as comment, in user agent field:
+                // https://musicbrainz.org/doc/XML_Web_Service/Rate_Limiting#User-Agent
+                UserAgent = string.Format("{0} ( {1} )", _appHost.ApplicationUserAgent, _appHost.ApplicationUserAgentAddress),
                 BufferContent = false
             };