2
0
Эх сурвалжийг харах

Merge pull request #508 from EraYaN/api-version-reporting

Update internal versioning and user agents.
Andrew Rabert 6 жил өмнө
parent
commit
469590c9c5

+ 1 - 0
.gitignore

@@ -263,3 +263,4 @@ deployment/**/pkg-dist/
 deployment/**/pkg-dist-tmp/
 deployment/collect-dist/
 
+jellyfin_version.ini

+ 1 - 1
BDInfo/BDInfo.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <ItemGroup>
-    <Compile Include="..\SharedVersion.cs" Link="SharedVersion.cs" />
+    <Compile Include="..\SharedVersion.cs" />
   </ItemGroup>
 
   <ItemGroup>

+ 1 - 1
DvdLib/DvdLib.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <ItemGroup>
-    <Compile Include="..\SharedVersion.cs" Link="SharedVersion.cs" />
+    <Compile Include="..\SharedVersion.cs" />
   </ItemGroup>
 
   <ItemGroup>

+ 1 - 1
Emby.Dlna/Emby.Dlna.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <ItemGroup>
-    <Compile Include="..\SharedVersion.cs" Link="SharedVersion.cs" />
+    <Compile Include="..\SharedVersion.cs" />
   </ItemGroup>
 
   <ItemGroup>

+ 1 - 1
Emby.Dlna/PlayTo/PlayToManager.cs

@@ -164,7 +164,7 @@ namespace Emby.Dlna.PlayTo
 
             string deviceName = null;
 
-            var sessionInfo = _sessionManager.LogSessionActivity("DLNA", _appHost.ApplicationVersion.ToString(), uuid, deviceName, uri.OriginalString, null);
+            var sessionInfo = _sessionManager.LogSessionActivity("DLNA", _appHost.ApplicationSemanticVersion, uuid, deviceName, uri.OriginalString, null);
 
             var controller = sessionInfo.SessionControllers.OfType<PlayToController>().FirstOrDefault();
 

+ 1 - 1
Emby.IsoMounting/IsoMounter/IsoMounter.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <ItemGroup>
-    <Compile Include="..\..\SharedVersion.cs" Link="SharedVersion.cs" />
+    <Compile Include="..\..\SharedVersion.cs" />
   </ItemGroup>
 
   <ItemGroup>

+ 1 - 1
Emby.Naming/Emby.Naming.csproj

@@ -6,7 +6,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <Compile Include="..\SharedVersion.cs" Link="SharedVersion.cs" />
+    <Compile Include="..\SharedVersion.cs" />
   </ItemGroup>
 
   <ItemGroup>

+ 1 - 1
Emby.Notifications/Emby.Notifications.csproj

@@ -6,7 +6,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <Compile Include="..\SharedVersion.cs" Link="SharedVersion.cs" />
+    <Compile Include="..\SharedVersion.cs" />
   </ItemGroup>
 
   <ItemGroup>

+ 24 - 27
Emby.Server.Implementations/ApplicationHost.cs

@@ -429,12 +429,27 @@ namespace Emby.Server.Implementations
             _validAddressResults.Clear();
         }
 
-        private Version _version;
+        private Version _applicationVersion;
         /// <summary>
-        /// Gets the current application version
+        /// Gets the current application server version
         /// </summary>
-        /// <value>The application version.</value>
-        public Version ApplicationVersion => _version ?? (_version = typeof(ApplicationHost).Assembly.GetName().Version);
+        /// <value>The application server version.</value>
+        public Version ApplicationVersion => _applicationVersion ?? (_applicationVersion = typeof(ApplicationHost).Assembly.GetName().Version);
+
+        public string ApplicationSemanticVersion => ApplicationVersion.ToString(3);
+
+        /// <summary>
+        /// Gets the current application server version
+        /// </summary>
+        /// <value>The application server version.</value>
+        public string ApplicationUserAgent => Name.Replace(' ','-') + "/" + ApplicationSemanticVersion;
+
+        private string _productName;
+        /// <summary>
+        /// Gets the current application name
+        /// </summary>
+        /// <value>The application name.</value>
+        public string ApplicationProductName => _productName ?? (_productName = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location).ProductName);
 
         private DeviceId _deviceId;
         public string SystemId
@@ -454,7 +469,7 @@ namespace Emby.Server.Implementations
         /// Gets the name.
         /// </summary>
         /// <value>The name.</value>
