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

Update internal versioning and user agents.
This commit is contained in:
Andrew Rabert 2019-01-19 21:08:35 -05:00 committed by GitHub
commit 469590c9c5
22 changed files with 70 additions and 55 deletions

1
.gitignore vendored
View File

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

View File

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

View File

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

View File

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

View File

@ -164,7 +164,7 @@ namespace Emby.Dlna.PlayTo
string deviceName = null; 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(); var controller = sessionInfo.SessionControllers.OfType<PlayToController>().FirstOrDefault();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -71,6 +71,18 @@ namespace MediaBrowser.Common
/// <value>The application version.</value> /// <value>The application version.</value>
Version ApplicationVersion { get; } 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> /// <summary>
/// Gets or sets a value indicating whether this instance can self update. /// Gets or sets a value indicating whether this instance can self update.
/// </summary> /// </summary>

View File

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

View File

@ -16,6 +16,15 @@ namespace MediaBrowser.Model.System
/// <value>The display name of the operating system.</value> /// <value>The display name of the operating system.</value>
public string OperatingSystemDisplayName { get; set; } 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; } public string PackageName { get; set; }
/// <summary> /// <summary>

View File

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

View File

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

View File

@ -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"), () => 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(); throw new ResourceNotFoundException();
@ -342,7 +342,7 @@ namespace MediaBrowser.WebDashboard.Api
cacheDuration = TimeSpan.FromDays(365); 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 // html gets modified on the fly
if (contentType.StartsWith("text/html", StringComparison.OrdinalIgnoreCase)) 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) private Task<Stream> GetResourceStream(string basePath, string virtualPath, string localizationCulture)
{ {
return GetPackageCreator(basePath) return GetPackageCreator(basePath)
.GetResource(virtualPath, null, localizationCulture, _appHost.ApplicationVersion.ToString()); .GetResource(virtualPath, null, localizationCulture, _appHost.ApplicationSemanticVersion);
} }
private PackageCreator GetPackageCreator(string basePath) private PackageCreator GetPackageCreator(string basePath)
@ -400,7 +400,7 @@ namespace MediaBrowser.WebDashboard.Api
CopyDirectory(inputPath, targetPath); CopyDirectory(inputPath, targetPath);
} }
var appVersion = _appHost.ApplicationVersion.ToString(); var appVersion = _appHost.ApplicationSemanticVersion;
await DumpHtml(packageCreator, inputPath, targetPath, mode, appVersion); await DumpHtml(packageCreator, inputPath, targetPath, mode, appVersion);

View File

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

View File

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

View File

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