mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Use frozen collections in MimeTypes.cs (#10826)
Co-authored-by: Stepan Goremykin <goremukin@gmail.com>
This commit is contained in:
parent
e1076bab9c
commit
a3cc39ddd8
@ -669,7 +669,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
|
|
||||||
if (parent is not null)
|
if (parent is not null)
|
||||||
{
|
{
|
||||||
var multiItemResolvers = resolvers is null ? MultiItemResolvers : resolvers.OfType<IMultiItemResolver>().ToArray();
|
var multiItemResolvers = resolvers is null ? MultiItemResolvers : resolvers.OfType<IMultiItemResolver>();
|
||||||
|
|
||||||
foreach (var resolver in multiItemResolvers)
|
foreach (var resolver in multiItemResolvers)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma warning disable CS1591
|
#pragma warning disable CS1591
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Frozen;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -26,7 +27,7 @@ namespace MediaBrowser.Model.Net
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Any extension in this list is considered a video file.
|
/// Any extension in this list is considered a video file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly HashSet<string> _videoFileExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
private static readonly FrozenSet<string> _videoFileExtensions = new[]
|
||||||
{
|
{
|
||||||
".3gp",
|
".3gp",
|
||||||
".asf",
|
".asf",
|
||||||
@ -57,90 +58,90 @@ namespace MediaBrowser.Model.Net
|
|||||||
".webm",
|
".webm",
|
||||||
".wmv",
|
".wmv",
|
||||||
".wtv",
|
".wtv",
|
||||||
};
|
}.ToFrozenSet(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used for extensions not in <see cref="Model.MimeTypes"/> or to override them.
|
/// Used for extensions not in <see cref="Model.MimeTypes"/> or to override them.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly Dictionary<string, string> _mimeTypeLookup = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
|
private static readonly FrozenDictionary<string, string> _mimeTypeLookup = new KeyValuePair<string, string>[]
|
||||||
{
|
{
|
||||||
// Type application
|
// Type application
|
||||||
{ ".azw3", "application/vnd.amazon.ebook" },
|
new(".azw3", "application/vnd.amazon.ebook"),
|
||||||
{ ".cb7", "application/x-cb7" },
|
new(".cb7", "application/x-cb7"),
|
||||||
{ ".cba", "application/x-cba" },
|
new(".cba", "application/x-cba"),
|
||||||
{ ".cbr", "application/vnd.comicbook-rar" },
|
new(".cbr", "application/vnd.comicbook-rar"),
|
||||||
{ ".cbt", "application/x-cbt" },
|
new(".cbt", "application/x-cbt"),
|
||||||
{ ".cbz", "application/vnd.comicbook+zip" },
|
new(".cbz", "application/vnd.comicbook+zip"),
|
||||||
|
|
||||||
// Type image
|
// Type image
|
||||||
{ ".tbn", "image/jpeg" },
|
new(".tbn", "image/jpeg"),
|
||||||
|
|
||||||
// Type text
|
// Type text
|
||||||
{ ".ass", "text/x-ssa" },
|
new(".ass", "text/x-ssa"),
|
||||||
{ ".ssa", "text/x-ssa" },
|
new(".ssa", "text/x-ssa"),
|
||||||
{ ".edl", "text/plain" },
|
new(".edl", "text/plain"),
|
||||||
{ ".html", "text/html; charset=UTF-8" },
|
new(".html", "text/html; charset=UTF-8"),
|
||||||
{ ".htm", "text/html; charset=UTF-8" },
|
new(".htm", "text/html; charset=UTF-8"),
|
||||||
|
|
||||||
// Type video
|
// Type video
|
||||||
{ ".mpegts", "video/mp2t" },
|
new(".mpegts", "video/mp2t"),
|
||||||
|
|
||||||
// Type audio
|
// Type audio
|
||||||
{ ".aac", "audio/aac" },
|
new(".aac", "audio/aac"),
|
||||||
{ ".ac3", "audio/ac3" },
|
new(".ac3", "audio/ac3"),
|
||||||
{ ".ape", "audio/x-ape" },
|
new(".ape", "audio/x-ape"),
|
||||||
{ ".dsf", "audio/dsf" },
|
new(".dsf", "audio/dsf"),
|
||||||
{ ".dsp", "audio/dsp" },
|
new(".dsp", "audio/dsp"),
|
||||||
{ ".flac", "audio/flac" },
|
new(".flac", "audio/flac"),
|
||||||
{ ".m4b", "audio/mp4" },
|
new(".m4b", "audio/mp4"),
|
||||||
{ ".mp3", "audio/mpeg" },
|
new(".mp3", "audio/mpeg"),
|
||||||
{ ".vorbis", "audio/vorbis" },
|
new(".vorbis", "audio/vorbis"),
|
||||||
{ ".webma", "audio/webm" },
|
new(".webma", "audio/webm"),
|
||||||
{ ".wv", "audio/x-wavpack" },
|
new(".wv", "audio/x-wavpack"),
|
||||||
{ ".xsp", "audio/xsp" },
|
new(".xsp", "audio/xsp"),
|
||||||
};
|
}.ToFrozenDictionary(pair => pair.Key, pair => pair.Value, StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
private static readonly Dictionary<string, string> _extensionLookup = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
|
private static readonly FrozenDictionary<string, string> _extensionLookup = new KeyValuePair<string, string>[]
|
||||||
{
|
{
|
||||||
// Type application
|
// Type application
|
||||||
{ "application/vnd.comicbook-rar", ".cbr" },
|
new("application/vnd.comicbook-rar", ".cbr"),
|
||||||
{ "application/vnd.comicbook+zip", ".cbz" },
|
new("application/vnd.comicbook+zip", ".cbz"),
|
||||||
{ "application/x-cb7", ".cb7" },
|
new("application/x-cb7", ".cb7"),
|
||||||
{ "application/x-cba", ".cba" },
|
new("application/x-cba", ".cba"),
|
||||||
{ "application/x-cbr", ".cbr" },
|
new("application/x-cbr", ".cbr"),
|
||||||
{ "application/x-cbt", ".cbt" },
|
new("application/x-cbt", ".cbt"),
|
||||||
{ "application/x-cbz", ".cbz" },
|
new("application/x-cbz", ".cbz"),
|
||||||
{ "application/x-javascript", ".js" },
|
new("application/x-javascript", ".js"),
|
||||||
{ "application/xml", ".xml" },
|
new("application/xml", ".xml"),
|
||||||
{ "application/x-mpegURL", ".m3u8" },
|
new("application/x-mpegURL", ".m3u8"),
|
||||||
|
|
||||||
// Type audio
|
// Type audio
|
||||||
{ "audio/aac", ".aac" },
|
new("audio/aac", ".aac"),
|
||||||
{ "audio/ac3", ".ac3" },
|
new("audio/ac3", ".ac3"),
|
||||||
{ "audio/dsf", ".dsf" },
|
new("audio/dsf", ".dsf"),
|
||||||
{ "audio/dsp", ".dsp" },
|
new("audio/dsp", ".dsp"),
|
||||||
{ "audio/flac", ".flac" },
|
new("audio/flac", ".flac"),
|
||||||
{ "audio/m4b", ".m4b" },
|
new("audio/m4b", ".m4b"),
|
||||||
{ "audio/vorbis", ".vorbis" },
|
new("audio/vorbis", ".vorbis"),
|
||||||
{ "audio/x-ape", ".ape" },
|
new("audio/x-ape", ".ape"),
|
||||||
{ "audio/xsp", ".xsp" },
|
new("audio/xsp", ".xsp"),
|
||||||
{ "audio/x-wavpack", ".wv" },
|
new("audio/x-wavpack", ".wv"),
|
||||||
|
|
||||||
// Type image
|
// Type image
|
||||||
{ "image/jpeg", ".jpg" },
|
new("image/jpeg", ".jpg"),
|
||||||
{ "image/tiff", ".tiff" },
|
new("image/tiff", ".tiff"),
|
||||||
{ "image/x-png", ".png" },
|
new("image/x-png", ".png"),
|
||||||
{ "image/x-icon", ".ico" },
|
new("image/x-icon", ".ico"),
|
||||||
|
|
||||||
// Type text
|
// Type text
|
||||||
{ "text/plain", ".txt" },
|
new("text/plain", ".txt"),
|
||||||
{ "text/rtf", ".rtf" },
|
new("text/rtf", ".rtf"),
|
||||||
{ "text/x-ssa", ".ssa" },
|
new("text/x-ssa", ".ssa"),
|
||||||
|
|
||||||
// Type video
|
// Type video
|
||||||
{ "video/vnd.mpeg.dash.mpd", ".mpd" },
|
new("video/vnd.mpeg.dash.mpd", ".mpd"),
|
||||||
{ "video/x-matroska", ".mkv" },
|
new("video/x-matroska", ".mkv"),
|
||||||
};
|
}.ToFrozenDictionary(pair => pair.Key, pair => pair.Value, StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
public static string GetMimeType(string path) => GetMimeType(path, "application/octet-stream");
|
public static string GetMimeType(string path) => GetMimeType(path, "application/octet-stream");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user