-        public string Name => "Emby Server";
+        public string Name => "Jellyfin Server";
 
         private static Tuple<Assembly, string> GetAssembly(Type type)
         {
@@ -1004,26 +1019,7 @@ namespace Emby.Server.Implementations
 
         protected string GetDefaultUserAgent()
         {
-            var name = FormatAttribute(Name);
-
-            return name + "/" + ApplicationVersion;
-        }
-
-        private static string FormatAttribute(string str)
-        {
-            var arr = str.ToCharArray();
-
-            arr = Array.FindAll(arr, (c => (char.IsLetterOrDigit(c)
-                                                  || char.IsWhiteSpace(c))));
-
-            var result = new string(arr);
-
-            if (string.IsNullOrWhiteSpace(result))
-            {
-                result = "Emby";
-            }
-
-            return result;
+            return ApplicationUserAgent;
         }
 
         protected virtual bool SupportsDualModeSockets => true;
@@ -1825,7 +1821,8 @@ namespace Emby.Server.Implementations
             {
                 HasPendingRestart = HasPendingRestart,
                 IsShuttingDown = IsShuttingDown,
-                Version = ApplicationVersion.ToString(),
+                Version = ApplicationSemanticVersion,
+                ProductName = ApplicationProductName,
                 WebSocketPortNumber = HttpPort,
                 CompletedInstallations = InstallationManager.CompletedInstallations.ToArray(),
                 Id = SystemId,
@@ -1871,7 +1868,7 @@ namespace Emby.Server.Implementations
             var wanAddress = await GetWanApiUrl(cancellationToken).ConfigureAwait(false);
             return new PublicSystemInfo
             {
-                Version = ApplicationVersion.ToString(),
+                Version = ApplicationSemanticVersion,
                 Id = SystemId,
                 OperatingSystem = EnvironmentInfo.OperatingSystem.ToString(),
                 WanAddress = wanAddress,

+ 1 - 1
Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs

@@ -38,7 +38,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
             _appHost = appHost;
         }
 
-        private string UserAgent => "Emby/" + _appHost.ApplicationVersion;
+        private string UserAgent => _appHost.ApplicationUserAgent;
 
         private static List<string> GetScheduleRequestDates(DateTime startDateUtc, DateTime endDateUtc)
         {

+ 1 - 1
Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs

@@ -58,7 +58,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
                     Url = url,
                     CancellationToken = cancellationToken,
                     // Some data providers will require a user agent
-                    UserAgent = _appHost.FriendlyName + "/" + _appHost.ApplicationVersion
+                    UserAgent = _appHost.ApplicationSemanticVersion
                 });
             }
             return Task.FromResult(_fileSystem.OpenRead(url));

+ 1 - 1
Emby.XmlTv/Emby.XmlTv/Emby.XmlTv.csproj

@@ -6,7 +6,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <Compile Include="..\..\SharedVersion.cs" Link="SharedVersion.cs" />
+    <Compile Include="..\..\SharedVersion.cs" />
   </ItemGroup>
 
 </Project>

+ 1 - 2
MediaBrowser.Api/Session/SessionsService.cs

@@ -309,8 +309,7 @@ namespace MediaBrowser.Api.Session
                 DateCreated = DateTime.UtcNow,
                 DeviceId = _appHost.SystemId,
                 DeviceName = _appHost.FriendlyName,
-                AppVersion = _appHost.ApplicationVersion.ToString()
-
+                AppVersion = _appHost.ApplicationSemanticVersion
             });
         }
 

+ 12 - 0
MediaBrowser.Common/IApplicationHost.cs

@@ -71,6 +71,18 @@ namespace MediaBrowser.Common
         /// <value>The application version.</value>
         Version ApplicationVersion { get; }
 
+        /// <summary>
+        /// Gets the application semantic version.
+        /// </summary>
+        /// <value>The application semantic version.</value>
+        string ApplicationSemanticVersion { get; }
+
+        /// <summary>
+        /// Gets the application user agent.
+        /// </summary>
+        /// <value>The application user agent.</value>
+        string ApplicationUserAgent { get; }
+
         /// <summary>
         /// Gets or sets a value indicating whether this instance can self update.
         /// </summary>

+ 2 - 2
MediaBrowser.Model/System/PublicSystemInfo.cs

@@ -21,10 +21,10 @@ namespace MediaBrowser.Model.System
         public string ServerName { get; set; }
 
         /// <summary>
-        /// Gets or sets the version.
+        /// Gets or sets the server version.
         /// </summary>
         /// <value>The version.</value>
-        public string Version { get; set; }
+        public string Version { get; set; }        
 
         /// <summary>
         /// Gets or sets the operating sytem.

+ 9 - 0
MediaBrowser.Model/System/SystemInfo.cs

@@ -16,6 +16,15 @@ namespace MediaBrowser.Model.System
         /// <value>The display name of the operating system.</value>
         public string OperatingSystemDisplayName { get; set; }
 
+        /// <summary>
+        /// The product name. This is the AssemblyProduct name.
+        /// </summary>
+        public string ProductName { get; set; }
+
+        /// <summary>
+        /// Get or sets the package name.
+        /// </summary>
+        /// <value>The value of the '-package' command line argument.</value>
         public string PackageName { get; set; }
 
         /// <summary>

+ 1 - 1
MediaBrowser.Providers/Movies/MovieDbProvider.cs

