aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Model')
-rw-r--r--MediaBrowser.Model/Activity/ActivityLogEntry.cs27
-rw-r--r--MediaBrowser.Model/Branding/BrandingOptions.cs5
-rw-r--r--MediaBrowser.Model/Channels/ChannelInfo.cs32
-rw-r--r--MediaBrowser.Model/Entities/JsonLowerCaseConverter.cs29
-rw-r--r--MediaBrowser.Model/Entities/MediaStream.cs74
-rw-r--r--MediaBrowser.Model/Entities/VirtualFolderInfo.cs1
-rw-r--r--MediaBrowser.Model/MediaBrowser.Model.csproj12
-rw-r--r--MediaBrowser.Model/Properties/AssemblyInfo.cs2
-rw-r--r--MediaBrowser.Model/QuickConnect/QuickConnectResult.cs32
-rw-r--r--MediaBrowser.Model/QuickConnect/QuickConnectState.cs23
-rw-r--r--MediaBrowser.Model/System/SystemInfo.cs1
11 files changed, 73 insertions, 165 deletions
diff --git a/MediaBrowser.Model/Activity/ActivityLogEntry.cs b/MediaBrowser.Model/Activity/ActivityLogEntry.cs
index 1d47ef9f6..f83dde56d 100644
--- a/MediaBrowser.Model/Activity/ActivityLogEntry.cs
+++ b/MediaBrowser.Model/Activity/ActivityLogEntry.cs
@@ -1,14 +1,27 @@
-#nullable disable
-#pragma warning disable CS1591
-
using System;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Model.Activity
{
+ /// <summary>
+ /// An activity log entry.
+ /// </summary>
public class ActivityLogEntry
{
/// <summary>
+ /// Initializes a new instance of the <see cref="ActivityLogEntry"/> class.
+ /// </summary>
+ /// <param name="name">The name.</param>
+ /// <param name="type">The type.</param>
+ /// <param name="userId">The user id.</param>
+ public ActivityLogEntry(string name, string type, Guid userId)
+ {
+ Name = name;
+ Type = type;
+ UserId = userId;
+ }
+
+ /// <summary>
/// Gets or sets the identifier.
/// </summary>
/// <value>The identifier.</value>
@@ -24,13 +37,13 @@ namespace MediaBrowser.Model.Activity
/// Gets or sets the overview.
/// </summary>
/// <value>The overview.</value>
- public string Overview { get; set; }
+ public string? Overview { get; set; }
/// <summary>
/// Gets or sets the short overview.
/// </summary>
/// <value>The short overview.</value>
- public string ShortOverview { get; set; }
+ public string? ShortOverview { get; set; }
/// <summary>
/// Gets or sets the type.
@@ -42,7 +55,7 @@ namespace MediaBrowser.Model.Activity
/// Gets or sets the item identifier.
/// </summary>
/// <value>The item identifier.</value>
- public string ItemId { get; set; }
+ public string? ItemId { get; set; }
/// <summary>
/// Gets or sets the date.
@@ -61,7 +74,7 @@ namespace MediaBrowser.Model.Activity
/// </summary>
/// <value>The user primary image tag.</value>
[Obsolete("UserPrimaryImageTag is not used.")]
- public string UserPrimaryImageTag { get; set; }
+ public string? UserPrimaryImageTag { get; set; }
/// <summary>
/// Gets or sets the log severity.
diff --git a/MediaBrowser.Model/Branding/BrandingOptions.cs b/MediaBrowser.Model/Branding/BrandingOptions.cs
index 5ddf1e7e6..7f19a5b85 100644
--- a/MediaBrowser.Model/Branding/BrandingOptions.cs
+++ b/MediaBrowser.Model/Branding/BrandingOptions.cs
@@ -1,4 +1,3 @@
-#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Branding
@@ -9,12 +8,12 @@ namespace MediaBrowser.Model.Branding
/// Gets or sets the login disclaimer.
/// </summary>
/// <value>The login disclaimer.</value>
- public string LoginDisclaimer { get; set; }
+ public string? LoginDisclaimer { get; set; }
/// <summary>
/// Gets or sets the custom CSS.
/// </summary>
/// <value>The custom CSS.</value>
- public string CustomCss { get; set; }
+ public string? CustomCss { get; set; }
}
}
diff --git a/MediaBrowser.Model/Channels/ChannelInfo.cs b/MediaBrowser.Model/Channels/ChannelInfo.cs
deleted file mode 100644
index f2432aaeb..000000000
--- a/MediaBrowser.Model/Channels/ChannelInfo.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-#nullable disable
-#pragma warning disable CS1591
-
-namespace MediaBrowser.Model.Channels
-{
- public class ChannelInfo
- {
- /// <summary>
- /// Gets or sets the name.
- /// </summary>
- /// <value>The name.</value>
- public string Name { get; set; }
-
- /// <summary>
- /// Gets or sets the identifier.
- /// </summary>
- /// <value>The identifier.</value>
- public string Id { get; set; }
-
- /// <summary>
- /// Gets or sets the home page URL.
- /// </summary>
- /// <value>The home page URL.</value>
- public string HomePageUrl { get; set; }
-
- /// <summary>
- /// Gets or sets the features.
- /// </summary>
- /// <value>The features.</value>
- public ChannelFeatures Features { get; set; }
- }
-}
diff --git a/MediaBrowser.Model/Entities/JsonLowerCaseConverter.cs b/MediaBrowser.Model/Entities/JsonLowerCaseConverter.cs
deleted file mode 100644
index 7c627f0e3..000000000
--- a/MediaBrowser.Model/Entities/JsonLowerCaseConverter.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-#nullable disable
-// THIS IS A HACK
-// TODO: @bond Move to separate project
-
-using System;
-using System.Text.Json;
-using System.Text.Json.Serialization;
-
-namespace MediaBrowser.Model.Entities
-{
- /// <summary>
- /// Converts an object to a lowercase string.
- /// </summary>
- /// <typeparam name="T">The object type.</typeparam>
- public class JsonLowerCaseConverter<T> : JsonConverter<T>
- {
- /// <inheritdoc />
- public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
- {
- return JsonSerializer.Deserialize<T>(ref reader, options);
- }
-
- /// <inheritdoc />
- public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
- {
- writer.WriteStringValue(value?.ToString().ToLowerInvariant());
- }
- }
-}
diff --git a/MediaBrowser.Model/Entities/MediaStream.cs b/MediaBrowser.Model/Entities/MediaStream.cs
index c67f30d04..9653a8ece 100644
--- a/MediaBrowser.Model/Entities/MediaStream.cs
+++ b/MediaBrowser.Model/Entities/MediaStream.cs
@@ -469,64 +469,30 @@ namespace MediaBrowser.Model.Entities
/// <value><c>true</c> if this instance is anamorphic; otherwise, <c>false</c>.</value>
public bool? IsAnamorphic { get; set; }
- private string GetResolutionText()
+ internal string GetResolutionText()
{
- var i = this;
-
- if (i.Width.HasValue && i.Height.HasValue)
+ if (!Width.HasValue || !Height.HasValue)
{
- var width = i.Width.Value;
- var height = i.Height.Value;
-
- if (width >= 3800 || height >= 2000)
- {
- return "4K";
- }
-
- if (width >= 2500)
- {
- if (i.IsInterlaced)
- {
- return "1440i";
- }
-
- return "1440p";
- }
-
- if (width >= 1900 || height >= 1000)
- {
- if (i.IsInterlaced)
- {
- return "1080i";
- }
-
- return "1080p";
- }
-
- if (width >= 1260 || height >= 700)
- {
- if (i.IsInterlaced)
- {
- return "720i";
- }
-
- return "720p";
- }
-
- if (width >= 700 || height >= 440)
- {
- if (i.IsInterlaced)
- {
- return "480i";
- }
-
- return "480p";
- }
-
- return "SD";
+ return null;
}
- return null;
+ return Width switch
+ {
+ <= 720 when Height <= 480 => IsInterlaced ? "480i" : "480p",
+ // 720x576 (PAL) (768 when rescaled for square pixels)
+ <= 768 when Height <= 576 => IsInterlaced ? "576i" : "576p",
+ // 960x540 (sometimes 544 which is multiple of 16)
+ <= 960 when Height <= 544 => IsInterlaced ? "540i" : "540p",
+ // 1280x720
+ <= 1280 when Height <= 962 => IsInterlaced ? "720i" : "720p",
+ // 1920x1080
+ <= 1920 when Height <= 1440 => IsInterlaced ? "1080i" : "1080p",
+ // 4K
+ <= 4096 when Height <= 3072 => "4K",
+ // 8K
+ <= 8192 when Height <= 6144 => "8K",
+ _ => null
+ };
}
public static bool IsTextFormat(string format)
diff --git a/MediaBrowser.Model/Entities/VirtualFolderInfo.cs b/MediaBrowser.Model/Entities/VirtualFolderInfo.cs
index 8fed392b9..2b2bda12c 100644
--- a/MediaBrowser.Model/Entities/VirtualFolderInfo.cs
+++ b/MediaBrowser.Model/Entities/VirtualFolderInfo.cs
@@ -3,6 +3,7 @@
using System;
using System.Text.Json.Serialization;
+using Jellyfin.Extensions.Json.Converters;
using MediaBrowser.Model.Configuration;
namespace MediaBrowser.Model.Entities
diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj
index 4db99f0b0..a371afc2c 100644
--- a/MediaBrowser.Model/MediaBrowser.Model.csproj
+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj
@@ -17,14 +17,15 @@
<TargetFramework>net5.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
- <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
- <Nullable>enable</Nullable>
- <!-- <AnalysisMode>AllEnabledByDefault</AnalysisMode> -->
- <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
+ <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ </PropertyGroup>
+
+ <PropertyGroup Condition=" '$(Configuration)' == 'Release'">
+ <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Stability)'=='Unstable'">
@@ -50,7 +51,8 @@
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\Jellyfin.Data\Jellyfin.Data.csproj" />
+ <ProjectReference Include="../Jellyfin.Data/Jellyfin.Data.csproj" />
+ <ProjectReference Include="../src/Jellyfin.Extensions/Jellyfin.Extensions.csproj" />
</ItemGroup>
</Project>
diff --git a/MediaBrowser.Model/Properties/AssemblyInfo.cs b/MediaBrowser.Model/Properties/AssemblyInfo.cs
index f99e9ece9..e50baf604 100644
--- a/MediaBrowser.Model/Properties/AssemblyInfo.cs
+++ b/MediaBrowser.Model/Properties/AssemblyInfo.cs
@@ -1,5 +1,6 @@
using System.Reflection;
using System.Resources;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
@@ -14,6 +15,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
+[assembly: InternalsVisibleTo("Jellyfin.Model.Tests")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
diff --git a/MediaBrowser.Model/QuickConnect/QuickConnectResult.cs b/MediaBrowser.Model/QuickConnect/QuickConnectResult.cs
index 0fa40b6a7..d180d2986 100644
--- a/MediaBrowser.Model/QuickConnect/QuickConnectResult.cs
+++ b/MediaBrowser.Model/QuickConnect/QuickConnectResult.cs
@@ -3,38 +3,46 @@ using System;
namespace MediaBrowser.Model.QuickConnect
{
/// <summary>
- /// Stores the result of an incoming quick connect request.
+ /// Stores the state of an quick connect request.
/// </summary>
public class QuickConnectResult
{
/// <summary>
- /// Gets a value indicating whether this request is authorized.
+ /// Initializes a new instance of the <see cref="QuickConnectResult"/> class.
/// </summary>
- public bool Authenticated => !string.IsNullOrEmpty(Authentication);
+ /// <param name="secret">The secret used to query the request state.</param>
+ /// <param name="code">The code used to allow the request.</param>
+ /// <param name="dateAdded">The time when the request was created.</param>
+ public QuickConnectResult(string secret, string code, DateTime dateAdded)
+ {
+ Secret = secret;
+ Code = code;
+ DateAdded = dateAdded;
+ }
/// <summary>
- /// Gets or sets the secret value used to uniquely identify this request. Can be used to retrieve authentication information.
+ /// Gets a value indicating whether this request is authorized.
/// </summary>
- public string? Secret { get; set; }
+ public bool Authenticated => Authentication != null;
/// <summary>
- /// Gets or sets the user facing code used so the user can quickly differentiate this request from others.
+ /// Gets the secret value used to uniquely identify this request. Can be used to retrieve authentication information.
/// </summary>
- public string? Code { get; set; }
+ public string Secret { get; }
/// <summary>
- /// Gets or sets the private access token.
+ /// Gets the user facing code used so the user can quickly differentiate this request from others.
/// </summary>
- public string? Authentication { get; set; }
+ public string Code { get; }
/// <summary>
- /// Gets or sets an error message.
+ /// Gets or sets the private access token.
/// </summary>
- public string? Error { get; set; }
+ public Guid? Authentication { get; set; }
/// <summary>
/// Gets or sets the DateTime that this request was created.
/// </summary>
- public DateTime? DateAdded { get; set; }
+ public DateTime DateAdded { get; set; }
}
}
diff --git a/MediaBrowser.Model/QuickConnect/QuickConnectState.cs b/MediaBrowser.Model/QuickConnect/QuickConnectState.cs
deleted file mode 100644
index f1074f25f..000000000
--- a/MediaBrowser.Model/QuickConnect/QuickConnectState.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-namespace MediaBrowser.Model.QuickConnect
-{
- /// <summary>
- /// Quick connect state.
- /// </summary>
- public enum QuickConnectState
- {
- /// <summary>
- /// This feature has not been opted into and is unavailable until the server administrator chooses to opt-in.
- /// </summary>
- Unavailable = 0,
-
- /// <summary>
- /// The feature is enabled for use on the server but is not currently accepting connection requests.
- /// </summary>
- Available = 1,
-
- /// <summary>
- /// The feature is actively accepting connection requests.
- /// </summary>
- Active = 2
- }
-}
diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs
index d75ae91c0..e45b2f33a 100644
--- a/MediaBrowser.Model/System/SystemInfo.cs
+++ b/MediaBrowser.Model/System/SystemInfo.cs
@@ -130,6 +130,7 @@ namespace MediaBrowser.Model.System
/// Gets or sets a value indicating whether this instance has update available.
/// </summary>
/// <value><c>true</c> if this instance has update available; otherwise, <c>false</c>.</value>
+ [Obsolete("This should be handled by the package manager")]
public bool HasUpdateAvailable { get; set; }
public FFmpegLocation EncoderLocation { get; set; }