aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-06-16 15:02:57 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-06-16 15:02:57 -0400
commitc5b00dec8ec326bbb17cf122263b78851ce398dd (patch)
tree1a82f76db1064a71d7bfa13d3882405427456673 /MediaBrowser.Controller
parente231bd4d32ce69a459f6c2ae1a995c14c2edb356 (diff)
Added multi-disc movie support
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Entities/Movies/Movie.cs8
-rw-r--r--MediaBrowser.Controller/Entities/MusicVideo.cs4
-rw-r--r--MediaBrowser.Controller/Entities/Video.cs44
-rw-r--r--MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs8
4 files changed, 37 insertions, 27 deletions
diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs
index 2e9cc3bea3..307fe19544 100644
--- a/MediaBrowser.Controller/Entities/Movies/Movie.cs
+++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs
@@ -20,7 +20,7 @@ namespace MediaBrowser.Controller.Entities.Movies
{
SpecialFeatureIds = new List<Guid>();
}
-
+
/// <summary>
/// Should be overridden to return the proper folder where metadata lives
/// </summary>
@@ -30,7 +30,7 @@ namespace MediaBrowser.Controller.Entities.Movies
{
get
{
- return VideoType == VideoType.VideoFile || VideoType == VideoType.Iso ? System.IO.Path.GetDirectoryName(Path) : Path;
+ return VideoType == VideoType.VideoFile || VideoType == VideoType.Iso || IsMultiPart ? System.IO.Path.GetDirectoryName(Path) : Path;
}
}
@@ -51,7 +51,7 @@ namespace MediaBrowser.Controller.Entities.Movies
{
get
{
- return VideoType == VideoType.VideoFile || VideoType == VideoType.Iso;
+ return VideoType == VideoType.VideoFile || VideoType == VideoType.Iso || IsMultiPart;
}
}
@@ -88,7 +88,7 @@ namespace MediaBrowser.Controller.Entities.Movies
return itemsChanged || results.Contains(true);
}
-
+
/// <summary>
/// Loads the special features.
/// </summary>
diff --git a/MediaBrowser.Controller/Entities/MusicVideo.cs b/MediaBrowser.Controller/Entities/MusicVideo.cs
index 983ce1567c..035709bb42 100644
--- a/MediaBrowser.Controller/Entities/MusicVideo.cs
+++ b/MediaBrowser.Controller/Entities/MusicVideo.cs
@@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Entities
{
get
{
- return VideoType == VideoType.VideoFile || VideoType == VideoType.Iso ? System.IO.Path.GetDirectoryName(Path) : Path;
+ return VideoType == VideoType.VideoFile || VideoType == VideoType.Iso || IsMultiPart ? System.IO.Path.GetDirectoryName(Path) : Path;
}
}
@@ -35,7 +35,7 @@ namespace MediaBrowser.Controller.Entities
{
get
{
- return VideoType == VideoType.VideoFile || VideoType == VideoType.Iso;
+ return VideoType == VideoType.VideoFile || VideoType == VideoType.Iso || IsMultiPart;
}
}
}
diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs
index a15362037c..d8d700d644 100644
--- a/MediaBrowser.Controller/Entities/Video.cs
+++ b/MediaBrowser.Controller/Entities/Video.cs
@@ -86,7 +86,7 @@ namespace MediaBrowser.Controller.Entities
var allFiles = Directory.EnumerateFiles(rootPath, "*", SearchOption.AllDirectories).ToList();
- return PlayableStreamFileNames.Select(name => allFiles.FirstOrDefault(f => string.Equals(System.IO.Path.GetFileName(f), name, System.StringComparison.OrdinalIgnoreCase)))
+ return PlayableStreamFileNames.Select(name => allFiles.FirstOrDefault(f => string.Equals(System.IO.Path.GetFileName(f), name, StringComparison.OrdinalIgnoreCase)))
.Where(f => !string.IsNullOrEmpty(f))
.ToList();
}
@@ -176,32 +176,38 @@ namespace MediaBrowser.Controller.Entities
return new List<Video>();
}
- ItemResolveArgs resolveArgs;
+ IEnumerable<FileSystemInfo> files;
- try
+ if (VideoType == VideoType.BluRay || VideoType == VideoType.Dvd)
{
- resolveArgs = ResolveArgs;
+ files = new DirectoryInfo(System.IO.Path.GetDirectoryName(Path))
+ .EnumerateDirectories()
+ .Where(i => !string.Equals(i.FullName, Path, StringComparison.OrdinalIgnoreCase) && EntityResolutionHelper.IsMultiPartFile(i.Name));
}
- catch (IOException ex)
+ else
{
- Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path);
- return new List<Video>();
- }
-
- if (!resolveArgs.IsDirectory)
- {
- return new List<Video>();
- }
+ ItemResolveArgs resolveArgs;
- var files = resolveArgs.FileSystemChildren.Where(i =>
- {
- if ((i.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
+ try
+ {
+ resolveArgs = ResolveArgs;
+ }
+ catch (IOException ex)
{
- return false;
+ Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path);
+ return new List<Video>();
}
- return !string.Equals(i.FullName, Path, StringComparison.OrdinalIgnoreCase) && EntityResolutionHelper.IsVideoFile(i.FullName) && EntityResolutionHelper.IsMultiPartFile(i.FullName);
- });
+ files = resolveArgs.FileSystemChildren.Where(i =>
+ {
+ if ((i.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
+ {
+ return false;
+ }
+
+ return !string.Equals(i.FullName, Path, StringComparison.OrdinalIgnoreCase) && EntityResolutionHelper.IsVideoFile(i.FullName) && EntityResolutionHelper.IsMultiPartFile(i.Name);
+ });
+ }
return LibraryManager.ResolvePaths<Video>(files, null).Select(video =>
{
diff --git a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs
index a1b7be906f..78c9b133be 100644
--- a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs
+++ b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs
@@ -48,7 +48,11 @@ namespace MediaBrowser.Controller.Resolvers
private static readonly Regex MultiFileRegex = new Regex(
@"(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck]|d)[ _.-]*[0-9]+)(.*?)(\.[^.]+)$",
- RegexOptions.Compiled);
+ RegexOptions.Compiled | RegexOptions.IgnoreCase);
+
+ private static readonly Regex MultiFolderRegex = new Regex(
+ @"(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck]|d)[ _.-]*[0-9]+)$",
+ RegexOptions.Compiled | RegexOptions.IgnoreCase);
/// <summary>
/// Determines whether [is multi part file] [the specified path].
@@ -57,7 +61,7 @@ namespace MediaBrowser.Controller.Resolvers
/// <returns><c>true</c> if [is multi part file] [the specified path]; otherwise, <c>false</c>.</returns>
public static bool IsMultiPartFile(string path)
{
- return MultiFileRegex.Match(path).Success;
+ return MultiFileRegex.Match(path).Success || MultiFolderRegex.Match(path).Success;
}
/// <summary>