From c4f587dd94a4f21e033a6643493a76e5838f283e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 12 Mar 2014 15:56:12 -0400 Subject: live tv stream adjustments, add additional dlna params --- MediaBrowser.Controller/Entities/BaseItem.cs | 4 +- MediaBrowser.Controller/Entities/IHasImages.cs | 6 +- MediaBrowser.Controller/Library/TVUtils.cs | 160 ++++++++++----------- MediaBrowser.Controller/Net/IHttpResultFactory.cs | 12 ++ .../Providers/DirectoryService.cs | 30 +--- .../Providers/ILocalImageProvider.cs | 2 +- 6 files changed, 105 insertions(+), 109 deletions(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 0deebeb32..23f8ac31a 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1184,7 +1184,7 @@ namespace MediaBrowser.Controller.Entities return GetImageInfo(type, imageIndex) != null; } - public void SetImagePath(ImageType type, int index, FileInfo file) + public void SetImagePath(ImageType type, int index, FileSystemInfo file) { if (type == ImageType.Chapter) { @@ -1339,7 +1339,7 @@ namespace MediaBrowser.Controller.Entities /// The images. /// true if XXXX, false otherwise. /// Cannot call AddImages with chapter images - public bool AddImages(ImageType imageType, IEnumerable images) + public bool AddImages(ImageType imageType, IEnumerable images) { if (imageType == ImageType.Chapter) { diff --git a/MediaBrowser.Controller/Entities/IHasImages.cs b/MediaBrowser.Controller/Entities/IHasImages.cs index 8e66605dd..bac226369 100644 --- a/MediaBrowser.Controller/Entities/IHasImages.cs +++ b/MediaBrowser.Controller/Entities/IHasImages.cs @@ -62,7 +62,7 @@ namespace MediaBrowser.Controller.Entities /// The type. /// The index. /// The file. - void SetImagePath(ImageType type, int index, FileInfo file); + void SetImagePath(ImageType type, int index, FileSystemInfo file); /// /// Determines whether the specified type has image. @@ -129,7 +129,7 @@ namespace MediaBrowser.Controller.Entities /// Type of the image. /// The images. /// true if XXXX, false otherwise. - bool AddImages(ImageType imageType, IEnumerable images); + bool AddImages(ImageType imageType, IEnumerable images); /// /// Determines whether [is save local metadata enabled]. @@ -180,7 +180,7 @@ namespace MediaBrowser.Controller.Entities /// The item. /// Type of the image. /// The file. - public static void SetImagePath(this IHasImages item, ImageType imageType, FileInfo file) + public static void SetImagePath(this IHasImages item, ImageType imageType, FileSystemInfo file) { item.SetImagePath(imageType, 0, file); } diff --git a/MediaBrowser.Controller/Library/TVUtils.cs b/MediaBrowser.Controller/Library/TVUtils.cs index c64e4fa0c..7841a32ae 100644 --- a/MediaBrowser.Controller/Library/TVUtils.cs +++ b/MediaBrowser.Controller/Library/TVUtils.cs @@ -27,94 +27,94 @@ namespace MediaBrowser.Controller.Library /// /// A season folder must contain one of these somewhere in the name /// - private static readonly string[] SeasonFolderNames = new[] - { - "season", - "sæson", - "temporada", - "saison", - "staffel", - "series", - "сезон" - }; + private static readonly string[] SeasonFolderNames = + { + "season", + "sæson", + "temporada", + "saison", + "staffel", + "series", + "сезон" + }; /// /// Used to detect paths that represent episodes, need to make sure they don't also /// match movie titles like "2001 A Space..." /// Currently we limit the numbers here to 2 digits to try and avoid this /// - private static readonly Regex[] EpisodeExpressions = new[] - { - new Regex( - @".*(\\|\/)[sS]?(?\d{1,4})[xX](?\d{1,3})[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)[sS](?\d{1,4})[x,X]?[eE](?\d{1,3})[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)(?((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?\d{1,4})[xX](?\d{1,3}))[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)(?[^\\\/]*)[sS](?\d{1,4})[xX\.]?[eE](?\d{1,3})[^\\\/]*$", - RegexOptions.Compiled) - }; - private static readonly Regex[] MultipleEpisodeExpressions = new[] - { - new Regex( - @".*(\\|\/)[sS]?(?\d{1,4})[xX](?\d{1,3})((-| - )\d{1,4}[eExX](?\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)[sS]?(?\d{1,4})[xX](?\d{1,3})((-| - )\d{1,4}[xX][eE](?\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)[sS]?(?\d{1,4})[xX](?\d{1,3})((-| - )?[xXeE](?\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)[sS]?(?\d{1,4})[xX](?\d{1,3})(-[xE]?[eE]?(?\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)(?((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?\d{1,4})[xX](?\d{1,3}))((-| - )\d{1,4}[xXeE](?\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)(?((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?\d{1,4})[xX](?\d{1,3}))((-| - )\d{1,4}[xX][eE](?\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)(?((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?\d{1,4})[xX](?\d{1,3}))((-| - )?[xXeE](?\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)(?((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?\d{1,4})[xX](?\d{1,3}))(-[xX]?[eE]?(?\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)(?[^\\\/]*)[sS](?\d{1,4})[xX\.]?[eE](?\d{1,3})((-| - )?[xXeE](?\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)(?[^\\\/]*)[sS](?\d{1,4})[xX\.]?[eE](?\d{1,3})(-[xX]?[eE]?(?\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled) - }; + private static readonly Regex[] EpisodeExpressions = + { + new Regex( + @".*(\\|\/)[sS]?(?\d{1,4})[xX](?\d{1,3})[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)[sS](?\d{1,4})[x,X]?[eE](?\d{1,3})[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)(?((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?\d{1,4})[xX](?\d{1,3}))[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)(?[^\\\/]*)[sS](?\d{1,4})[xX\.]?[eE](?\d{1,3})[^\\\/]*$", + RegexOptions.Compiled) + }; + private static readonly Regex[] MultipleEpisodeExpressions = + { + new Regex( + @".*(\\|\/)[sS]?(?\d{1,4})[xX](?\d{1,3})((-| - )\d{1,4}[eExX](?\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)[sS]?(?\d{1,4})[xX](?\d{1,3})((-| - )\d{1,4}[xX][eE](?\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)[sS]?(?\d{1,4})[xX](?\d{1,3})((-| - )?[xXeE](?\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)[sS]?(?\d{1,4})[xX](?\d{1,3})(-[xE]?[eE]?(?\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)(?((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?\d{1,4})[xX](?\d{1,3}))((-| - )\d{1,4}[xXeE](?\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)(?((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?\d{1,4})[xX](?\d{1,3}))((-| - )\d{1,4}[xX][eE](?\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)(?((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?\d{1,4})[xX](?\d{1,3}))((-| - )?[xXeE](?\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)(?((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?\d{1,4})[xX](?\d{1,3}))(-[xX]?[eE]?(?\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)(?[^\\\/]*)[sS](?\d{1,4})[xX\.]?[eE](?\d{1,3})((-| - )?[xXeE](?\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)(?[^\\\/]*)[sS](?\d{1,4})[xX\.]?[eE](?\d{1,3})(-[xX]?[eE]?(?\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled) + }; /// /// To avoid the following matching movies they are only valid when contained in a folder which has been matched as a being season /// - private static readonly Regex[] EpisodeExpressionsInASeasonFolder = new[] - { - new Regex( - @".*(\\|\/)(?\d{1,2})\s?-\s?[^\\\/]*$", - RegexOptions.Compiled), - // 01 - blah.avi, 01-blah.avi - new Regex( - @".*(\\|\/)(?\d{1,2})[^\d\\]*[^\\\/]*$", - RegexOptions.Compiled), - // 01.avi, 01.blah.avi "01 - 22 blah.avi" - new Regex( - @".*(\\|\/)(?\d)(?\d{1,2})[^\d\\]+[^\\\/]*$", - RegexOptions.Compiled), - // 01.avi, 01.blah.avi - new Regex( - @".*(\\|\/)\D*\d+(?\d{2})", - RegexOptions.Compiled) - // hell0 - 101 - hello.avi - - }; + private static readonly Regex[] EpisodeExpressionsInASeasonFolder = + { + new Regex( + @".*(\\|\/)(?\d{1,2})\s?-\s?[^\\\/]*$", + RegexOptions.Compiled), + // 01 - blah.avi, 01-blah.avi + new Regex( + @".*(\\|\/)(?\d{1,2})[^\d\\]*[^\\\/]*$", + RegexOptions.Compiled), + // 01.avi, 01.blah.avi "01 - 22 blah.avi" + new Regex( + @".*(\\|\/)(?\d)(?\d{1,2})[^\d\\]+[^\\\/]*$", + RegexOptions.Compiled), + // 01.avi, 01.blah.avi + new Regex( + @".*(\\|\/)\D*\d+(?\d{2})", + RegexOptions.Compiled) + // hell0 - 101 - hello.avi + + }; /// /// Gets the season number from path. @@ -151,8 +151,8 @@ namespace MediaBrowser.Controller.Library /// System.Nullable{System.Int32}. private static int? GetSeasonNumberFromPathSubstring(string path) { - int numericStart = -1; - int length = 0; + var numericStart = -1; + var length = 0; // Find out where the numbers start, and then keep going until they end for (var i = 0; i < path.Length; i++) diff --git a/MediaBrowser.Controller/Net/IHttpResultFactory.cs b/MediaBrowser.Controller/Net/IHttpResultFactory.cs index b7dff96cd..f7984c32c 100644 --- a/MediaBrowser.Controller/Net/IHttpResultFactory.cs +++ b/MediaBrowser.Controller/Net/IHttpResultFactory.cs @@ -95,6 +95,18 @@ namespace MediaBrowser.Controller.Net /// System.Object. object GetStaticFileResult(IRequest requestContext, string path, FileShare fileShare = FileShare.Read, IDictionary responseHeaders = null, bool isHeadRequest = false); + /// + /// Gets the static file result. + /// + /// The request context. + /// The path. + /// Type of the content. + /// The file share. + /// The response headers. + /// if set to true [is head request]. + /// System.Object. + object GetStaticFileResult(IRequest requestContext, string path, string contentType, FileShare fileShare = FileShare.Read, IDictionary responseHeaders = null, bool isHeadRequest = false); + /// /// Gets the optimized serialized result using cache. /// diff --git a/MediaBrowser.Controller/Providers/DirectoryService.cs b/MediaBrowser.Controller/Providers/DirectoryService.cs index 751de9fb4..9d41b6d25 100644 --- a/MediaBrowser.Controller/Providers/DirectoryService.cs +++ b/MediaBrowser.Controller/Providers/DirectoryService.cs @@ -1,6 +1,6 @@ -using System.Collections.Concurrent; -using MediaBrowser.Model.Logging; +using MediaBrowser.Model.Logging; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; @@ -10,10 +10,8 @@ namespace MediaBrowser.Controller.Providers public interface IDirectoryService { List GetFileSystemEntries(string path); - IEnumerable GetFiles(string path); - IEnumerable GetDirectories(string path); - FileInfo GetFile(string path); - DirectoryInfo GetDirectory(string path); + IEnumerable GetFiles(string path); + FileSystemInfo GetFile(string path); } public class DirectoryService : IDirectoryService @@ -50,31 +48,17 @@ namespace MediaBrowser.Controller.Providers return entries; } - public IEnumerable GetFiles(string path) + public IEnumerable GetFiles(string path) { - return GetFileSystemEntries(path).OfType(); + return GetFileSystemEntries(path).Where(i => (i.Attributes & FileAttributes.Directory) != FileAttributes.Directory); } - public IEnumerable GetDirectories(string path) - { - return GetFileSystemEntries(path).OfType(); - } - - public FileInfo GetFile(string path) + public FileSystemInfo GetFile(string path) { var directory = Path.GetDirectoryName(path); var filename = Path.GetFileName(path); return GetFiles(directory).FirstOrDefault(i => string.Equals(i.Name, filename, StringComparison.OrdinalIgnoreCase)); } - - - public DirectoryInfo GetDirectory(string path) - { - var directory = Path.GetDirectoryName(path); - var name = Path.GetFileName(path); - - return GetDirectories(directory).FirstOrDefault(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase)); - } } } diff --git a/MediaBrowser.Controller/Providers/ILocalImageProvider.cs b/MediaBrowser.Controller/Providers/ILocalImageProvider.cs index ec24e1d60..68afb84b8 100644 --- a/MediaBrowser.Controller/Providers/ILocalImageProvider.cs +++ b/MediaBrowser.Controller/Providers/ILocalImageProvider.cs @@ -23,7 +23,7 @@ namespace MediaBrowser.Controller.Providers public class LocalImageInfo { - public FileInfo FileInfo { get; set; } + public FileSystemInfo FileInfo { get; set; } public ImageType Type { get; set; } } -- cgit v1.2.3