aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model
diff options
context:
space:
mode:
authornyanmisaka <nst799610810@gmail.com>2021-12-25 00:33:17 +0800
committernyanmisaka <nst799610810@gmail.com>2021-12-25 00:33:17 +0800
commit728a5988b3801dc559efbaf278e1a75770884faf (patch)
treebf48cbc6a85fbd96ddaf65d7ccf28ee78f6b385e /MediaBrowser.Model
parent7db753d2471e6c8e0b003c75c1d40fc7b2f396da (diff)
parent2e7d173188cc755ed56b8a45e3b18206afdc4b91 (diff)
Merge remote-tracking branch 'origin/master' into hwa
Diffstat (limited to 'MediaBrowser.Model')
-rw-r--r--MediaBrowser.Model/Configuration/LibraryOptions.cs3
-rw-r--r--MediaBrowser.Model/Configuration/ServerConfiguration.cs222
-rw-r--r--MediaBrowser.Model/Dlna/CodecProfile.cs4
-rw-r--r--MediaBrowser.Model/Dlna/ConditionProcessor.cs4
-rw-r--r--MediaBrowser.Model/Dlna/ContainerProfile.cs4
-rw-r--r--MediaBrowser.Model/Dlna/DeviceProfile.cs12
-rw-r--r--MediaBrowser.Model/Dlna/StreamBuilder.cs20
-rw-r--r--MediaBrowser.Model/Dlna/SubtitleDeliveryMethod.cs7
-rw-r--r--MediaBrowser.Model/Dlna/SubtitleProfile.cs4
-rw-r--r--MediaBrowser.Model/Entities/ImageType.cs2
-rw-r--r--MediaBrowser.Model/IO/IZipClient.cs56
-rw-r--r--MediaBrowser.Model/MediaBrowser.Model.csproj6
-rw-r--r--MediaBrowser.Model/Net/MimeTypes.cs151
-rw-r--r--MediaBrowser.Model/Notifications/NotificationOptions.cs8
-rw-r--r--MediaBrowser.Model/Querying/LatestItemsQuery.cs3
-rw-r--r--MediaBrowser.Model/Search/SearchQuery.cs9
-rw-r--r--MediaBrowser.Model/Session/BrowseRequest.cs5
-rw-r--r--MediaBrowser.Model/Session/TranscodeReason.cs3
18 files changed, 110 insertions, 413 deletions
diff --git a/MediaBrowser.Model/Configuration/LibraryOptions.cs b/MediaBrowser.Model/Configuration/LibraryOptions.cs
index 90cf8f43b..d3ce6aa7f 100644
--- a/MediaBrowser.Model/Configuration/LibraryOptions.cs
+++ b/MediaBrowser.Model/Configuration/LibraryOptions.cs
@@ -21,7 +21,6 @@ namespace MediaBrowser.Model.Configuration
SaveSubtitlesWithMedia = true;
EnableRealtimeMonitor = true;
PathInfos = Array.Empty<MediaPathInfo>();
- EnableInternetProviders = true;
EnableAutomaticSeriesGrouping = true;
SeasonZeroDisplayName = "Specials";
}
@@ -38,6 +37,7 @@ namespace MediaBrowser.Model.Configuration
public bool SaveLocalMetadata { get; set; }
+ [Obsolete("Disable remote providers in TypeOptions instead")]
public bool EnableInternetProviders { get; set; }
public bool EnableAutomaticSeriesGrouping { get; set; }
@@ -81,6 +81,7 @@ namespace MediaBrowser.Model.Configuration
public bool RequirePerfectSubtitleMatch { get; set; }
public bool SaveSubtitlesWithMedia { get; set; }
+
public bool AutomaticallyAddToCollection { get; set; }
public TypeOptions[] TypeOptions { get; set; }
diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
index 0ab721b77..46e61ee1a 100644
--- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs
+++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
@@ -14,18 +14,6 @@ namespace MediaBrowser.Model.Configuration
public class ServerConfiguration : BaseApplicationConfiguration
{
/// <summary>
- /// The default value for <see cref="HttpServerPortNumber"/>.
- /// </summary>
- public const int DefaultHttpPort = 8096;
-
- /// <summary>
- /// The default value for <see cref="PublicHttpsPort"/> and <see cref="HttpsPortNumber"/>.
- /// </summary>
- public const int DefaultHttpsPort = 8920;
-
- private string _baseUrl = string.Empty;
-
- /// <summary>
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
/// </summary>
public ServerConfiguration()
@@ -76,149 +64,13 @@ namespace MediaBrowser.Model.Configuration
}
/// <summary>
- /// Gets or sets a value indicating whether to enable automatic port forwarding.
- /// </summary>
- public bool EnableUPnP { get; set; } = false;
-
- /// <summary>
/// Gets or sets a value indicating whether to enable prometheus metrics exporting.
/// </summary>
public bool EnableMetrics { get; set; } = false;
- /// <summary>
- /// Gets or sets the public mapped port.
- /// </summary>
- /// <value>The public mapped port.</value>
- public int PublicPort { get; set; } = DefaultHttpPort;
-
- /// <summary>
- /// Gets or sets a value indicating whether the http port should be mapped as part of UPnP automatic port forwarding.
- /// </summary>
- public bool UPnPCreateHttpPortMap { get; set; } = false;
-
- /// <summary>
- /// Gets or sets client udp port range.
- /// </summary>
- public string UDPPortRange { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets a value indicating whether IPV6 capability is enabled.
- /// </summary>
- public bool EnableIPV6 { get; set; } = false;
-
- /// <summary>
- /// Gets or sets a value indicating whether IPV4 capability is enabled.
- /// </summary>
- public bool EnableIPV4 { get; set; } = true;
-
- /// <summary>
- /// Gets or sets a value indicating whether detailed ssdp logs are sent to the console/log.
- /// "Emby.Dlna": "Debug" must be set in logging.default.json for this property to work.
- /// </summary>
- public bool EnableSSDPTracing { get; set; } = false;
-
- /// <summary>
- /// Gets or sets a value indicating whether an IP address is to be used to filter the detailed ssdp logs that are being sent to the console/log.
- /// If the setting "Emby.Dlna": "Debug" msut be set in logging.default.json for this property to work.
- /// </summary>
- public string SSDPTracingFilter { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the number of times SSDP UDP messages are sent.
- /// </summary>
- public int UDPSendCount { get; set; } = 2;
-
- /// <summary>
- /// Gets or sets the delay between each groups of SSDP messages (in ms).
- /// </summary>
- public int UDPSendDelay { get; set; } = 100;
-
- /// <summary>
- /// Gets or sets a value indicating whether address names that match <see cref="VirtualInterfaceNames"/> should be Ignore for the purposes of binding.
- /// </summary>
- public bool IgnoreVirtualInterfaces { get; set; } = true;
-
- /// <summary>
- /// Gets or sets a value indicating the interfaces that should be ignored. The list can be comma separated. <seealso cref="IgnoreVirtualInterfaces"/>.
- /// </summary>
- public string VirtualInterfaceNames { get; set; } = "vEthernet*";
-
- /// <summary>
- /// Gets or sets the time (in seconds) between the pings of SSDP gateway monitor.
- /// </summary>
- public int GatewayMonitorPeriod { get; set; } = 60;
-
- /// <summary>
- /// Gets a value indicating whether multi-socket binding is available.
- /// </summary>
- public bool EnableMultiSocketBinding { get; } = true;
-
- /// <summary>
- /// Gets or sets a value indicating whether all IPv6 interfaces should be treated as on the internal network.
- /// Depending on the address range implemented ULA ranges might not be used.
- /// </summary>
- public bool TrustAllIP6Interfaces { get; set; } = false;
-
- /// <summary>
- /// Gets or sets the ports that HDHomerun uses.
- /// </summary>
- public string HDHomerunPortRange { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets PublishedServerUri to advertise for specific subnets.
- /// </summary>
- public string[] PublishedServerUriBySubnet { get; set; } = Array.Empty<string>();
-
- /// <summary>
- /// Gets or sets a value indicating whether Autodiscovery tracing is enabled.
- /// </summary>
- public bool AutoDiscoveryTracing { get; set; } = false;
-
- /// <summary>
- /// Gets or sets a value indicating whether Autodiscovery is enabled.
- /// </summary>
- public bool AutoDiscovery { get; set; } = true;
-
- /// <summary>
- /// Gets or sets the public HTTPS port.
- /// </summary>
- /// <value>The public HTTPS port.</value>
- public int PublicHttpsPort { get; set; } = DefaultHttpsPort;
-
- /// <summary>
- /// Gets or sets the HTTP server port number.
- /// </summary>
- /// <value>The HTTP server port number.</value>
- public int HttpServerPortNumber { get; set; } = DefaultHttpPort;
-
- /// <summary>
- /// Gets or sets the HTTPS server port number.
- /// </summary>
- /// <value>The HTTPS server port number.</value>
- public int HttpsPortNumber { get; set; } = DefaultHttpsPort;
-
- /// <summary>
- /// Gets or sets a value indicating whether to use HTTPS.
- /// </summary>
- /// <remarks>
- /// In order for HTTPS to be used, in addition to setting this to true, valid values must also be
- /// provided for <see cref="CertificatePath"/> and <see cref="CertificatePassword"/>.
- /// </remarks>
- public bool EnableHttps { get; set; } = false;
-
public bool EnableNormalizedItemByNameIds { get; set; } = true;
/// <summary>
- /// Gets or sets the filesystem path of an X.509 certificate to use for SSL.
- /// </summary>
- public string CertificatePath { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the password required to access the X.509 certificate data in the file specified by <see cref="CertificatePath"/>.
- /// </summary>
- public string CertificatePassword { get; set; } = string.Empty;
-
- /// <summary>
/// Gets or sets a value indicating whether this instance is port authorized.
/// </summary>
/// <value><c>true</c> if this instance is port authorized; otherwise, <c>false</c>.</value>
@@ -230,11 +82,6 @@ namespace MediaBrowser.Model.Configuration
public bool QuickConnectAvailable { get; set; } = false;
/// <summary>
- /// Gets or sets a value indicating whether access outside of the LAN is permitted.
- /// </summary>
- public bool EnableRemoteAccess { get; set; } = true;
-
- /// <summary>
/// Gets or sets a value indicating whether [enable case sensitive item ids].
/// </summary>
/// <value><c>true</c> if [enable case sensitive item ids]; otherwise, <c>false</c>.</value>
@@ -319,13 +166,6 @@ namespace MediaBrowser.Model.Configuration
public int LibraryMonitorDelay { get; set; } = 60;
/// <summary>
- /// Gets or sets a value indicating whether [enable dashboard response caching].
- /// Allows potential contributors without visual studio to modify production dashboard code and test changes.
- /// </summary>
- /// <value><c>true</c> if [enable dashboard response caching]; otherwise, <c>false</c>.</value>
- public bool EnableDashboardResponseCaching { get; set; } = true;
-
- /// <summary>
/// Gets or sets the image saving convention.
/// </summary>
/// <value>The image saving convention.</value>
@@ -337,36 +177,6 @@ namespace MediaBrowser.Model.Configuration
public string ServerName { get; set; } = string.Empty;
- public string BaseUrl
- {
- get => _baseUrl;
- set
- {
- // Normalize the start of the string
- if (string.IsNullOrWhiteSpace(value))
- {
- // If baseUrl is empty, set an empty prefix string
- _baseUrl = string.Empty;
- return;
- }
-
- if (value[0] != '/')
- {
- // If baseUrl was not configured with a leading slash, append one for consistency
- value = "/" + value;
- }
-
- // Normalize the end of the string
- if (value[value.Length - 1] == '/')
- {
- // If baseUrl was configured with a trailing slash, remove it for consistency
- value = value.Remove(value.Length - 1);
- }
-
- _baseUrl = value;
- }
- }
-
public string UICulture { get; set; } = "en-US";
public bool SaveMetadataHidden { get; set; } = false;
@@ -381,43 +191,16 @@ namespace MediaBrowser.Model.Configuration
public bool DisplaySpecialsWithinSeasons { get; set; } = true;
- /// <summary>
- /// Gets or sets the subnets that are deemed to make up the LAN.
- /// </summary>
- public string[] LocalNetworkSubnets { get; set; } = Array.Empty<string>();
-
- /// <summary>
- /// Gets or sets the interface addresses which Jellyfin will bind to. If empty, all interfaces will be used.
- /// </summary>
- public string[] LocalNetworkAddresses { get; set; } = Array.Empty<string>();
-
public string[] CodecsUsed { get; set; } = Array.Empty<string>();
public List<RepositoryInfo> PluginRepositories { get; set; } = new List<RepositoryInfo>();
public bool EnableExternalContentInSuggestions { get; set; } = true;
- /// <summary>
- /// Gets or sets a value indicating whether the server should force connections over HTTPS.
- /// </summary>
- public bool RequireHttps { get; set; } = false;
-
- /// <summary>
- /// Gets or sets the filter for remote IP connectivity. Used in conjuntion with <seealso cref="IsRemoteIPFilterBlacklist"/>.
- /// </summary>
- public string[] RemoteIPFilter { get; set; } = Array.Empty<string>();
-
- /// <summary>
- /// Gets or sets a value indicating whether <seealso cref="RemoteIPFilter"/> contains a blacklist or a whitelist. Default is a whitelist.
- /// </summary>
- public bool IsRemoteIPFilterBlacklist { get; set; } = false;
-
public int ImageExtractionTimeoutMs { get; set; } = 0;
public PathSubstitution[] PathSubstitutions { get; set; } = Array.Empty<PathSubstitution>();
- public string[] UninstalledPlugins { get; set; } = Array.Empty<string>();
-
/// <summary>
/// Gets or sets a value indicating whether slow server responses should be logged as a warning.
/// </summary>
@@ -434,11 +217,6 @@ namespace MediaBrowser.Model.Configuration
public string[] CorsHosts { get; set; } = new[] { "*" };
/// <summary>
- /// Gets or sets the known proxies.
- /// </summary>
- public string[] KnownProxies { get; set; } = Array.Empty<string>();
-
- /// <summary>
/// Gets or sets the number of days we should retain activity logs.
/// </summary>
public int? ActivityLogRetentionDays { get; set; } = 30;
diff --git a/MediaBrowser.Model/Dlna/CodecProfile.cs b/MediaBrowser.Model/Dlna/CodecProfile.cs
index 8343cf028..f857bf3a8 100644
--- a/MediaBrowser.Model/Dlna/CodecProfile.cs
+++ b/MediaBrowser.Model/Dlna/CodecProfile.cs
@@ -2,8 +2,8 @@
#pragma warning disable CS1591
using System;
-using System.Linq;
using System.Xml.Serialization;
+using Jellyfin.Extensions;
namespace MediaBrowser.Model.Dlna
{
@@ -58,7 +58,7 @@ namespace MediaBrowser.Model.Dlna
foreach (var val in codec)
{
- if (codecs.Contains(val, StringComparer.OrdinalIgnoreCase))
+ if (codecs.Contains(val, StringComparison.OrdinalIgnoreCase))
{
return true;
}
diff --git a/MediaBrowser.Model/Dlna/ConditionProcessor.cs b/MediaBrowser.Model/Dlna/ConditionProcessor.cs
index 55c4dd074..8d03b4c0b 100644
--- a/MediaBrowser.Model/Dlna/ConditionProcessor.cs
+++ b/MediaBrowser.Model/Dlna/ConditionProcessor.cs
@@ -2,7 +2,7 @@
using System;
using System.Globalization;
-using System.Linq;
+using Jellyfin.Extensions;
using MediaBrowser.Model.MediaInfo;
namespace MediaBrowser.Model.Dlna
@@ -167,7 +167,7 @@ namespace MediaBrowser.Model.Dlna
switch (condition.Condition)
{
case ProfileConditionType.EqualsAny:
- return expected.Split('|').Contains(currentValue, StringComparer.OrdinalIgnoreCase);
+ return expected.Split('|').Contains(currentValue, StringComparison.OrdinalIgnoreCase);
case ProfileConditionType.Equals:
return string.Equals(currentValue, expected, StringComparison.OrdinalIgnoreCase);
case ProfileConditionType.NotEquals:
diff --git a/MediaBrowser.Model/Dlna/ContainerProfile.cs b/MediaBrowser.Model/Dlna/ContainerProfile.cs
index 740966088..c6befdd85 100644
--- a/MediaBrowser.Model/Dlna/ContainerProfile.cs
+++ b/MediaBrowser.Model/Dlna/ContainerProfile.cs
@@ -1,8 +1,8 @@
#pragma warning disable CS1591
using System;
-using System.Linq;
using System.Xml.Serialization;
+using Jellyfin.Extensions;
namespace MediaBrowser.Model.Dlna
{
@@ -62,7 +62,7 @@ namespace MediaBrowser.Model.Dlna
foreach (var container in allInputContainers)
{
- if (profileContainers.Contains(container, StringComparer.OrdinalIgnoreCase))
+ if (profileContainers.Contains(container, StringComparison.OrdinalIgnoreCase))
{
return !isNegativeList;
}
diff --git a/MediaBrowser.Model/Dlna/DeviceProfile.cs b/MediaBrowser.Model/Dlna/DeviceProfile.cs
index feb3d880e..6170ff5bd 100644
--- a/MediaBrowser.Model/Dlna/DeviceProfile.cs
+++ b/MediaBrowser.Model/Dlna/DeviceProfile.cs
@@ -1,8 +1,8 @@
#pragma warning disable CA1819 // Properties should not return arrays
using System;
using System.ComponentModel;
-using System.Linq;
using System.Xml.Serialization;
+using Jellyfin.Extensions;
using MediaBrowser.Model.MediaInfo;
namespace MediaBrowser.Model.Dlna
@@ -253,7 +253,7 @@ namespace MediaBrowser.Model.Dlna
continue;
}
- if (!i.GetAudioCodecs().Contains(audioCodec ?? string.Empty, StringComparer.OrdinalIgnoreCase))
+ if (!i.GetAudioCodecs().Contains(audioCodec ?? string.Empty, StringComparison.OrdinalIgnoreCase))
{
continue;
}
@@ -287,7 +287,7 @@ namespace MediaBrowser.Model.Dlna
continue;
}
- if (!i.GetAudioCodecs().Contains(audioCodec ?? string.Empty, StringComparer.OrdinalIgnoreCase))
+ if (!i.GetAudioCodecs().Contains(audioCodec ?? string.Empty, StringComparison.OrdinalIgnoreCase))
{
continue;
}
@@ -328,7 +328,7 @@ namespace MediaBrowser.Model.Dlna
}
var audioCodecs = i.GetAudioCodecs();
- if (audioCodecs.Length > 0 && !audioCodecs.Contains(audioCodec ?? string.Empty, StringComparer.OrdinalIgnoreCase))
+ if (audioCodecs.Length > 0 && !audioCodecs.Contains(audioCodec ?? string.Empty, StringComparison.OrdinalIgnoreCase))
{
continue;
}
@@ -469,13 +469,13 @@ namespace MediaBrowser.Model.Dlna
}
var audioCodecs = i.GetAudioCodecs();
- if (audioCodecs.Length > 0 && !audioCodecs.Contains(audioCodec ?? string.Empty, StringComparer.OrdinalIgnoreCase))
+ if (audioCodecs.Length > 0 && !audioCodecs.Contains(audioCodec ?? string.Empty, StringComparison.OrdinalIgnoreCase))
{
continue;
}
var videoCodecs = i.GetVideoCodecs();
- if (videoCodecs.Length > 0 && !videoCodecs.Contains(videoCodec ?? string.Empty, StringComparer.OrdinalIgnoreCase))
+ if (videoCodecs.Length > 0 && !videoCodecs.Contains(videoCodec ?? string.Empty, StringComparison.OrdinalIgnoreCase))
{
continue;
}
diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs
index 322cc367b..c6ce45788 100644
--- a/MediaBrowser.Model/Dlna/StreamBuilder.cs
+++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs
@@ -677,8 +677,8 @@ namespace MediaBrowser.Model.Dlna
var videoStream = item.VideoStream;
// TODO: This doesn't account for situations where the device is able to handle the media's bitrate, but the connection isn't fast enough
- var directPlayEligibilityResult = IsEligibleForDirectPlay(item, GetBitrateForDirectPlayCheck(item, options, true) ?? 0, subtitleStream, options, PlayMethod.DirectPlay);
- var directStreamEligibilityResult = IsEligibleForDirectPlay(item, options.GetMaxBitrate(false) ?? 0, subtitleStream, options, PlayMethod.DirectStream);
+ var directPlayEligibilityResult = IsEligibleForDirectPlay(item, GetBitrateForDirectPlayCheck(item, options, true) ?? 0, subtitleStream, audioStream, options, PlayMethod.DirectPlay);
+ var directStreamEligibilityResult = IsEligibleForDirectPlay(item, options.GetMaxBitrate(false) ?? 0, subtitleStream, audioStream, options, PlayMethod.DirectStream);
bool isEligibleForDirectPlay = options.EnableDirectPlay && (options.ForceDirectPlay || directPlayEligibilityResult.Item1);
bool isEligibleForDirectStream = options.EnableDirectStream && (options.ForceDirectStream || directStreamEligibilityResult.Item1);
@@ -1213,6 +1213,7 @@ namespace MediaBrowser.Model.Dlna
MediaSourceInfo item,
long maxBitrate,
MediaStream subtitleStream,
+ MediaStream audioStream,
VideoOptions options,
PlayMethod playMethod)
{
@@ -1220,7 +1221,9 @@ namespace MediaBrowser.Model.Dlna
{
var subtitleProfile = GetSubtitleProfile(item, subtitleStream, options.Profile.SubtitleProfiles, playMethod, _transcoderSupport, item.Container, null);
- if (subtitleProfile.Method != SubtitleDeliveryMethod.External && subtitleProfile.Method != SubtitleDeliveryMethod.Embed)
+ if (subtitleProfile.Method != SubtitleDeliveryMethod.Drop
+ && subtitleProfile.Method != SubtitleDeliveryMethod.External
+ && subtitleProfile.Method != SubtitleDeliveryMethod.Embed)
{
_logger.LogDebug("Not eligible for {0} due to unsupported subtitles", playMethod);
return (false, TranscodeReason.SubtitleCodecNotSupported);
@@ -1228,8 +1231,17 @@ namespace MediaBrowser.Model.Dlna
}
bool result = IsAudioEligibleForDirectPlay(item, maxBitrate, playMethod);
+ if (!result)
+ {
+ return (false, TranscodeReason.ContainerBitrateExceedsLimit);
+ }
+
+ if (audioStream.IsExternal)
+ {
+ return (false, TranscodeReason.AudioIsExternal);
+ }
- return (result, result ? null : TranscodeReason.ContainerBitrateExceedsLimit);
+ return (true, null);
}
public static SubtitleProfile GetSubtitleProfile(
diff --git a/MediaBrowser.Model/Dlna/SubtitleDeliveryMethod.cs b/MediaBrowser.Model/Dlna/SubtitleDeliveryMethod.cs
index 9b39f9e11..69bda2d91 100644
--- a/MediaBrowser.Model/Dlna/SubtitleDeliveryMethod.cs
+++ b/MediaBrowser.Model/Dlna/SubtitleDeliveryMethod.cs
@@ -25,6 +25,11 @@ namespace MediaBrowser.Model.Dlna
/// <summary>
/// Serve the subtitles as a separate HLS stream.
/// </summary>
- Hls = 3
+ Hls = 3,
+
+ /// <summary>
+ /// Drop the subtitle.
+ /// </summary>
+ Drop = 4
}
}
diff --git a/MediaBrowser.Model/Dlna/SubtitleProfile.cs b/MediaBrowser.Model/Dlna/SubtitleProfile.cs
index 01e3c696b..9ebde25ff 100644
--- a/MediaBrowser.Model/Dlna/SubtitleProfile.cs
+++ b/MediaBrowser.Model/Dlna/SubtitleProfile.cs
@@ -2,8 +2,8 @@
#pragma warning disable CS1591
using System;
-using System.Linq;
using System.Xml.Serialization;
+using Jellyfin.Extensions;
namespace MediaBrowser.Model.Dlna
{
@@ -42,7 +42,7 @@ namespace MediaBrowser.Model.Dlna
}
var languages = GetLanguages();
- return languages.Length == 0 || languages.Contains(subLanguage, StringComparer.OrdinalIgnoreCase);
+ return languages.Length == 0 || languages.Contains(subLanguage, StringComparison.OrdinalIgnoreCase);
}
}
}
diff --git a/MediaBrowser.Model/Entities/ImageType.cs b/MediaBrowser.Model/Entities/ImageType.cs
index 684b7390a..1f7e03718 100644
--- a/MediaBrowser.Model/Entities/ImageType.cs
+++ b/MediaBrowser.Model/Entities/ImageType.cs
@@ -1,5 +1,3 @@
-using System;
-
namespace MediaBrowser.Model.Entities
{
/// <summary>
diff --git a/MediaBrowser.Model/IO/IZipClient.cs b/MediaBrowser.Model/IO/IZipClient.cs
index fca52ebae..2448575d1 100644
--- a/MediaBrowser.Model/IO/IZipClient.cs
+++ b/MediaBrowser.Model/IO/IZipClient.cs
@@ -9,64 +9,8 @@ namespace MediaBrowser.Model.IO
/// </summary>
public interface IZipClient
{
- /// <summary>
- /// Extracts all.
- /// </summary>
- /// <param name="sourceFile">The source file.</param>
- /// <param name="targetPath">The target path.</param>
- /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
- void ExtractAll(string sourceFile, string targetPath, bool overwriteExistingFiles);
-
- /// <summary>
- /// Extracts all.
- /// </summary>
- /// <param name="source">The source.</param>
- /// <param name="targetPath">The target path.</param>
- /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
- void ExtractAll(Stream source, string targetPath, bool overwriteExistingFiles);
-
void ExtractAllFromGz(Stream source, string targetPath, bool overwriteExistingFiles);
void ExtractFirstFileFromGz(Stream source, string targetPath, string defaultFileName);
-
- /// <summary>
- /// Extracts all from zip.
- /// </summary>
- /// <param name="source">The source.</param>
- /// <param name="targetPath">The target path.</param>
- /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
- void ExtractAllFromZip(Stream source, string targetPath, bool overwriteExistingFiles);
-
- /// <summary>
- /// Extracts all from7z.
- /// </summary>
- /// <param name="sourceFile">The source file.</param>
- /// <param name="targetPath">The target path.</param>
- /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
- void ExtractAllFrom7z(string sourceFile, string targetPath, bool overwriteExistingFiles);
-
- /// <summary>
- /// Extracts all from7z.
- /// </summary>
- /// <param name="source">The source.</param>
- /// <param name="targetPath">The target path.</param>
- /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
- void ExtractAllFrom7z(Stream source, string targetPath, bool overwriteExistingFiles);
-
- /// <summary>
- /// Extracts all from tar.
- /// </summary>
- /// <param name="sourceFile">The source file.</param>
- /// <param name="targetPath">The target path.</param>
- /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
- void ExtractAllFromTar(string sourceFile, string targetPath, bool overwriteExistingFiles);
-
- /// <summary>
- /// Extracts all from tar.
- /// </summary>
- /// <param name="source">The source.</param>
- /// <param name="targetPath">The target path.</param>
- /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
- void ExtractAllFromTar(Stream source, string targetPath, bool overwriteExistingFiles);
}
}
diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj
index 70fef5d66..a161b99fd 100644
--- a/MediaBrowser.Model/MediaBrowser.Model.csproj
+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj
@@ -31,8 +31,12 @@
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
+ <PackageReference Include="MimeTypes" Version="2.2.1">
+ <PrivateAssets>all</PrivateAssets>
+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
+ </PackageReference>
<PackageReference Include="System.Globalization" Version="4.3.0" />
- <PackageReference Include="System.Text.Json" Version="6.0.0" />
+ <PackageReference Include="System.Text.Json" Version="6.0.1" />
</ItemGroup>
<ItemGroup>
diff --git a/MediaBrowser.Model/Net/MimeTypes.cs b/MediaBrowser.Model/Net/MimeTypes.cs
index 043cee2a2..3b03466e9 100644
--- a/MediaBrowser.Model/Net/MimeTypes.cs
+++ b/MediaBrowser.Model/Net/MimeTypes.cs
@@ -12,6 +12,15 @@ namespace MediaBrowser.Model.Net
/// <summary>
/// Class MimeTypes.
/// </summary>
+ ///
+ /// <remarks>
+ /// For more information on MIME types:
+ /// <list type="bullet">
+ /// <item>http://en.wikipedia.org/wiki/Internet_media_type</item>
+ /// <item>https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types</item>
+ /// <item>http://www.iana.org/assignments/media-types/media-types.xhtml</item>
+ /// </list>
+ /// </remarks>
public static class MimeTypes
{
/// <summary>
@@ -50,81 +59,26 @@ namespace MediaBrowser.Model.Net
".wtv",
};
- // http://en.wikipedia.org/wiki/Internet_media_type
- // https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
- // http://www.iana.org/assignments/media-types/media-types.xhtml
- // Add more as needed
+ /// <summary>
+ /// Used for extensions not in <see cref="Model.MimeTypes"/> or to override them.
+ /// </summary>
private static readonly Dictionary<string, string> _mimeTypeLookup = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
// Type application
- { ".7z", "application/x-7z-compressed" },
- { ".azw", "application/vnd.amazon.ebook" },
{ ".azw3", "application/vnd.amazon.ebook" },
- { ".cbz", "application/x-cbz" },
- { ".cbr", "application/epub+zip" },
- { ".eot", "application/vnd.ms-fontobject" },
- { ".epub", "application/epub+zip" },
- { ".js", "application/x-javascript" },
- { ".json", "application/json" },
- { ".m3u8", "application/x-mpegURL" },
- { ".map", "application/x-javascript" },
- { ".mobi", "application/x-mobipocket-ebook" },
- { ".opf", "application/oebps-package+xml" },
- { ".pdf", "application/pdf" },
- { ".rar", "application/vnd.rar" },
- { ".srt", "application/x-subrip" },
- { ".ttml", "application/ttml+xml" },
- { ".wasm", "application/wasm" },
- { ".xml", "application/xml" },
- { ".zip", "application/zip" },
// Type image
- { ".bmp", "image/bmp" },
- { ".gif", "image/gif" },
- { ".ico", "image/vnd.microsoft.icon" },
- { ".jpg", "image/jpeg" },
- { ".jpeg", "image/jpeg" },
- { ".png", "image/png" },
- { ".svg", "image/svg+xml" },
- { ".svgz", "image/svg+xml" },
{ ".tbn", "image/jpeg" },
- { ".tif", "image/tiff" },
- { ".tiff", "image/tiff" },
- { ".webp", "image/webp" },
-
- // Type font
- { ".ttf", "font/ttf" },
- { ".woff", "font/woff" },
- { ".woff2", "font/woff2" },
// Type text
{ ".ass", "text/x-ssa" },
{ ".ssa", "text/x-ssa" },
- { ".css", "text/css" },
- { ".csv", "text/csv" },
{ ".edl", "text/plain" },
- { ".rtf", "text/rtf" },
- { ".txt", "text/plain" },
- { ".vtt", "text/vtt" },
+ { ".html", "text/html; charset=UTF-8" },
+ { ".htm", "text/html; charset=UTF-8" },
// Type video
- { ".3gp", "video/3gpp" },
- { ".3g2", "video/3gpp2" },
- { ".asf", "video/x-ms-asf" },
- { ".avi", "video/x-msvideo" },
- { ".flv", "video/x-flv" },
- { ".mp4", "video/mp4" },
- { ".m4s", "video/mp4" },
- { ".m4v", "video/x-m4v" },
{ ".mpegts", "video/mp2t" },
- { ".mpg", "video/mpeg" },
- { ".mkv", "video/x-matroska" },
- { ".mov", "video/quicktime" },
- { ".mpd", "video/vnd.mpeg.dash.mpd" },
- { ".ogv", "video/ogg" },
- { ".ts", "video/mp2t" },
- { ".webm", "video/webm" },
- { ".wmv", "video/x-ms-wmv" },
// Type audio
{ ".aac", "audio/aac" },
@@ -133,37 +87,47 @@ namespace MediaBrowser.Model.Net
{ ".dsf", "audio/dsf" },
{ ".dsp", "audio/dsp" },
{ ".flac", "audio/flac" },
- { ".m4a", "audio/mp4" },
{ ".m4b", "audio/m4b" },
- { ".mid", "audio/midi" },
- { ".midi", "audio/midi" },
{ ".mp3", "audio/mpeg" },
- { ".oga", "audio/ogg" },
- { ".ogg", "audio/ogg" },
- { ".opus", "audio/ogg" },
{ ".vorbis", "audio/vorbis" },
- { ".wav", "audio/wav" },
{ ".webma", "audio/webm" },
- { ".wma", "audio/x-ms-wma" },
{ ".wv", "audio/x-wavpack" },
{ ".xsp", "audio/xsp" },
};
- private static readonly Dictionary<string, string> _extensionLookup = CreateExtensionLookup();
-
- private static Dictionary<string, string> CreateExtensionLookup()
+ private static readonly Dictionary<string, string> _extensionLookup = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
- var dict = _mimeTypeLookup
- .GroupBy(i => i.Value)
- .ToDictionary(x => x.Key, x => x.First().Key, StringComparer.OrdinalIgnoreCase);
+ // Type application
+ { "application/x-cbz", ".cbz" },
+ { "application/x-javascript", ".js" },
+ { "application/xml", ".xml" },
+ { "application/x-mpegURL", ".m3u8" },
- dict["image/jpg"] = ".jpg";
- dict["image/x-png"] = ".png";
+ // Type audio
+ { "audio/aac", ".aac" },
+ { "audio/ac3", ".ac3" },
+ { "audio/dsf", ".dsf" },
+ { "audio/dsp", ".dsp" },
+ { "audio/flac", ".flac" },
+ { "audio/m4b", ".m4b" },
+ { "audio/vorbis", ".vorbis" },
+ { "audio/x-ape", ".ape" },
+ { "audio/xsp", ".xsp" },
+ { "audio/x-wavpack", ".wv" },
- dict["audio/x-aac"] = ".aac";
+ // Type image
+ { "image/jpeg", ".jpg" },
+ { "image/x-png", ".png" },
- return dict;
- }
+ // Type text
+ { "text/plain", ".txt" },
+ { "text/rtf", ".rtf" },
+ { "text/x-ssa", ".ssa" },
+
+ // Type video
+ { "video/vnd.mpeg.dash.mpd", ".mpd" },
+ { "video/x-matroska", ".mkv" },
+ };
public static string GetMimeType(string path) => GetMimeType(path, "application/octet-stream");
@@ -173,7 +137,7 @@ namespace MediaBrowser.Model.Net
/// <param name="filename">The filename to find the MIME type of.</param>
/// <param name="defaultValue">The default value to return if no fitting MIME type is found.</param>
/// <returns>The correct MIME type for the given filename, or <paramref name="defaultValue"/> if it wasn't found.</returns>
- [return: NotNullIfNotNullAttribute("defaultValue")]
+ [return: NotNullIfNotNull("defaultValue")]
public static string? GetMimeType(string filename, string? defaultValue = null)
{
if (filename.Length == 0)
@@ -188,29 +152,15 @@ namespace MediaBrowser.Model.Net
return result;
}
- // Catch-all for all video types that don't require specific mime types
- if (_videoFileExtensions.Contains(ext))
- {
- return string.Concat("video/", ext.AsSpan(1));
- }
-
- // Type text
- if (string.Equals(ext, ".html", StringComparison.OrdinalIgnoreCase)
- || string.Equals(ext, ".htm", StringComparison.OrdinalIgnoreCase))
+ if (Model.MimeTypes.TryGetMimeType(filename, out var mimeType))
{
- return "text/html; charset=UTF-8";
+ return mimeType;
}
- if (string.Equals(ext, ".log", StringComparison.OrdinalIgnoreCase)
- || string.Equals(ext, ".srt", StringComparison.OrdinalIgnoreCase))
- {
- return "text/plain";
- }
-
- // Misc
- if (string.Equals(ext, ".dll", StringComparison.OrdinalIgnoreCase))
+ // Catch-all for all video types that don't require specific mime types
+ if (_videoFileExtensions.Contains(ext))
{
- return "application/octet-stream";
+ return string.Concat("video/", ext.AsSpan(1));
}
return defaultValue;
@@ -231,7 +181,8 @@ namespace MediaBrowser.Model.Net
return result;
}
- return null;
+ var extension = Model.MimeTypes.GetMimeTypeExtensions(mimeType).FirstOrDefault();
+ return string.IsNullOrEmpty(extension) ? null : "." + extension;
}
}
}
diff --git a/MediaBrowser.Model/Notifications/NotificationOptions.cs b/MediaBrowser.Model/Notifications/NotificationOptions.cs
index 09beb2ef7..d1b5491bd 100644
--- a/MediaBrowser.Model/Notifications/NotificationOptions.cs
+++ b/MediaBrowser.Model/Notifications/NotificationOptions.cs
@@ -2,9 +2,9 @@
#pragma warning disable CS1591
using System;
-using System.Linq;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Extensions;
namespace MediaBrowser.Model.Notifications
{
@@ -94,7 +94,7 @@ namespace MediaBrowser.Model.Notifications
NotificationOption opt = GetOptions(notificationType);
return opt == null
- || !opt.DisabledServices.Contains(service, StringComparer.OrdinalIgnoreCase);
+ || !opt.DisabledServices.Contains(service, StringComparison.OrdinalIgnoreCase);
}
public bool IsEnabledToMonitorUser(string type, Guid userId)
@@ -103,7 +103,7 @@ namespace MediaBrowser.Model.Notifications
return opt != null
&& opt.Enabled
- && !opt.DisabledMonitorUsers.Contains(userId.ToString("N"), StringComparer.OrdinalIgnoreCase);
+ && !opt.DisabledMonitorUsers.Contains(userId.ToString("N"), StringComparison.OrdinalIgnoreCase);
}
public bool IsEnabledToSendToUser(string type, string userId, User user)
@@ -122,7 +122,7 @@ namespace MediaBrowser.Model.Notifications
return true;
}
- return opt.SendToUsers.Contains(userId, StringComparer.OrdinalIgnoreCase);
+ return opt.SendToUsers.Contains(userId, StringComparison.OrdinalIgnoreCase);
}
return false;
diff --git a/MediaBrowser.Model/Querying/LatestItemsQuery.cs b/MediaBrowser.Model/Querying/LatestItemsQuery.cs
index f555ffb36..d2d9f1f9a 100644
--- a/MediaBrowser.Model/Querying/LatestItemsQuery.cs
+++ b/MediaBrowser.Model/Querying/LatestItemsQuery.cs
@@ -2,6 +2,7 @@
#pragma warning disable CS1591
using System;
+using Jellyfin.Data.Enums;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Model.Querying
@@ -48,7 +49,7 @@ namespace MediaBrowser.Model.Querying
/// Gets or sets the include item types.
/// </summary>
/// <value>The include item types.</value>
- public string[] IncludeItemTypes { get; set; }
+ public BaseItemKind[] IncludeItemTypes { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is played.
diff --git a/MediaBrowser.Model/Search/SearchQuery.cs b/MediaBrowser.Model/Search/SearchQuery.cs
index aedfa4d36..1caed827f 100644
--- a/MediaBrowser.Model/Search/SearchQuery.cs
+++ b/MediaBrowser.Model/Search/SearchQuery.cs
@@ -2,6 +2,7 @@
#pragma warning disable CS1591
using System;
+using Jellyfin.Data.Enums;
namespace MediaBrowser.Model.Search
{
@@ -16,8 +17,8 @@ namespace MediaBrowser.Model.Search
IncludeStudios = true;
MediaTypes = Array.Empty<string>();
- IncludeItemTypes = Array.Empty<string>();
- ExcludeItemTypes = Array.Empty<string>();
+ IncludeItemTypes = Array.Empty<BaseItemKind>();
+ ExcludeItemTypes = Array.Empty<BaseItemKind>();
}
/// <summary>
@@ -56,9 +57,9 @@ namespace MediaBrowser.Model.Search
public string[] MediaTypes { get; set; }
- public string[] IncludeItemTypes { get; set; }
+ public BaseItemKind[] IncludeItemTypes { get; set; }
- public string[] ExcludeItemTypes { get; set; }
+ public BaseItemKind[] ExcludeItemTypes { get; set; }
public Guid? ParentId { get; set; }
diff --git a/MediaBrowser.Model/Session/BrowseRequest.cs b/MediaBrowser.Model/Session/BrowseRequest.cs
index 65afe5cf3..5ad7d783a 100644
--- a/MediaBrowser.Model/Session/BrowseRequest.cs
+++ b/MediaBrowser.Model/Session/BrowseRequest.cs
@@ -1,3 +1,5 @@
+using Jellyfin.Data.Enums;
+
#nullable disable
namespace MediaBrowser.Model.Session
{
@@ -8,10 +10,9 @@ namespace MediaBrowser.Model.Session
{
/// <summary>
/// Gets or sets the item type.
- /// Artist, Genre, Studio, Person, or any kind of BaseItem.
/// </summary>
/// <value>The type of the item.</value>
- public string ItemType { get; set; }
+ public BaseItemKind ItemType { get; set; }
/// <summary>
/// Gets or sets the item id.
diff --git a/MediaBrowser.Model/Session/TranscodeReason.cs b/MediaBrowser.Model/Session/TranscodeReason.cs
index e93b5d288..3c95df66d 100644
--- a/MediaBrowser.Model/Session/TranscodeReason.cs
+++ b/MediaBrowser.Model/Session/TranscodeReason.cs
@@ -26,6 +26,7 @@ namespace MediaBrowser.Model.Session
VideoProfileNotSupported = 19,
AudioBitDepthNotSupported = 20,
SubtitleCodecNotSupported = 21,
- DirectPlayError = 22
+ DirectPlayError = 22,
+ AudioIsExternal = 23
}
}