diff options
| author | 7illusions <z@7illusions.com> | 2014-03-12 21:04:37 +0100 |
|---|---|---|
| committer | 7illusions <z@7illusions.com> | 2014-03-12 21:04:37 +0100 |
| commit | b2df3d648d64982528907bbd716b2c1984fb1345 (patch) | |
| tree | 7bc6bed22253d3dcc468e155c74e30bae7a468fb /MediaBrowser.Controller | |
| parent | 438b0078ccd07e39cbf95b737d676a39192d064c (diff) | |
| parent | 37a69d78e1064afaa14e333abd0ede71b92dd216 (diff) | |
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Diffstat (limited to 'MediaBrowser.Controller')
| -rw-r--r-- | MediaBrowser.Controller/Entities/BaseItem.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/IHasImages.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Library/TVUtils.cs | 160 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Net/IHttpResultFactory.cs | 12 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Providers/DirectoryService.cs | 30 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Providers/ILocalImageProvider.cs | 2 |
6 files changed, 105 insertions, 109 deletions
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 /// <param name="images">The images.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> /// <exception cref="System.ArgumentException">Cannot call AddImages with chapter images</exception> - public bool AddImages(ImageType imageType, IEnumerable<FileInfo> images) + public bool AddImages(ImageType imageType, IEnumerable<FileSystemInfo> 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 /// <param name="type">The type.</param> /// <param name="index">The index.</param> /// <param name="file">The file.</param> - void SetImagePath(ImageType type, int index, FileInfo file); + void SetImagePath(ImageType type, int index, FileSystemInfo file); /// <summary> /// Determines whether the specified type has image. @@ -129,7 +129,7 @@ namespace MediaBrowser.Controller.Entities /// <param name="imageType">Type of the image.</param> /// <param name="images">The images.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> - bool AddImages(ImageType imageType, IEnumerable<FileInfo> images); + bool AddImages(ImageType imageType, IEnumerable<FileSystemInfo> images); /// <summary> /// Determines whether [is save local metadata enabled]. @@ -180,7 +180,7 @@ namespace MediaBrowser.Controller.Entities /// <param name="item">The item.</param> /// <param name="imageType">Type of the image.</param> /// <param name="file">The file.</param> - 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 /// <summary> /// A season folder must contain one of these somewhere in the name /// </summary> - 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", + "сезон" + }; /// <summary> /// 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 /// </summary> - private static readonly Regex[] EpisodeExpressions = new[] - { - new Regex( - @".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)[sS](?<seasonnumber>\d{1,4})[x,X]?[eE](?<epnumber>\d{1,3})[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})[^\\\/]*$", - RegexOptions.Compiled) - }; - private static readonly Regex[] MultipleEpisodeExpressions = new[] - { - new Regex( - @".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})((-| - )\d{1,4}[eExX](?<endingepnumber>\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})((-| - )\d{1,4}[xX][eE](?<endingepnumber>\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})(-[xE]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))((-| - )\d{1,4}[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))((-| - )\d{1,4}[xX][eE](?<endingepnumber>\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))(-[xX]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled), - new Regex( - @".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})(-[xX]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\\/]*$", - RegexOptions.Compiled) - }; + private static readonly Regex[] EpisodeExpressions = + { + new Regex( + @".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)[sS](?<seasonnumber>\d{1,4})[x,X]?[eE](?<epnumber>\d{1,3})[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})[^\\\/]*$", + RegexOptions.Compiled) + }; + private static readonly Regex[] MultipleEpisodeExpressions = + { + new Regex( + @".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})((-| - )\d{1,4}[eExX](?<endingepnumber>\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})((-| - )\d{1,4}[xX][eE](?<endingepnumber>\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})(-[xE]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))((-| - )\d{1,4}[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))((-| - )\d{1,4}[xX][eE](?<endingepnumber>\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\\/])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))(-[xX]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled), + new Regex( + @".*(\\|\/)(?<seriesname>[^\\\/]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})(-[xX]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\\/]*$", + RegexOptions.Compiled) + }; /// <summary> /// To avoid the following matching movies they are only valid when contained in a folder which has been matched as a being season /// </summary> - private static readonly Regex[] EpisodeExpressionsInASeasonFolder = new[] - { - new Regex( - @".*(\\|\/)(?<epnumber>\d{1,2})\s?-\s?[^\\\/]*$", - RegexOptions.Compiled), - // 01 - blah.avi, 01-blah.avi - new Regex( - @".*(\\|\/)(?<epnumber>\d{1,2})[^\d\\]*[^\\\/]*$", - RegexOptions.Compiled), - // 01.avi, 01.blah.avi "01 - 22 blah.avi" - new Regex( - @".*(\\|\/)(?<seasonnumber>\d)(?<epnumber>\d{1,2})[^\d\\]+[^\\\/]*$", - RegexOptions.Compiled), - // 01.avi, 01.blah.avi - new Regex( - @".*(\\|\/)\D*\d+(?<epnumber>\d{2})", - RegexOptions.Compiled) - // hell0 - 101 - hello.avi - - }; + private static readonly Regex[] EpisodeExpressionsInASeasonFolder = + { + new Regex( + @".*(\\|\/)(?<epnumber>\d{1,2})\s?-\s?[^\\\/]*$", + RegexOptions.Compiled), + // 01 - blah.avi, 01-blah.avi + new Regex( + @".*(\\|\/)(?<epnumber>\d{1,2})[^\d\\]*[^\\\/]*$", + RegexOptions.Compiled), + // 01.avi, 01.blah.avi "01 - 22 blah.avi" + new Regex( + @".*(\\|\/)(?<seasonnumber>\d)(?<epnumber>\d{1,2})[^\d\\]+[^\\\/]*$", + RegexOptions.Compiled), + // 01.avi, 01.blah.avi + new Regex( + @".*(\\|\/)\D*\d+(?<epnumber>\d{2})", + RegexOptions.Compiled) + // hell0 - 101 - hello.avi + + }; /// <summary> /// Gets the season number from path. @@ -151,8 +151,8 @@ namespace MediaBrowser.Controller.Library /// <returns>System.Nullable{System.Int32}.</returns> 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 @@ -96,6 +96,18 @@ namespace MediaBrowser.Controller.Net object GetStaticFileResult(IRequest requestContext, string path, FileShare fileShare = FileShare.Read, IDictionary<string, string> responseHeaders = null, bool isHeadRequest = false); /// <summary> + /// Gets the static file result. + /// </summary> + /// <param name="requestContext">The request context.</param> + /// <param name="path">The path.</param> + /// <param name="contentType">Type of the content.</param> + /// <param name="fileShare">The file share.</param> + /// <param name="responseHeaders">The response headers.</param> + /// <param name="isHeadRequest">if set to <c>true</c> [is head request].</param> + /// <returns>System.Object.</returns> + object GetStaticFileResult(IRequest requestContext, string path, string contentType, FileShare fileShare = FileShare.Read, IDictionary<string, string> responseHeaders = null, bool isHeadRequest = false); + + /// <summary> /// Gets the optimized serialized result using cache. /// </summary> /// <typeparam name="T"></typeparam> 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<FileSystemInfo> GetFileSystemEntries(string path); - IEnumerable<FileInfo> GetFiles(string path); - IEnumerable<DirectoryInfo> GetDirectories(string path); - FileInfo GetFile(string path); - DirectoryInfo GetDirectory(string path); + IEnumerable<FileSystemInfo> GetFiles(string path); + FileSystemInfo GetFile(string path); } public class DirectoryService : IDirectoryService @@ -50,31 +48,17 @@ namespace MediaBrowser.Controller.Providers return entries; } - public IEnumerable<FileInfo> GetFiles(string path) + public IEnumerable<FileSystemInfo> GetFiles(string path) { - return GetFileSystemEntries(path).OfType<FileInfo>(); + return GetFileSystemEntries(path).Where(i => (i.Attributes & FileAttributes.Directory) != FileAttributes.Directory); } - public IEnumerable<DirectoryInfo> GetDirectories(string path) - { - return GetFileSystemEntries(path).OfType<DirectoryInfo>(); - } - - 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; } } |
