|
|
@ -12,9 +12,9 @@ namespace MediaBrowser.Model.Net
|
|
|
|
public static class MimeTypes
|
|
|
|
public static class MimeTypes
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Any extension in this list is considered a video file - can be added to at runtime for extensibility
|
|
|
|
/// Any extension in this list is considered a video file
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
private static readonly string[] VideoFileExtensions = new string[]
|
|
|
|
private static readonly HashSet<string> _videoFileExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
".mkv",
|
|
|
|
".mkv",
|
|
|
|
".m2t",
|
|
|
|
".m2t",
|
|
|
@ -46,79 +46,99 @@ namespace MediaBrowser.Model.Net
|
|
|
|
".rec"
|
|
|
|
".rec"
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private static Dictionary<string, string> GetVideoFileExtensionsDictionary()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var dict = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (string ext in VideoFileExtensions)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dict[ext] = ext;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return dict;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly Dictionary<string, string> VideoFileExtensionsDictionary = GetVideoFileExtensionsDictionary();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// http://en.wikipedia.org/wiki/Internet_media_type
|
|
|
|
// http://en.wikipedia.org/wiki/Internet_media_type
|
|
|
|
// Add more as needed
|
|
|
|
// Add more as needed
|
|
|
|
|
|
|
|
private static readonly Dictionary<string, string> _mimeTypeLookup = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Type application
|
|
|
|
|
|
|
|
{ ".cbz", "application/x-cbz" },
|
|
|
|
|
|
|
|
{ ".cbr", "application/epub+zip" },
|
|
|
|
|
|
|
|
{ ".eot", "application/vnd.ms-fontobject" },
|
|
|
|
|
|
|
|
{ ".epub", "application/epub+zip" },
|
|
|
|
|
|
|
|
{ ".js", "application/x-javascript" },
|
|
|
|
|
|
|
|
{ ".json", "application/json" },
|
|
|
|
|
|
|
|
{ ".map", "application/x-javascript" },
|
|
|
|
|
|
|
|
{ ".pdf", "application/pdf" },
|
|
|
|
|
|
|
|
{ ".ttml", "application/ttml+xml" },
|
|
|
|
|
|
|
|
{ ".m3u8", "application/x-mpegURL" },
|
|
|
|
|
|
|
|
{ ".mobi", "application/x-mobipocket-ebook" },
|
|
|
|
|
|
|
|
{ ".xml", "application/xml" },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Type image
|
|
|
|
|
|
|
|
{ ".jpg", "image/jpeg" },
|
|
|
|
|
|
|
|
{ ".jpeg", "image/jpeg" },
|
|
|
|
|
|
|
|
{ ".tbn", "image/jpeg" },
|
|
|
|
|
|
|
|
{ ".png", "image/png" },
|
|
|
|
|
|
|
|
{ ".gif", "image/gif" },
|
|
|
|
|
|
|
|
{ ".tiff", "image/tiff" },
|
|
|
|
|
|
|
|
{ ".webp", "image/webp" },
|
|
|
|
|
|
|
|
{ ".ico", "image/vnd.microsoft.icon" },
|
|
|
|
|
|
|
|
{ ".svg", "image/svg+xml" },
|
|
|
|
|
|
|
|
{ ".svgz", "image/svg+xml" },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Type font
|
|
|
|
|
|
|
|
{ ".ttf" , "font/ttf" },
|
|
|
|
|
|
|
|
{ ".woff" , "font/woff" },
|
|
|
|
|
|
|
|
|
|
|
|
private static Dictionary<string, string> GetMimeTypeLookup()
|
|
|
|
// Type text
|
|
|
|
{
|
|
|
|
{ ".ass", "text/x-ssa" },
|
|
|
|
var dict = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
|
|
|
{ ".ssa", "text/x-ssa" },
|
|
|
|
|
|
|
|
{ ".css", "text/css" },
|
|
|
|
dict.Add(".jpg", "image/jpeg");
|
|
|
|
{ ".csv", "text/csv" },
|
|
|
|
dict.Add(".jpeg", "image/jpeg");
|
|
|
|
{ ".txt", "text/plain" },
|
|
|
|
dict.Add(".tbn", "image/jpeg");
|
|
|
|
{ ".vtt", "text/vtt" },
|
|
|
|
dict.Add(".png", "image/png");
|
|
|
|
|
|
|
|
dict.Add(".gif", "image/gif");
|
|
|
|
|
|
|
|
dict.Add(".tiff", "image/tiff");
|
|
|
|
|
|
|
|
dict.Add(".webp", "image/webp");
|
|
|
|
|
|
|
|
dict.Add(".ico", "image/vnd.microsoft.icon");
|
|
|
|
|
|
|
|
dict.Add(".mpg", "video/mpeg");
|
|
|
|
|
|
|
|
dict.Add(".mpeg", "video/mpeg");
|
|
|
|
|
|
|
|
dict.Add(".ogv", "video/ogg");
|
|
|
|
|
|
|
|
dict.Add(".mov", "video/quicktime");
|
|
|
|
|
|
|
|
dict.Add(".webm", "video/webm");
|
|
|
|
|
|
|
|
dict.Add(".mkv", "video/x-matroska");
|
|
|
|
|
|
|
|
dict.Add(".wmv", "video/x-ms-wmv");
|
|
|
|
|
|
|
|
dict.Add(".flv", "video/x-flv");
|
|
|
|
|
|
|
|
dict.Add(".avi", "video/x-msvideo");
|
|
|
|
|
|
|
|
dict.Add(".asf", "video/x-ms-asf");
|
|
|
|
|
|
|
|
dict.Add(".m4v", "video/x-m4v");
|
|
|
|
|
|
|
|
dict.Add(".m4s", "video/mp4");
|
|
|
|
|
|
|
|
dict.Add(".cbz", "application/x-cbz");
|
|
|
|
|
|
|
|
dict.Add(".cbr", "application/epub+zip");
|
|
|
|
|
|
|
|
dict.Add(".epub", "application/epub+zip");
|
|
|
|
|
|
|
|
dict.Add(".pdf", "application/pdf");
|
|
|
|
|
|
|
|
dict.Add(".mobi", "application/x-mobipocket-ebook");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dict.Add(".ass", "text/x-ssa");
|
|
|
|
|
|
|
|
dict.Add(".ssa", "text/x-ssa");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return dict;
|
|
|
|
// Type video
|
|
|
|
}
|
|
|
|
{ ".mpg", "video/mpeg" },
|
|
|
|
|
|
|
|
{ ".ogv", "video/ogg" },
|
|
|
|
|
|
|
|
{ ".mov", "video/quicktime" },
|
|
|
|
|
|
|
|
{ ".webm", "video/webm" },
|
|
|
|
|
|
|
|
{ ".mkv", "video/x-matroska" },
|
|
|
|
|
|
|
|
{ ".wmv", "video/x-ms-wmv" },
|
|
|
|
|
|
|
|
{ ".flv", "video/x-flv" },
|
|
|
|
|
|
|
|
{ ".avi", "video/x-msvideo" },
|
|
|
|
|
|
|
|
{ ".asf", "video/x-ms-asf" },
|
|
|
|
|
|
|
|
{ ".m4v", "video/x-m4v" },
|
|
|
|
|
|
|
|
{ ".m4s", "video/mp4" },
|
|
|
|
|
|
|
|
{ ".3gp", "video/3gpp" },
|
|
|
|
|
|
|
|
{ ".3g2", "video/3gpp2" },
|
|
|
|
|
|
|
|
{ ".mpd", "video/vnd.mpeg.dash.mpd" },
|
|
|
|
|
|
|
|
{ ".ts", "video/mp2t" },
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly Dictionary<string, string> MimeTypeLookup = GetMimeTypeLookup();
|
|
|
|
// Type audio
|
|
|
|
|
|
|
|
{ ".mp3", "audio/mpeg" },
|
|
|
|
|
|
|
|
{ ".m4a", "audio/mp4" },
|
|
|
|
|
|
|
|
{ ".aac", "audio/mp4" },
|
|
|
|
|
|
|
|
{ ".webma", "audio/webm" },
|
|
|
|
|
|
|
|
{ ".wav", "audio/wav" },
|
|
|
|
|
|
|
|
{ ".wma", "audio/x-ms-wma" },
|
|
|
|
|
|
|
|
{ ".ogg", "audio/ogg" },
|
|
|
|
|
|
|
|
{ ".oga", "audio/ogg" },
|
|
|
|
|
|
|
|
{ ".opus", "audio/ogg" },
|
|
|
|
|
|
|
|
{ ".ac3", "audio/ac3" },
|
|
|
|
|
|
|
|
{ ".dsf", "audio/dsf" },
|
|
|
|
|
|
|
|
{ ".m4b", "audio/m4b" },
|
|
|
|
|
|
|
|
{ ".xsp", "audio/xsp" },
|
|
|
|
|
|
|
|
{ ".dsp", "audio/dsp" },
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly Dictionary<string, string> ExtensionLookup = CreateExtensionLookup();
|
|
|
|
private static readonly Dictionary<string, string> _extensionLookup = CreateExtensionLookup();
|
|
|
|
|
|
|
|
|
|
|
|
private static Dictionary<string, string> CreateExtensionLookup()
|
|
|
|
private static Dictionary<string, string> CreateExtensionLookup()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var dict = MimeTypeLookup
|
|
|
|
var dict = _mimeTypeLookup
|
|
|
|
.GroupBy(i => i.Value)
|
|
|
|
.GroupBy(i => i.Value)
|
|
|
|
.ToDictionary(x => x.Key, x => x.First().Key, StringComparer.OrdinalIgnoreCase);
|
|
|
|
.ToDictionary(x => x.Key, x => x.First().Key, StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
|
|
|
|
|
|
|
dict["image/jpg"] = ".jpg";
|
|
|
|
dict["image/jpg"] = ".jpg";
|
|
|
|
dict["image/x-png"] = ".png";
|
|
|
|
dict["image/x-png"] = ".png";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dict["audio/x-aac"] = ".aac";
|
|
|
|
|
|
|
|
|
|
|
|
return dict;
|
|
|
|
return dict;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string GetMimeType(string path)
|
|
|
|
public static string GetMimeType(string path) => GetMimeType(path, true);
|
|
|
|
{
|
|
|
|
|
|
|
|
return GetMimeType(path, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the type of the MIME.
|
|
|
|
/// Gets the type of the MIME.
|
|
|
@ -130,137 +150,30 @@ namespace MediaBrowser.Model.Net
|
|
|
|
throw new ArgumentNullException(nameof(path));
|
|
|
|
throw new ArgumentNullException(nameof(path));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var ext = Path.GetExtension(path) ?? string.Empty;
|
|
|
|
var ext = Path.GetExtension(path);
|
|
|
|
|
|
|
|
|
|
|
|
if (MimeTypeLookup.TryGetValue(ext, out string result))
|
|
|
|
if (_mimeTypeLookup.TryGetValue(ext, out string result))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Type video
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".3gp"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "video/3gpp";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".3g2"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "video/3gpp2";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".ts"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "video/mp2t";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".mpd"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "video/vnd.mpeg.dash.mpd";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Catch-all for all video types that don't require specific mime types
|
|
|
|
// Catch-all for all video types that don't require specific mime types
|
|
|
|
if (VideoFileExtensionsDictionary.ContainsKey(ext))
|
|
|
|
if (_videoFileExtensions.Contains(ext))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return "video/" + ext.TrimStart('.').ToLowerInvariant();
|
|
|
|
return "video/" + ext.Substring(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Type text
|
|
|
|
// Type text
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".css"))
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".html")
|
|
|
|
{
|
|
|
|
|| StringHelper.EqualsIgnoreCase(ext, ".htm"))
|
|
|
|
return "text/css";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".csv"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "text/csv";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".html"))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return "text/html; charset=UTF-8";
|
|
|
|
return "text/html; charset=UTF-8";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".htm"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "text/html; charset=UTF-8";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".txt"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "text/plain";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".log"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "text/plain";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".xml"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "application/xml";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Type audio
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".mp3"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "audio/mpeg";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".m4a"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "audio/mp4";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".aac"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "audio/mp4";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".webma"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "audio/webm";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".wav"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "audio/wav";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".wma"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "audio/x-ms-wma";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".flac"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "audio/flac";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".aac"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "audio/x-aac";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".ogg"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "audio/ogg";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".oga"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "audio/ogg";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".opus"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "audio/ogg";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".ac3"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "audio/ac3";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".dsf"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "audio/dsf";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".m4b"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "audio/m4b";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".xsp"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "audio/xsp";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".dsp"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "audio/dsp";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Playlists
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".log")
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".m3u8"))
|
|
|
|
|| StringHelper.EqualsIgnoreCase(ext, ".srt"))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return "application/x-mpegURL";
|
|
|
|
return "text/plain";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Misc
|
|
|
|
// Misc
|
|
|
@ -269,63 +182,7 @@ namespace MediaBrowser.Model.Net
|
|
|
|
return "application/octet-stream";
|
|
|
|
return "application/octet-stream";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Web
|
|
|
|
return enableStreamDefault ? "application/octet-stream" : null;
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".js"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "application/x-javascript";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".json"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "application/json";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".map"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "application/x-javascript";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".woff"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "font/woff";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".ttf"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "font/ttf";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".eot"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "application/vnd.ms-fontobject";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".svg"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "image/svg+xml";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".svgz"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "image/svg+xml";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".srt"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "text/plain";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".vtt"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "text/vtt";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringHelper.EqualsIgnoreCase(ext, ".ttml"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "application/ttml+xml";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (enableStreamDefault)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "application/octet-stream";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string ToExtension(string mimeType)
|
|
|
|
public static string ToExtension(string mimeType)
|
|
|
@ -338,10 +195,11 @@ namespace MediaBrowser.Model.Net
|
|
|
|
// handle text/html; charset=UTF-8
|
|
|
|
// handle text/html; charset=UTF-8
|
|
|
|
mimeType = mimeType.Split(';')[0];
|
|
|
|
mimeType = mimeType.Split(';')[0];
|
|
|
|
|
|
|
|
|
|
|
|
if (ExtensionLookup.TryGetValue(mimeType, out string result))
|
|
|
|
if (_extensionLookup.TryGetValue(mimeType, out string result))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|