/// <summary>
        /// Resolves the specified args.
        /// </summary>
        /// <param name="args">The args.</param>
        /// <returns>MusicAlbum.</returns>
        protected override MusicAlbum Resolve(ItemResolveArgs args)
        {
            if (!args.IsDirectory)
            {
                return(null);
            }

            //Avoid mis-identifying top folders
            if (args.Parent == null)
            {
                return(null);
            }
            if (args.Parent.IsRoot)
            {
                return(null);
            }
            if (args.Parent is MusicAlbum)
            {
                return(null);
            }

            var collectionType = args.Parent == null ? null : _libraryManager.FindCollectionType(args.Parent);

            // If there's a collection type and it's not music, it can't be a series
            if (!string.IsNullOrEmpty(collectionType) &&
                !string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase))
            {
                return(null);
            }

            return(IsMusicAlbum(args) ? new MusicAlbum
            {
                DisplayMediaType = "Album"
            } : null);
        }
示例#2
0
        /// <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);
        }
示例#3
0
        /// <summary>
        /// Resolves the specified args.
        /// </summary>
        /// <param name="args">The args.</param>
        /// <returns>MusicArtist.</returns>
        protected override MusicArtist Resolve(ItemResolveArgs args)
        {
            if (!args.IsDirectory)
            {
                return(null);
            }

            //Avoid mis-identifying top folders
            if (args.Parent == null)
            {
                return(null);
            }
            if (args.Parent.IsRoot)
            {
                return(null);
            }

            // Don't allow nested artists
            if (args.Parent is MusicArtist)
            {
                return(null);
            }

            var collectionType = args.Parent == null ? null : _libraryManager.FindCollectionType(args.Parent);

            // If there's a collection type and it's not music, it can't be a series
            if (!string.IsNullOrEmpty(collectionType) &&
                !string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase))
            {
                return(null);
            }

            // If we contain an album assume we are an artist folder
            return(args.FileSystemChildren.Where(i => (i.Attributes & FileAttributes.Directory) == FileAttributes.Directory).Any(i => MusicAlbumResolver.IsMusicAlbum(i.FullName)) ? new MusicArtist() : null);
        }
示例#4
0
        public string GetCollectionType()
        {
            if (!_collectionTypeDiscovered)
            {
                _collectionType           = Parent == null ? null : _libraryManager.FindCollectionType(Parent);
                _collectionTypeDiscovered = true;
            }

            return(_collectionType);
        }
示例#5
0
        /// <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);
                }

                var collectionType = args.Parent == null ? null : _libraryManager.FindCollectionType(args.Parent);

                // 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))
                {
                    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("[boxset]", StringComparison.OrdinalIgnoreCase) != -1 || 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))
                {
                    return(new Series());
                }
            }

            return(null);
        }
示例#6
0
        /// <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.Parent == null ? null : _libraryManager.FindCollectionType(args.Parent);

            // 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.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) &&
                    !string.Equals(collectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase))
                {
                    return(null);
                }

                return(FindMovie <Movie>(args.Path, args.FileSystemChildren));
            }

            // 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);
        }