Added multi-disc movie support

This commit is contained in:
Luke Pulverenti
2013-06-16 15:02:57 -04:00
parent e231bd4d32
commit c5b00dec8e
6 changed files with 152 additions and 66 deletions

View File

@@ -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>

View File

@@ -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;
}
}
}

View File

@@ -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>();
}
ItemResolveArgs resolveArgs;
if (!resolveArgs.IsDirectory)
{
return new List<Video>();
}
var files = resolveArgs.FileSystemChildren.Where(i =>
{
if ((i.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
try
{
return false;
resolveArgs = ResolveArgs;
}
catch (IOException ex)
{
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 =>
{

View File

@@ -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>