diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-12-01 21:24:14 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-12-01 21:24:14 -0500 |
| commit | ad52d8b5d96bea85c17f37da7ff3334164f8d4a4 (patch) | |
| tree | 1011a8fb901bfc8422f66f69fa6ee2effc6362fe /MediaBrowser.Controller | |
| parent | 42a2522637d1772381eecee0d32ed3ef60fa3c73 (diff) | |
fixes #640 - Add management filters
Diffstat (limited to 'MediaBrowser.Controller')
| -rw-r--r-- | MediaBrowser.Controller/Entities/BaseItem.cs | 1 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Video.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Controller/MediaBrowser.Controller.csproj | 1 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Providers/NameParser.cs | 39 |
4 files changed, 45 insertions, 1 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index d88282429..25da18fca 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -138,6 +138,7 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the type of the location. /// </summary> /// <value>The type of the location.</value> + [IgnoreDataMember] public virtual LocationType LocationType { get diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index ef768f628..9b02571b0 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -262,7 +262,10 @@ namespace MediaBrowser.Controller.Entities { if (!IsInMixedFolder) { - return new[] { System.IO.Path.GetDirectoryName(Path) }; + if (VideoType == VideoType.VideoFile || VideoType == VideoType.Iso) + { + return new[] { System.IO.Path.GetDirectoryName(Path) }; + } } return base.GetDeletePaths(); diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index a309d815c..9b89b12c5 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -117,6 +117,7 @@ <Compile Include="Notifications\NotificationUpdateEventArgs.cs" /> <Compile Include="Providers\IDynamicInfoProvider.cs" /> <Compile Include="Providers\IImageProvider.cs" /> + <Compile Include="Providers\NameParser.cs" /> <Compile Include="Session\ISessionManager.cs" /> <Compile Include="Drawing\ImageExtensions.cs" /> <Compile Include="Entities\AggregateFolder.cs" /> diff --git a/MediaBrowser.Controller/Providers/NameParser.cs b/MediaBrowser.Controller/Providers/NameParser.cs new file mode 100644 index 000000000..726f0e60e --- /dev/null +++ b/MediaBrowser.Controller/Providers/NameParser.cs @@ -0,0 +1,39 @@ +using System; +using System.Text.RegularExpressions; + +namespace MediaBrowser.Controller.Providers +{ + public static class NameParser + { + static readonly Regex[] NameMatches = new[] { + new Regex(@"(?<name>.*)\((?<year>\d{4})\)"), // matches "My Movie (2001)" and gives us the name and the year + new Regex(@"(?<name>.*)(\.(?<year>\d{4})(\.|$)).*$"), + new Regex(@"(?<name>.*)") // last resort matches the whole string as the name + }; + + + /// <summary> + /// Parses the name. + /// </summary> + /// <param name="name">The name.</param> + /// <param name="justName">Name of the just.</param> + /// <param name="year">The year.</param> + public static void ParseName(string name, out string justName, out int? year) + { + justName = null; + year = null; + foreach (var re in NameMatches) + { + Match m = re.Match(name); + if (m.Success) + { + justName = m.Groups["name"].Value.Trim(); + string y = m.Groups["year"] != null ? m.Groups["year"].Value : null; + int temp; + year = Int32.TryParse(y, out temp) ? temp : (int?)null; + break; + } + } + } + } +} |
