/// <summary> /// Resolves the specified args. /// </summary> /// <param name="args">The args.</param> /// <returns>BoxSet.</returns> protected override BoxSet Resolve(ItemResolveArgs args) { // It's a boxset if all of the following conditions are met: // Is a Directory // Contains [boxset] in the path if (args.IsDirectory) { var filename = Path.GetFileName(args.Path); if (string.IsNullOrEmpty(filename)) { return(null); } // This is a bit of a one-off but it's here to combat MCM's over-aggressive placement of collection.xml files where they don't belong, including in series folders. if (args.ContainsMetaFileByName("series.xml")) { return(null); } if (filename.IndexOf("[boxset]", StringComparison.OrdinalIgnoreCase) != -1 || args.ContainsFileSystemEntryByName("collection.xml")) { return(new BoxSet { Path = args.Path }); } } return(null); }
/// <summary> /// Resolves the specified args. /// </summary> /// <param name="args">The args.</param> /// <returns>Video.</returns> protected override Video Resolve(ItemResolveArgs args) { // Must be a directory if (args.IsDirectory) { // Avoid expensive tests against VF's and all their children by not allowing this if (args.Parent != null) { if (args.Parent.IsRoot) { return(null); } // If the parent is not a boxset, the only other allowed parent type is Folder if (!(args.Parent is BoxSet)) { if (args.Parent.GetType() != typeof(Folder)) { return(null); } } } // Since the looping is expensive, this is an optimization to help us avoid it if (args.ContainsMetaFileByName("series.xml") || args.Path.IndexOf("[tvdbid", StringComparison.OrdinalIgnoreCase) != -1) { return(null); } var collectionType = args.Parent == null ? null : _libraryManager.FindCollectionType(args.Parent); if (args.Path.IndexOf("[trailers]", StringComparison.OrdinalIgnoreCase) != -1 || string.Equals(collectionType, CollectionType.Trailers, StringComparison.OrdinalIgnoreCase)) { return(FindMovie <Trailer>(args.Path, args.FileSystemChildren)); } if (args.Path.IndexOf("[musicvideos]", StringComparison.OrdinalIgnoreCase) != -1 || string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase)) { return(FindMovie <MusicVideo>(args.Path, args.FileSystemChildren)); } if (args.Path.IndexOf("[adultvideos]", StringComparison.OrdinalIgnoreCase) != -1 || string.Equals(collectionType, CollectionType.AdultVideos, StringComparison.OrdinalIgnoreCase)) { return(FindMovie <AdultVideo>(args.Path, args.FileSystemChildren)); } if (!string.IsNullOrEmpty(collectionType) && !string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase)) { return(null); } return(FindMovie <Movie>(args.Path, args.FileSystemChildren)); } return(null); }
/// <summary> /// Resolves the specified args. /// </summary> /// <param name="args">The args.</param> /// <returns>Series.</returns> protected override Series Resolve(ItemResolveArgs args) { if (args.IsDirectory) { // Avoid expensive tests against VF's and all their children by not allowing this if (args.Parent == null || args.Parent.IsRoot) { return(null); } // Optimization to avoid running these tests against Seasons if (args.Parent is Series) { return(null); } // It's a Series if any of the following conditions are met: // series.xml exists // [tvdbid= is present in the path // TVUtils.IsSeriesFolder returns true var filename = Path.GetFileName(args.Path); if (string.IsNullOrEmpty(filename)) { return(null); } if (args.ContainsMetaFileByName("series.xml") || filename.IndexOf("[tvdbid=", StringComparison.OrdinalIgnoreCase) != -1 || TVUtils.IsSeriesFolder(args.Path, args.FileSystemChildren)) { return(new Series()); } } return(null); }
/// <summary> /// Resolves the specified args. /// </summary> /// <param name="args">The args.</param> /// <returns>Video.</returns> protected override Video Resolve(ItemResolveArgs args) { // Must be a directory if (args.IsDirectory) { // Avoid expensive tests against VF's and all their children by not allowing this if (args.Parent != null) { if (args.Parent.IsRoot) { return(null); } // If the parent is not a boxset, the only other allowed parent type is Folder if (!(args.Parent is BoxSet)) { if (args.Parent.GetType() != typeof(Folder)) { return(null); } } } // Since the looping is expensive, this is an optimization to help us avoid it if (args.ContainsMetaFileByName("series.xml") || args.Path.IndexOf("[tvdbid", StringComparison.OrdinalIgnoreCase) != -1) { return(null); } // A shortcut to help us resolve faster in some cases var isKnownMovie = args.ContainsMetaFileByName("movie.xml"); if (args.Path.IndexOf("[trailers]", StringComparison.OrdinalIgnoreCase) != -1) { return(FindMovie <Trailer>(args.Path, args.FileSystemChildren, isKnownMovie)); } if (args.Path.IndexOf("[musicvideos]", StringComparison.OrdinalIgnoreCase) != -1) { return(FindMovie <MusicVideo>(args.Path, args.FileSystemChildren, isKnownMovie)); } return(FindMovie <Movie>(args.Path, args.FileSystemChildren, isKnownMovie)); } return(null); }
/// <summary> /// Resolves the specified args. /// </summary> /// <param name="args">The args.</param> /// <returns>Series.</returns> protected override Series Resolve(ItemResolveArgs args) { if (args.IsDirectory) { // Avoid expensive tests against VF's and all their children by not allowing this if (args.Parent == null || args.Parent.IsRoot) { return(null); } // Optimization to avoid running these tests against Seasons if (args.Parent is Series || args.Parent is Season || args.Parent is MusicArtist || args.Parent is MusicAlbum) { return(null); } var collectionType = args.GetCollectionType(); // If there's a collection type and it's not tv, it can't be a series if (!string.IsNullOrEmpty(collectionType) && !string.Equals(collectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) && !string.Equals(collectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase)) { return(null); } // It's a Series if any of the following conditions are met: // series.xml exists // [tvdbid= is present in the path // TVUtils.IsSeriesFolder returns true var filename = Path.GetFileName(args.Path); if (string.IsNullOrEmpty(filename)) { return(null); } // Without these movies that have the name season in them could cause the parent folder to be resolved as a series if (filename.IndexOf("[tmdbid=", StringComparison.OrdinalIgnoreCase) != -1) { return(null); } if (args.ContainsMetaFileByName("series.xml") || filename.IndexOf("[tvdbid=", StringComparison.OrdinalIgnoreCase) != -1 || TVUtils.IsSeriesFolder(args.Path, args.FileSystemChildren, args.DirectoryService)) { return(new Series()); } } return(null); }
/// <summary> /// Resolves the specified args. /// </summary> /// <param name="args">The args.</param> /// <returns>Video.</returns> protected override Video Resolve(ItemResolveArgs args) { // Avoid expensive tests against VF's and all their children by not allowing this if (args.Parent != null) { if (args.Parent.IsRoot) { return(null); } // If the parent is not a boxset, the only other allowed parent type is Folder if (!(args.Parent is BoxSet)) { if (args.Parent.GetType() != typeof(Folder)) { return(null); } } } // Since the looping is expensive, this is an optimization to help us avoid it if (args.Path.IndexOf("[tvdbid", StringComparison.OrdinalIgnoreCase) != -1) { return(null); } 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.Path.IndexOf("[trailers]", StringComparison.OrdinalIgnoreCase) != -1 || string.Equals(collectionType, CollectionType.Trailers, StringComparison.OrdinalIgnoreCase)) { return(FindMovie <Trailer>(args.Path, args.Parent, args.FileSystemChildren, args.DirectoryService)); } if (args.Path.IndexOf("[musicvideos]", StringComparison.OrdinalIgnoreCase) != -1 || string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase)) { return(FindMovie <MusicVideo>(args.Path, args.Parent, args.FileSystemChildren, args.DirectoryService)); } if (args.Path.IndexOf("[adultvideos]", StringComparison.OrdinalIgnoreCase) != -1 || string.Equals(collectionType, CollectionType.AdultVideos, StringComparison.OrdinalIgnoreCase)) { return(FindMovie <AdultVideo>(args.Path, args.Parent, args.FileSystemChildren, args.DirectoryService)); } if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase)) { return(FindMovie <Video>(args.Path, args.Parent, args.FileSystemChildren, args.DirectoryService)); } if (string.IsNullOrEmpty(collectionType) || string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase) || string.Equals(collectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase)) { return(FindMovie <Movie>(args.Path, args.Parent, args.FileSystemChildren, args.DirectoryService)); } return(null); } var filename = Path.GetFileName(args.Path); // Don't misidentify xbmc trailers as a movie if (filename.IndexOf(BaseItem.XbmcTrailerFileSuffix, StringComparison.OrdinalIgnoreCase) != -1) { return(null); } // Find movies that are mixed in the same folder if (args.Path.IndexOf("[trailers]", StringComparison.OrdinalIgnoreCase) != -1 || string.Equals(collectionType, CollectionType.Trailers, StringComparison.OrdinalIgnoreCase)) { return(ResolveVideo <Trailer>(args)); } Video item = null; if (args.Path.IndexOf("[musicvideos]", StringComparison.OrdinalIgnoreCase) != -1 || string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase)) { item = ResolveVideo <MusicVideo>(args); } if (args.Path.IndexOf("[adultvideos]", StringComparison.OrdinalIgnoreCase) != -1 || string.Equals(collectionType, CollectionType.AdultVideos, StringComparison.OrdinalIgnoreCase)) { item = ResolveVideo <AdultVideo>(args); } // 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) || string.Equals(collectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase)) { item = ResolveVideo <Movie>(args); } if (item != null) { item.IsInMixedFolder = true; } return(item); }
/// <summary> /// Finds a movie based on a child file system entries /// </summary> /// <param name="args">The args.</param> /// <returns>Movie.</returns> private Movie FindMovie(ItemResolveArgs args) { // Since the looping is expensive, this is an optimization to help us avoid it if (args.ContainsMetaFileByName("series.xml") || args.Path.IndexOf("[tvdbid", StringComparison.OrdinalIgnoreCase) != -1) { return(null); } // Optimization to avoid having to resolve every file bool?isKnownMovie = null; var movies = new List <Movie>(); // Loop through each child file/folder and see if we find a video foreach (var child in args.FileSystemChildren) { if (child.IsDirectory) { if (IsDvdDirectory(child.cFileName)) { return(new Movie { Path = args.Path, VideoType = VideoType.Dvd }); } if (IsBluRayDirectory(child.cFileName)) { return(new Movie { Path = args.Path, VideoType = VideoType.BluRay }); } if (IsHdDvdDirectory(child.cFileName)) { return(new Movie { Path = args.Path, VideoType = VideoType.HdDvd }); } continue; } var childArgs = new ItemResolveArgs(ApplicationPaths) { FileInfo = child, Path = child.Path }; var item = base.Resolve(childArgs); if (item != null) { // If we already know it's a movie, we can stop looping if (!isKnownMovie.HasValue) { isKnownMovie = args.ContainsMetaFileByName("movie.xml") || args.ContainsMetaFileByName(MovieDbProvider.LOCAL_META_FILE_NAME) || args.Path.IndexOf("[tmdbid", StringComparison.OrdinalIgnoreCase) != -1; } if (isKnownMovie.Value) { return(item); } movies.Add(item); } } // If there are multiple video files, return null, and let the VideoResolver catch them later as plain videos return(movies.Count == 1 ? movies[0] : null); }
/// <summary> /// Resolves the specified args. /// </summary> /// <param name="args">The args.</param> /// <returns>Video.</returns> protected override Video Resolve(ItemResolveArgs args) { // Avoid expensive tests against VF's and all their children by not allowing this if (args.Parent != null) { if (args.Parent.IsRoot) { return(null); } } 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 (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)); } if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase)) { return(FindMovie <Video>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, true, false, collectionType)); } if (string.IsNullOrEmpty(collectionType) || 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, true, collectionType)); } return(null); } var filename = Path.GetFileName(args.Path); // Don't misidentify extras or trailers if (BaseItem.ExtraSuffixes.Any(i => filename.IndexOf(i.Key, StringComparison.OrdinalIgnoreCase) != -1)) { return(null); } // Find movies that are mixed in the same folder if (string.Equals(collectionType, CollectionType.Trailers, StringComparison.OrdinalIgnoreCase)) { return(ResolveVideo <Trailer>(args)); } Video item = null; if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase)) { item = ResolveVideo <MusicVideo>(args); } // 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) || string.Equals(collectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase)) { item = ResolveVideo <Movie>(args); } if (item != null) { item.IsInMixedFolder = true; } return(item); }