aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Library/Resolvers
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-12-02 22:13:03 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-12-02 22:13:03 -0500
commit56f6b0335ce40aeab275f1038b96a8ecc642f18f (patch)
tree92d8a4c47dec99f1be6e1aca0bb59bd64b48911b /MediaBrowser.Server.Implementations/Library/Resolvers
parentc48458f215bd5ea1da3ef3636f801a4652e77aa0 (diff)
updated nuget
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library/Resolvers')
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs160
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/LocalTrailerResolver.cs61
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs101
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs34
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/VideoResolver.cs6
5 files changed, 172 insertions, 190 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs
index 35519b932..f8cd209a1 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs
@@ -2,6 +2,7 @@
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Entities;
using MediaBrowser.Naming.Common;
+using MediaBrowser.Naming.Video;
using System;
using System.IO;
@@ -42,9 +43,75 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
where TVideoType : Video, new()
{
// If the path is a file check for a matching extensions
- if (!args.IsDirectory)
+ var parser = new Naming.Video.VideoResolver(new ExtendedNamingOptions(), new Naming.Logging.NullLogger());
+
+ if (args.IsDirectory)
+ {
+ TVideoType video = null;
+ VideoFileInfo videoInfo = null;
+
+ // Loop through each child file/folder and see if we find a video
+ foreach (var child in args.FileSystemChildren)
+ {
+ var filename = child.Name;
+
+ if ((child.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
+ {
+ if (IsDvdDirectory(filename))
+ {
+ videoInfo = parser.ResolveDirectory(args.Path);
+
+ if (videoInfo == null)
+ {
+ return null;
+ }
+
+ video = new TVideoType
+ {
+ Path = args.Path,
+ VideoType = VideoType.Dvd,
+ ProductionYear = videoInfo.Year
+ };
+ break;
+ }
+ if (IsBluRayDirectory(filename))
+ {
+ videoInfo = parser.ResolveDirectory(args.Path);
+
+ if (videoInfo == null)
+ {
+ return null;
+ }
+
+ video = new TVideoType
+ {
+ Path = args.Path,
+ VideoType = VideoType.BluRay,
+ ProductionYear = videoInfo.Year
+ };
+ break;
+ }
+ }
+ }
+
+ if (video != null)
+ {
+ if (parseName)
+ {
+ video.Name = videoInfo.Name;
+ }
+ else
+ {
+ video.Name = Path.GetFileName(args.Path);
+ }
+
+ Set3DFormat(video, videoInfo);
+ }
+
+ return video;
+ }
+ else
{
- var parser = new Naming.Video.VideoResolver(new ExtendedNamingOptions(), new Naming.Logging.NullLogger());
var videoInfo = parser.ResolveFile(args.Path);
if (videoInfo == null)
@@ -57,7 +124,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
if (LibraryManager.IsVideoFile(args.Path) || videoInfo.IsStub || isShortcut)
{
var type = string.Equals(videoInfo.Container, "iso", StringComparison.OrdinalIgnoreCase) || string.Equals(videoInfo.Container, "img", StringComparison.OrdinalIgnoreCase) ?
- VideoType.Iso :
+ VideoType.Iso :
VideoType.VideoFile;
var path = args.Path;
@@ -97,37 +164,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
}
}
- if (videoInfo.Is3D)
- {
- if (string.Equals(videoInfo.Format3D, "fsbs", StringComparison.OrdinalIgnoreCase))
- {
- video.Video3DFormat = Video3DFormat.FullSideBySide;
- }
- else if (string.Equals(videoInfo.Format3D, "ftab", StringComparison.OrdinalIgnoreCase))
- {
- video.Video3DFormat = Video3DFormat.FullTopAndBottom;
- }
- else if (string.Equals(videoInfo.Format3D, "hsbs", StringComparison.OrdinalIgnoreCase))
- {
- video.Video3DFormat = Video3DFormat.HalfSideBySide;
- }
- else if (string.Equals(videoInfo.Format3D, "htab", StringComparison.OrdinalIgnoreCase))
- {
- video.Video3DFormat = Video3DFormat.HalfTopAndBottom;
- }
- else if (string.Equals(videoInfo.Format3D, "sbs", StringComparison.OrdinalIgnoreCase))
- {
- video.Video3DFormat = Video3DFormat.HalfSideBySide;
- }
- else if (string.Equals(videoInfo.Format3D, "sbs3d", StringComparison.OrdinalIgnoreCase))
- {
- video.Video3DFormat = Video3DFormat.HalfSideBySide;
- }
- else if (string.Equals(videoInfo.Format3D, "tab", StringComparison.OrdinalIgnoreCase))
- {
- video.Video3DFormat = Video3DFormat.HalfTopAndBottom;
- }
- }
+ Set3DFormat(video, videoInfo);
return video;
}
@@ -135,5 +172,60 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
return null;
}
+
+ private void Set3DFormat(Video video, VideoFileInfo videoInfo)
+ {
+ if (videoInfo.Is3D)
+ {
+ if (string.Equals(videoInfo.Format3D, "fsbs", StringComparison.OrdinalIgnoreCase))
+ {
+ video.Video3DFormat = Video3DFormat.FullSideBySide;
+ }
+ else if (string.Equals(videoInfo.Format3D, "ftab", StringComparison.OrdinalIgnoreCase))
+ {
+ video.Video3DFormat = Video3DFormat.FullTopAndBottom;
+ }
+ else if (string.Equals(videoInfo.Format3D, "hsbs", StringComparison.OrdinalIgnoreCase))
+ {
+ video.Video3DFormat = Video3DFormat.HalfSideBySide;
+ }
+ else if (string.Equals(videoInfo.Format3D, "htab", StringComparison.OrdinalIgnoreCase))
+ {
+ video.Video3DFormat = Video3DFormat.HalfTopAndBottom;
+ }
+ else if (string.Equals(videoInfo.Format3D, "sbs", StringComparison.OrdinalIgnoreCase))
+ {
+ video.Video3DFormat = Video3DFormat.HalfSideBySide;
+ }
+ else if (string.Equals(videoInfo.Format3D, "sbs3d", StringComparison.OrdinalIgnoreCase))
+ {
+ video.Video3DFormat = Video3DFormat.HalfSideBySide;
+ }
+ else if (string.Equals(videoInfo.Format3D, "tab", StringComparison.OrdinalIgnoreCase))
+ {
+ video.Video3DFormat = Video3DFormat.HalfTopAndBottom;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Determines whether [is DVD directory] [the specified directory name].
+ /// </summary>
+ /// <param name="directoryName">Name of the directory.</param>
+ /// <returns><c>true</c> if [is DVD directory] [the specified directory name]; otherwise, <c>false</c>.</returns>
+ protected bool IsDvdDirectory(string directoryName)
+ {
+ return string.Equals(directoryName, "video_ts", StringComparison.OrdinalIgnoreCase);
+ }
+
+ /// <summary>
+ /// Determines whether [is blu ray directory] [the specified directory name].
+ /// </summary>
+ /// <param name="directoryName">Name of the directory.</param>
+ /// <returns><c>true</c> if [is blu ray directory] [the specified directory name]; otherwise, <c>false</c>.</returns>
+ protected bool IsBluRayDirectory(string directoryName)
+ {
+ return string.Equals(directoryName, "bdmv", StringComparison.OrdinalIgnoreCase);
+ }
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/LocalTrailerResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/LocalTrailerResolver.cs
deleted file mode 100644
index dfeefb74f..000000000
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/LocalTrailerResolver.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using MediaBrowser.Common.IO;
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.Resolvers;
-using MediaBrowser.Model.Entities;
-using System;
-using System.IO;
-using System.Linq;
-
-namespace MediaBrowser.Server.Implementations.Library.Resolvers
-{
- /// <summary>
- /// Class LocalTrailerResolver
- /// </summary>
- public class LocalTrailerResolver : BaseVideoResolver<Trailer>
- {
- private readonly IFileSystem _fileSystem;
-
- public LocalTrailerResolver(ILibraryManager libraryManager, IFileSystem fileSystem) : base(libraryManager)
- {
- _fileSystem = fileSystem;
- }
-
- /// <summary>
- /// Resolves the specified args.
- /// </summary>
- /// <param name="args">The args.</param>
- /// <returns>Trailer.</returns>
- protected override Trailer Resolve(ItemResolveArgs args)
- {
- // Trailers are not Children, therefore this can never happen
- if (args.Parent != null)
- {
- return null;
- }
-
- // If the file is within a trailers folder, see if the VideoResolver returns something
- if (!args.IsDirectory)
- {
- if (string.Equals(Path.GetFileName(Path.GetDirectoryName(args.Path)), BaseItem.TrailerFolderName, StringComparison.OrdinalIgnoreCase))
- {
- return base.Resolve(args);
- }
-
- // Support xbmc local trailer convention, but only when looking for local trailers (hence the parent == null check)
- if (args.Parent == null)
- {
- var nameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(args.Path);
- var suffix = BaseItem.ExtraSuffixes.First(i => i.Value == ExtraType.Trailer);
-
- if (nameWithoutExtension.EndsWith(suffix.Key, StringComparison.OrdinalIgnoreCase))
- {
- return base.Resolve(args);
- }
- }
- }
-
- return null;
- }
- }
-}
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
index c928c5e65..6d396ad9c 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
@@ -1,5 +1,4 @@
-using MediaBrowser.Common.Extensions;
-using MediaBrowser.Common.IO;
+using MediaBrowser.Common.IO;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
@@ -64,44 +63,44 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
}
}
- var isDirectory = args.IsDirectory;
-
- if (isDirectory)
- {
- // Since the looping is expensive, this is an optimization to help us avoid it
- if (args.ContainsMetaFileByName("series.xml"))
- {
- return null;
- }
- }
-
var collectionType = args.GetCollectionType();
// Find movies with their own folders
- if (isDirectory)
+ if (args.IsDirectory)
{
- if (string.Equals(collectionType, CollectionType.Trailers, StringComparison.OrdinalIgnoreCase))
- {
- return FindMovie<Trailer>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, false, false, collectionType);
- }
-
if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase))
{
- return FindMovie<MusicVideo>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, false, false, collectionType);
+ return FindMovie<MusicVideo>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, false, collectionType);
}
if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase))
{
- return FindMovie<Video>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, true, false, collectionType);
+ return FindMovie<Video>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, false, collectionType);
}
- if (string.IsNullOrEmpty(collectionType) ||
- string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase) ||
- string.Equals(collectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase))
+ if (string.IsNullOrEmpty(collectionType))
{
- return FindMovie<Movie>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, true, true, collectionType);
+ // Owned items should just use the plain video type
+ if (args.Parent == null)
+ {
+ return FindMovie<Video>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, false, collectionType);
+ }
+
+ // Since the looping is expensive, this is an optimization to help us avoid it
+ if (args.ContainsMetaFileByName("series.xml"))
+ {
+ return null;
+ }
+
+ return FindMovie<Movie>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, true, collectionType);
}
+ if (string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase) ||
+ string.Equals(collectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase))
+ {
+ return FindMovie<Movie>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, true, collectionType);
+ }
+
return null;
}
@@ -112,12 +111,6 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
return null;
}
- // Find movies that are mixed in the same folder
- if (string.Equals(collectionType, CollectionType.Trailers, StringComparison.OrdinalIgnoreCase))
- {
- return ResolveVideo<Trailer>(args, true);
- }
-
Video item = null;
if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase))
@@ -126,13 +119,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
}
// To find a movie file, the collection type must be movies or boxsets
- // Otherwise we'll consider it a plain video and let the video resolver handle it
- if (string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase) ||
+ else if (string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase) ||
string.Equals(collectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase))
{
item = ResolveVideo<Movie>(args, true);
}
-
+
if (item != null)
{
item.IsInMixedFolder = true;
@@ -178,11 +170,10 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
/// <param name="parent">The parent.</param>
/// <param name="fileSystemEntries">The file system entries.</param>
/// <param name="directoryService">The directory service.</param>
- /// <param name="supportMultiFileItems">if set to <c>true</c> [support multi file items].</param>
/// <param name="supportsMultipleSources">if set to <c>true</c> [supports multiple sources].</param>
/// <param name="collectionType">Type of the collection.</param>
/// <returns>Movie.</returns>
- private T FindMovie<T>(string path, Folder parent, IEnumerable<FileSystemInfo> fileSystemEntries, IDirectoryService directoryService, bool supportMultiFileItems, bool supportsMultipleSources, string collectionType)
+ private T FindMovie<T>(string path, Folder parent, IEnumerable<FileSystemInfo> fileSystemEntries, IDirectoryService directoryService, bool supportsMultipleSources, string collectionType)
where T : Video, new()
{
var movies = new List<T>();
@@ -243,15 +234,13 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
if (movies.Count > 1)
{
- if (supportMultiFileItems)
- {
- var result = GetMultiFileMovie(movies);
+ var multiFileResult = GetMultiFileMovie(movies);
- if (result != null)
- {
- return result;
- }
+ if (multiFileResult != null)
+ {
+ return multiFileResult;
}
+
if (supportsMultipleSources)
{
var result = GetMovieWithMultipleSources(movies);
@@ -334,7 +323,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
{
Path = folderPaths[0],
- IsMultiPart = true,
+ AdditionalParts = folderPaths.Skip(1).ToList(),
VideoType = videoTypes[0],
@@ -366,7 +355,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
return null;
}
- firstMovie.IsMultiPart = true;
+ firstMovie.AdditionalParts = result.Stacks[0].Files.Skip(1).ToList();
firstMovie.Name = result.Stacks[0].Name;
// They must all be part of the sequence if we're going to consider it a multi-part movie
@@ -392,7 +381,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
{
if (sortedMovies.All(i => _fileSystem.GetFileNameWithoutExtension(i.Path).StartsWith(filenamePrefix + " - ", StringComparison.OrdinalIgnoreCase)))
{
- firstMovie.HasLocalAlternateVersions = true;
+ firstMovie.LocalAlternateVersions = sortedMovies.Skip(1).Select(i => i.Path).ToList();
_logger.Debug("Multi-version video found: " + firstMovie.Path);
@@ -402,25 +391,5 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
return null;
}
-
- /// <summary>
- /// Determines whether [is DVD directory] [the specified directory name].
- /// </summary>
- /// <param name="directoryName">Name of the directory.</param>
- /// <returns><c>true</c> if [is DVD directory] [the specified directory name]; otherwise, <c>false</c>.</returns>
- private bool IsDvdDirectory(string directoryName)
- {
- return string.Equals(directoryName, "video_ts", StringComparison.OrdinalIgnoreCase);
- }
-
- /// <summary>
- /// Determines whether [is blu ray directory] [the specified directory name].
- /// </summary>
- /// <param name="directoryName">Name of the directory.</param>
- /// <returns><c>true</c> if [is blu ray directory] [the specified directory name]; otherwise, <c>false</c>.</returns>
- private bool IsBluRayDirectory(string directoryName)
- {
- return string.Equals(directoryName, "bdmv", StringComparison.OrdinalIgnoreCase);
- }
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs
index 839b14a9e..112490ccd 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Controller.Entities.TV;
+using System;
+using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Model.Entities;
@@ -41,39 +42,14 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
// If the parent is a Season or Series, then this is an Episode if the VideoResolver returns something
if (season != null || parent is Series || parent.Parents.OfType<Series>().Any())
{
- Episode episode = null;
-
- if (args.IsDirectory)
+ if (args.IsDirectory && args.Path.IndexOf("dead like me", StringComparison.OrdinalIgnoreCase) != -1)
{
- if (args.ContainsFileSystemEntryByName("video_ts"))
- {
- episode = new Episode
- {
- Path = args.Path,
- VideoType = VideoType.Dvd
- };
- }
- if (args.ContainsFileSystemEntryByName("bdmv"))
- {
- episode = new Episode
- {
- Path = args.Path,
- VideoType = VideoType.BluRay
- };
- }
- }
-
- if (episode == null)
- {
- episode = base.Resolve(args);
+ var b = true;
}
+ var episode = ResolveVideo<Episode>(args, false);
if (episode != null)
{
- // The base video resolver is going to fill these in, so null them out
- episode.ProductionYear = null;
- episode.Name = null;
-
if (season != null)
{
episode.ParentIndexNumber = season.IndexNumber;
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/VideoResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/VideoResolver.cs
index cde75aea2..cecf2d699 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/VideoResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/VideoResolver.cs
@@ -21,6 +21,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
{
if (args.Parent != null)
{
+ // The movie resolver will handle this
+ if (args.IsDirectory)
+ {
+ return null;
+ }
+
var collectionType = args.GetCollectionType() ?? string.Empty;
var accepted = new[]
{