mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-28 02:21:00 +01:00
resolve wtv transcoding
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Common.Net
|
||||
{
|
||||
@@ -13,6 +15,65 @@ namespace MediaBrowser.Common.Net
|
||||
/// </summary>
|
||||
public static string JsonMimeType = "application/json";
|
||||
|
||||
/// <summary>
|
||||
/// Any extension in this list is considered a video file - can be added to at runtime for extensibility
|
||||
/// </summary>
|
||||
private static readonly List<string> VideoFileExtensions = new List<string>
|
||||
{
|
||||
".mkv",
|
||||
".m2t",
|
||||
".m2ts",
|
||||
".img",
|
||||
".iso",
|
||||
".mk3d",
|
||||
".ts",
|
||||
".rmvb",
|
||||
".mov",
|
||||
".avi",
|
||||
".mpg",
|
||||
".mpeg",
|
||||
".wmv",
|
||||
".mp4",
|
||||
".divx",
|
||||
".dvr-ms",
|
||||
".wtv",
|
||||
".ogm",
|
||||
".ogv",
|
||||
".asf",
|
||||
".m4v",
|
||||
".flv",
|
||||
".f4v",
|
||||
".3gp",
|
||||
".webm",
|
||||
".mts",
|
||||
".m2v",
|
||||
".rec"
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, string> VideoFileExtensionsDictionary = VideoFileExtensions.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is video file] [the specified path].
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns><c>true</c> if [is video file] [the specified path]; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsVideoFile(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentNullException("path");
|
||||
}
|
||||
|
||||
var extension = Path.GetExtension(path);
|
||||
|
||||
if (string.IsNullOrEmpty(extension))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return VideoFileExtensionsDictionary.ContainsKey(extension);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the MIME.
|
||||
/// </summary>
|
||||
@@ -26,7 +87,7 @@ namespace MediaBrowser.Common.Net
|
||||
{
|
||||
throw new ArgumentNullException("path");
|
||||
}
|
||||
|
||||
|
||||
var ext = Path.GetExtension(path) ?? string.Empty;
|
||||
|
||||
// http://en.wikipedia.org/wiki/Internet_media_type
|
||||
@@ -37,10 +98,6 @@ namespace MediaBrowser.Common.Net
|
||||
{
|
||||
return "video/mpeg";
|
||||
}
|
||||
if (ext.Equals(".mp4", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "video/mp4";
|
||||
}
|
||||
if (ext.Equals(".ogv", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "video/ogg";
|
||||
@@ -90,6 +147,12 @@ namespace MediaBrowser.Common.Net
|
||||
return "video/mp2t";
|
||||
}
|
||||
|
||||
// Catch-all for all video types that don't require specific mime types
|
||||
if (VideoFileExtensionsDictionary.ContainsKey(ext))
|
||||
{
|
||||
return "video/" + ext.TrimStart('.').ToLower();
|
||||
}
|
||||
|
||||
// Type text
|
||||
if (ext.Equals(".css", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -152,7 +215,7 @@ namespace MediaBrowser.Common.Net
|
||||
return "image/vnd.microsoft.icon";
|
||||
}
|
||||
|
||||
// Type audio
|
||||
// Type audio
|
||||
if (ext.Equals(".mp3", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "audio/mpeg";
|
||||
|
||||
Reference in New Issue
Block a user