From 54a36322bb19ceaeb9f4ae3a01fa54998d243ec8 Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Sun, 3 Mar 2013 11:53:58 -0500 Subject: made base video resolver available for re-use --- .../Library/EntityResolutionHelper.cs | 97 ---------------------- MediaBrowser.Controller/Library/IItemResolver.cs | 22 ----- MediaBrowser.Controller/Library/ILibraryManager.cs | 1 + .../Library/IResolverIgnoreRule.cs | 10 --- .../Library/ResolverPriority.cs | 26 ------ MediaBrowser.Controller/Library/TVUtils.cs | 1 + 6 files changed, 2 insertions(+), 155 deletions(-) delete mode 100644 MediaBrowser.Controller/Library/EntityResolutionHelper.cs delete mode 100644 MediaBrowser.Controller/Library/IItemResolver.cs delete mode 100644 MediaBrowser.Controller/Library/IResolverIgnoreRule.cs delete mode 100644 MediaBrowser.Controller/Library/ResolverPriority.cs (limited to 'MediaBrowser.Controller/Library') diff --git a/MediaBrowser.Controller/Library/EntityResolutionHelper.cs b/MediaBrowser.Controller/Library/EntityResolutionHelper.cs deleted file mode 100644 index 07e0b5a11..000000000 --- a/MediaBrowser.Controller/Library/EntityResolutionHelper.cs +++ /dev/null @@ -1,97 +0,0 @@ -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.IO; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace MediaBrowser.Controller.Library -{ - /// - /// Class EntityResolutionHelper - /// - public static class EntityResolutionHelper - { - /// - /// Any extension in this list is considered a video file - can be added to at runtime for extensibility - /// - public static List VideoFileExtensions = new List - { - ".mkv", - ".m2t", - ".m2ts", - ".img", - ".iso", - ".ts", - ".rmvb", - ".mov", - ".avi", - ".mpg", - ".mpeg", - ".wmv", - ".mp4", - ".divx", - ".dvr-ms", - ".wtv", - ".ogm", - ".ogv", - ".asf", - ".m4v", - ".flv", - ".f4v", - ".3gp", - ".webm" - }; - - /// - /// Determines whether [is video file] [the specified path]. - /// - /// The path. - /// true if [is video file] [the specified path]; otherwise, false. - public static bool IsVideoFile(string path) - { - var extension = Path.GetExtension(path) ?? string.Empty; - return VideoFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase); - } - - /// - /// Ensures DateCreated and DateModified have values - /// - /// The item. - /// The args. - public static void EnsureDates(BaseItem item, ItemResolveArgs args) - { - if (!Path.IsPathRooted(item.Path)) - { - return; - } - - // See if a different path came out of the resolver than what went in - if (!args.Path.Equals(item.Path, StringComparison.OrdinalIgnoreCase)) - { - var childData = args.IsDirectory ? args.GetFileSystemEntryByPath(item.Path) : null; - - if (childData.HasValue) - { - item.DateCreated = childData.Value.CreationTimeUtc; - item.DateModified = childData.Value.LastWriteTimeUtc; - } - else - { - var fileData = FileSystem.GetFileData(item.Path); - - if (fileData.HasValue) - { - item.DateCreated = fileData.Value.CreationTimeUtc; - item.DateModified = fileData.Value.LastWriteTimeUtc; - } - } - } - else - { - item.DateCreated = args.FileInfo.CreationTimeUtc; - item.DateModified = args.FileInfo.LastWriteTimeUtc; - } - } - } -} diff --git a/MediaBrowser.Controller/Library/IItemResolver.cs b/MediaBrowser.Controller/Library/IItemResolver.cs deleted file mode 100644 index 721b787d3..000000000 --- a/MediaBrowser.Controller/Library/IItemResolver.cs +++ /dev/null @@ -1,22 +0,0 @@ -using MediaBrowser.Controller.Entities; - -namespace MediaBrowser.Controller.Library -{ - /// - /// Interface IItemResolver - /// - public interface IItemResolver - { - /// - /// Resolves the path. - /// - /// The args. - /// BaseItem. - BaseItem ResolvePath(ItemResolveArgs args); - /// - /// Gets the priority. - /// - /// The priority. - ResolverPriority Priority { get; } - } -} diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 7ba60e921..3f1930209 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -1,5 +1,6 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.IO; +using MediaBrowser.Controller.Resolvers; using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; diff --git a/MediaBrowser.Controller/Library/IResolverIgnoreRule.cs b/MediaBrowser.Controller/Library/IResolverIgnoreRule.cs deleted file mode 100644 index c9c602089..000000000 --- a/MediaBrowser.Controller/Library/IResolverIgnoreRule.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MediaBrowser.Controller.Library -{ - /// - /// Provides a base "rule" that anyone can use to have paths ignored by the resolver - /// - public interface IResolverIgnoreRule - { - bool ShouldIgnore(ItemResolveArgs args); - } -} diff --git a/MediaBrowser.Controller/Library/ResolverPriority.cs b/MediaBrowser.Controller/Library/ResolverPriority.cs deleted file mode 100644 index 1f266f371..000000000 --- a/MediaBrowser.Controller/Library/ResolverPriority.cs +++ /dev/null @@ -1,26 +0,0 @@ - -namespace MediaBrowser.Controller.Library -{ - /// - /// Enum ResolverPriority - /// - public enum ResolverPriority - { - /// - /// The first - /// - First = 1, - /// - /// The second - /// - Second = 2, - /// - /// The third - /// - Third = 3, - /// - /// The last - /// - Last = 4 - } -} diff --git a/MediaBrowser.Controller/Library/TVUtils.cs b/MediaBrowser.Controller/Library/TVUtils.cs index e0ef188b8..d6a922ff4 100644 --- a/MediaBrowser.Controller/Library/TVUtils.cs +++ b/MediaBrowser.Controller/Library/TVUtils.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; +using MediaBrowser.Controller.Resolvers; namespace MediaBrowser.Controller.Library { -- cgit v1.2.3