@@ -424,7 +424,7 @@ namespace MediaBrowser.Providers.Movies
             _lastRequestTicks = DateTime.UtcNow.Ticks;
 
             options.BufferContent = true;
-            options.UserAgent = "Emby/" + _appHost.ApplicationVersion;
+            options.UserAgent = _appHost.ApplicationUserAgent;
 
             return await _httpClient.SendAsync(options, "GET").ConfigureAwait(false);
         }

+ 1 - 1
MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs

@@ -742,7 +742,7 @@ namespace MediaBrowser.Providers.Music
             {
                 Url = url,
                 CancellationToken = cancellationToken,
-                UserAgent = _appHost.Name + "/" + _appHost.ApplicationVersion,
+                UserAgent = _appHost.ApplicationUserAgent,
                 BufferContent = throttleMs > 0
             };
 

+ 4 - 4
MediaBrowser.WebDashboard/Api/DashboardService.cs

@@ -205,7 +205,7 @@ namespace MediaBrowser.WebDashboard.Api
                     return _resultFactory.GetStaticResult(Request, plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => Task.FromResult(stream));
                 }
 
-                return _resultFactory.GetStaticResult(Request, plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator(DashboardUIPath).ModifyHtml("dummy.html", stream, null, _appHost.ApplicationVersion.ToString(), null));
+                return _resultFactory.GetStaticResult(Request, plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator(DashboardUIPath).ModifyHtml("dummy.html", stream, null, _appHost.ApplicationSemanticVersion, null));
             }
 
             throw new ResourceNotFoundException();
@@ -342,7 +342,7 @@ namespace MediaBrowser.WebDashboard.Api
                 cacheDuration = TimeSpan.FromDays(365);
             }
 
-            var cacheKey = (_appHost.ApplicationVersion + (localizationCulture ?? string.Empty) + path).GetMD5();
+            var cacheKey = (_appHost.ApplicationSemanticVersion + (localizationCulture ?? string.Empty) + path).GetMD5();
 
             // html gets modified on the fly
             if (contentType.StartsWith("text/html", StringComparison.OrdinalIgnoreCase))
@@ -364,7 +364,7 @@ namespace MediaBrowser.WebDashboard.Api
         private Task<Stream> GetResourceStream(string basePath, string virtualPath, string localizationCulture)
         {
             return GetPackageCreator(basePath)
-                .GetResource(virtualPath, null, localizationCulture, _appHost.ApplicationVersion.ToString());
+                .GetResource(virtualPath, null, localizationCulture, _appHost.ApplicationSemanticVersion);
         }
 
         private PackageCreator GetPackageCreator(string basePath)
@@ -400,7 +400,7 @@ namespace MediaBrowser.WebDashboard.Api
                 CopyDirectory(inputPath, targetPath);
             }
 
-            var appVersion = _appHost.ApplicationVersion.ToString();
+            var appVersion = _appHost.ApplicationSemanticVersion;
 
             await DumpHtml(packageCreator, inputPath, targetPath, mode, appVersion);
 

+ 1 - 4
MediaBrowser.sln

@@ -1,4 +1,3 @@
-
 Microsoft Visual Studio Solution File, Format Version 12.00
 # Visual Studio 15
 VisualStudioVersion = 15.0.26730.3
@@ -58,6 +57,7 @@ EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{41093F42-C7CC-4D07-956B-6182CBEDE2EC}"
 	ProjectSection(SolutionItems) = preProject
 		.editorconfig = .editorconfig
+		SharedVersion.cs = SharedVersion.cs
 	EndProjectSection
 EndProject
 Global
@@ -178,12 +178,9 @@ Global
 		SolutionGuid = {3448830C-EBDC-426C-85CD-7BBB9651A7FE}
 	EndGlobalSection
 	GlobalSection(AutomaticVersions) = postSolution
-		PrimaryVersionType = AssemblyFileVersionAttribute
 		UpdateAssemblyVersion = True
 		UpdateAssemblyFileVersion = True
 		UpdateAssemblyInfoVersion = True
-		ShouldCreateLogs = True
-		AdvancedSettingsExpanded = True
 		AssemblyVersionSettings = None.None.None.None
 		AssemblyFileVersionSettings = None.None.None.None
 		AssemblyInfoVersionSettings = None.None.None.None

+ 2 - 2
OpenSubtitlesHandler/Properties/AssemblyInfo.cs

@@ -20,5 +20,5 @@ using System.Runtime.InteropServices;
 // COM, set the ComVisible attribute to true on that type.
 [assembly: ComVisible(false)]
 
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.0.3.0")]
+[assembly: AssemblyFileVersion("2019.1.20.3")]

+ 2 - 2
RSSDP/Properties/AssemblyInfo.cs

@@ -20,5 +20,5 @@ using System.Runtime.InteropServices;
 // COM, set the ComVisible attribute to true on that type.
 [assembly: ComVisible(false)]
 
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.0.3.0")]
+[assembly: AssemblyFileVersion("2019.1.20.3")]