aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model/Entities
diff options
context:
space:
mode:
authorNyanmisaka <nst799610810@gmail.com>2024-07-23 15:37:33 +0800
committerGitHub <noreply@github.com>2024-07-23 15:37:33 +0800
commit00088c295445fe2710cae468e1b09f98a32e40a5 (patch)
tree77614fb434409bc2ddf3d7d0b5830339a6374bfb /MediaBrowser.Model/Entities
parentdeb36eeedaba2f1421b92d290d85d45bfe48d1f5 (diff)
parent19dca018b2604ff8666cabaf9d0f9c8974572756 (diff)
Merge branch 'master' into fix-hwa-video-rotation
Diffstat (limited to 'MediaBrowser.Model/Entities')
-rw-r--r--MediaBrowser.Model/Entities/CollectionTypeOptions.cs59
-rw-r--r--MediaBrowser.Model/Entities/IHasShares.cs6
-rw-r--r--MediaBrowser.Model/Entities/MediaStream.cs60
-rw-r--r--MediaBrowser.Model/Entities/PlaylistUserPermissions.cs30
-rw-r--r--MediaBrowser.Model/Entities/ProviderIdsExtensions.cs60
-rw-r--r--MediaBrowser.Model/Entities/Share.cs17
-rw-r--r--MediaBrowser.Model/Entities/VirtualFolderInfo.cs3
7 files changed, 172 insertions, 63 deletions
diff --git a/MediaBrowser.Model/Entities/CollectionTypeOptions.cs b/MediaBrowser.Model/Entities/CollectionTypeOptions.cs
index e1894d84a..fc4cfdd66 100644
--- a/MediaBrowser.Model/Entities/CollectionTypeOptions.cs
+++ b/MediaBrowser.Model/Entities/CollectionTypeOptions.cs
@@ -1,16 +1,49 @@
-#pragma warning disable CS1591
+#pragma warning disable SA1300 // Lowercase required for backwards compat.
-namespace MediaBrowser.Model.Entities
+namespace MediaBrowser.Model.Entities;
+
+/// <summary>
+/// The collection type options.
+/// </summary>
+public enum CollectionTypeOptions
{
- public enum CollectionTypeOptions
- {
- Movies = 0,
- TvShows = 1,
- Music = 2,
- MusicVideos = 3,
- HomeVideos = 4,
- BoxSets = 5,
- Books = 6,
- Mixed = 7
- }
+ /// <summary>
+ /// Movies.
+ /// </summary>
+ movies = 0,
+
+ /// <summary>
+ /// TV Shows.
+ /// </summary>
+ tvshows = 1,
+
+ /// <summary>
+ /// Music.
+ /// </summary>
+ music = 2,
+
+ /// <summary>
+ /// Music Videos.
+ /// </summary>
+ musicvideos = 3,
+
+ /// <summary>
+ /// Home Videos (and Photos).
+ /// </summary>
+ homevideos = 4,
+
+ /// <summary>
+ /// Box Sets.
+ /// </summary>
+ boxsets = 5,
+
+ /// <summary>
+ /// Books.
+ /// </summary>
+ books = 6,
+
+ /// <summary>
+ /// Mixed Movies and TV Shows.
+ /// </summary>
+ mixed = 7
}
diff --git a/MediaBrowser.Model/Entities/IHasShares.cs b/MediaBrowser.Model/Entities/IHasShares.cs
index b34d1a037..8c4ba6c42 100644
--- a/MediaBrowser.Model/Entities/IHasShares.cs
+++ b/MediaBrowser.Model/Entities/IHasShares.cs
@@ -1,4 +1,6 @@
-namespace MediaBrowser.Model.Entities;
+using System.Collections.Generic;
+
+namespace MediaBrowser.Model.Entities;
/// <summary>
/// Interface for access to shares.
@@ -8,5 +10,5 @@ public interface IHasShares
/// <summary>
/// Gets or sets the shares.
/// </summary>
- Share[] Shares { get; set; }
+ IReadOnlyList<PlaylistUserPermissions> Shares { get; set; }
}
diff --git a/MediaBrowser.Model/Entities/MediaStream.cs b/MediaBrowser.Model/Entities/MediaStream.cs
index fa09902e5..844214fae 100644
--- a/MediaBrowser.Model/Entities/MediaStream.cs
+++ b/MediaBrowser.Model/Entities/MediaStream.cs
@@ -7,6 +7,7 @@ using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
+using System.Text.Json.Serialization;
using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Model.Dlna;
@@ -273,13 +274,13 @@ namespace MediaBrowser.Model.Entities
attributes.Add(StringHelper.FirstToUpper(fullLanguage ?? Language));
}
- if (!string.IsNullOrEmpty(Codec) && !string.Equals(Codec, "dca", StringComparison.OrdinalIgnoreCase) && !string.Equals(Codec, "dts", StringComparison.OrdinalIgnoreCase))
+ if (!string.IsNullOrEmpty(Profile) && !string.Equals(Profile, "lc", StringComparison.OrdinalIgnoreCase))
{
- attributes.Add(AudioCodec.GetFriendlyName(Codec));
+ attributes.Add(Profile);
}
- else if (!string.IsNullOrEmpty(Profile) && !string.Equals(Profile, "lc", StringComparison.OrdinalIgnoreCase))
+ else if (!string.IsNullOrEmpty(Codec))
{
- attributes.Add(Profile);
+ attributes.Add(AudioCodec.GetFriendlyName(Codec));
}
if (!string.IsNullOrEmpty(ChannelLayout))
@@ -591,6 +592,33 @@ namespace MediaBrowser.Model.Entities
}
}
+ [JsonIgnore]
+ public bool IsPgsSubtitleStream
+ {
+ get
+ {
+ if (Type != MediaStreamType.Subtitle)
+ {
+ return false;
+ }
+
+ if (string.IsNullOrEmpty(Codec) && !IsExternal)
+ {
+ return false;
+ }
+
+ return IsPgsFormat(Codec);
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether this is a subtitle steam that is extractable by ffmpeg.
+ /// All text-based and pgs subtitles can be extracted.
+ /// </summary>
+ /// <value><c>true</c> if this is a extractable subtitle steam otherwise, <c>false</c>.</value>
+ [JsonIgnore]
+ public bool IsExtractableSubtitleStream => IsTextSubtitleStream || IsPgsSubtitleStream;
+
/// <summary>
/// Gets or sets a value indicating whether [supports external stream].
/// </summary>
@@ -662,14 +690,22 @@ namespace MediaBrowser.Model.Entities
{
string codec = format ?? string.Empty;
- // sub = external .sub file
+ // microdvd and dvdsub/vobsub share the ".sub" file extension, but it's text-based.
+
+ return codec.Contains("microdvd", StringComparison.OrdinalIgnoreCase)
+ || (!codec.Contains("pgs", StringComparison.OrdinalIgnoreCase)
+ && !codec.Contains("dvdsub", StringComparison.OrdinalIgnoreCase)
+ && !codec.Contains("dvbsub", StringComparison.OrdinalIgnoreCase)
+ && !string.Equals(codec, "sup", StringComparison.OrdinalIgnoreCase)
+ && !string.Equals(codec, "sub", StringComparison.OrdinalIgnoreCase));
+ }
+
+ public static bool IsPgsFormat(string format)
+ {
+ string codec = format ?? string.Empty;
- return !codec.Contains("pgs", StringComparison.OrdinalIgnoreCase)
- && !codec.Contains("dvd", StringComparison.OrdinalIgnoreCase)
- && !codec.Contains("dvbsub", StringComparison.OrdinalIgnoreCase)
- && !string.Equals(codec, "sub", StringComparison.OrdinalIgnoreCase)
- && !string.Equals(codec, "sup", StringComparison.OrdinalIgnoreCase)
- && !string.Equals(codec, "dvb_subtitle", StringComparison.OrdinalIgnoreCase);
+ return codec.Contains("pgs", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(codec, "sup", StringComparison.OrdinalIgnoreCase);
}
public bool SupportsSubtitleConversionTo(string toCodec)
@@ -736,6 +772,8 @@ namespace MediaBrowser.Model.Entities
1 => (VideoRange.HDR, VideoRangeType.DOVIWithHDR10),
4 => (VideoRange.HDR, VideoRangeType.DOVIWithHLG),
2 => (VideoRange.SDR, VideoRangeType.DOVIWithSDR),
+ // While not in Dolby Spec, Profile 8 CCid 6 media are possible to create, and since CCid 6 stems from Bluray (Profile 7 originally) an HDR10 base layer is guaranteed to exist.
+ 6 => (VideoRange.HDR, VideoRangeType.DOVIWithHDR10),
// There is no other case to handle here as per Dolby Spec. Default case included for completeness and linting purposes
_ => (VideoRange.SDR, VideoRangeType.SDR)
},
diff --git a/MediaBrowser.Model/Entities/PlaylistUserPermissions.cs b/MediaBrowser.Model/Entities/PlaylistUserPermissions.cs
new file mode 100644
index 000000000..b5f017d2b
--- /dev/null
+++ b/MediaBrowser.Model/Entities/PlaylistUserPermissions.cs
@@ -0,0 +1,30 @@
+using System;
+
+namespace MediaBrowser.Model.Entities;
+
+/// <summary>
+/// Class to hold data on user permissions for playlists.
+/// </summary>
+public class PlaylistUserPermissions
+{
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PlaylistUserPermissions"/> class.
+ /// </summary>
+ /// <param name="userId">The user id.</param>
+ /// <param name="canEdit">Edit permission.</param>
+ public PlaylistUserPermissions(Guid userId, bool canEdit = false)
+ {
+ UserId = userId;
+ CanEdit = canEdit;
+ }
+
+ /// <summary>
+ /// Gets or sets the user id.
+ /// </summary>
+ public Guid UserId { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the user has edit permissions.
+ /// </summary>
+ public bool CanEdit { get; set; }
+}
diff --git a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs
index cf453d62c..1c73091f0 100644
--- a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs
+++ b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs
@@ -111,31 +111,32 @@ namespace MediaBrowser.Model.Entities
/// Sets a provider id.
/// </summary>
/// <param name="instance">The instance.</param>
- /// <param name="name">The name.</param>
+ /// <param name="name">The name, this should not contain a '=' character.</param>
/// <param name="value">The value.</param>
- public static void SetProviderId(this IHasProviderIds instance, string name, string? value)
+ /// <remarks>Due to how deserialization from the database works the name can not contain '='.</remarks>
+ public static void SetProviderId(this IHasProviderIds instance, string name, string value)
{
ArgumentNullException.ThrowIfNull(instance);
+ ArgumentException.ThrowIfNullOrEmpty(name);
+ ArgumentException.ThrowIfNullOrEmpty(value);
+
+ // When name contains a '=' it can't be deserialized from the database
+ if (name.Contains('=', StringComparison.Ordinal))
+ {
+ throw new ArgumentException("Provider id name cannot contain '='", nameof(name));
+ }
+
+ // Ensure it exists
+ instance.ProviderIds ??= new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
- // If it's null remove the key from the dictionary
- if (string.IsNullOrEmpty(value))
+ // Match on internal MetadataProvider enum string values before adding arbitrary providers
+ if (_metadataProviderEnumDictionary.TryGetValue(name, out var enumValue))
{
- instance.ProviderIds?.Remove(name);
+ instance.ProviderIds[enumValue] = value;
}
else
{
- // Ensure it exists
- instance.ProviderIds ??= new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
-
- // Match on internal MetadataProvider enum string values before adding arbitrary providers
- if (_metadataProviderEnumDictionary.TryGetValue(name, out var enumValue))
- {
- instance.ProviderIds[enumValue] = value;
- }
- else
- {
- instance.ProviderIds[name] = value;
- }
+ instance.ProviderIds[name] = value;
}
}
@@ -149,5 +150,30 @@ namespace MediaBrowser.Model.Entities
{
instance.SetProviderId(provider.ToString(), value);
}
+
+ /// <summary>
+ /// Removes a provider id.
+ /// </summary>
+ /// <param name="instance">The instance.</param>
+ /// <param name="name">The name.</param>
+ public static void RemoveProviderId(this IHasProviderIds instance, string name)
+ {
+ ArgumentNullException.ThrowIfNull(instance);
+ ArgumentException.ThrowIfNullOrEmpty(name);
+
+ instance.ProviderIds?.Remove(name);
+ }
+
+ /// <summary>
+ /// Removes a provider id.
+ /// </summary>
+ /// <param name="instance">The instance.</param>
+ /// <param name="provider">The provider.</param>
+ public static void RemoveProviderId(this IHasProviderIds instance, MetadataProvider provider)
+ {
+ ArgumentNullException.ThrowIfNull(instance);
+
+ instance.ProviderIds?.Remove(provider.ToString());
+ }
}
}
diff --git a/MediaBrowser.Model/Entities/Share.cs b/MediaBrowser.Model/Entities/Share.cs
deleted file mode 100644
index 186aad189..000000000
--- a/MediaBrowser.Model/Entities/Share.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace MediaBrowser.Model.Entities;
-
-/// <summary>
-/// Class to hold data on sharing permissions.
-/// </summary>
-public class Share
-{
- /// <summary>
- /// Gets or sets the user id.
- /// </summary>
- public string? UserId { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether the user has edit permissions.
- /// </summary>
- public bool CanEdit { get; set; }
-}
diff --git a/MediaBrowser.Model/Entities/VirtualFolderInfo.cs b/MediaBrowser.Model/Entities/VirtualFolderInfo.cs
index 2b2bda12c..ea3df3726 100644
--- a/MediaBrowser.Model/Entities/VirtualFolderInfo.cs
+++ b/MediaBrowser.Model/Entities/VirtualFolderInfo.cs
@@ -2,8 +2,6 @@
#pragma warning disable CS1591
using System;
-using System.Text.Json.Serialization;
-using Jellyfin.Extensions.Json.Converters;
using MediaBrowser.Model.Configuration;
namespace MediaBrowser.Model.Entities
@@ -37,7 +35,6 @@ namespace MediaBrowser.Model.Entities
/// Gets or sets the type of the collection.
/// </summary>
/// <value>The type of the collection.</value>
- [JsonConverter(typeof(JsonLowerCaseConverter<CollectionTypeOptions?>))]
public CollectionTypeOptions? CollectionType { get; set; }
public LibraryOptions LibraryOptions { get; set; }