示例#1
0
        private AudioBook FindAudioBook(ItemResolveArgs args, bool parseName)
        {
            // TODO: Allow GetMultiDiscMovie in here
            var result = ResolveMultipleAudio(args.Parent, args.GetActualFileSystemChildren(), parseName);

            if (result == null || result.Items.Count != 1 || result.Items[0] is not AudioBook item)
            {
                return(null);
            }

            // If we were supporting this we'd be checking filesFromOtherItems
            item.IsInMixedFolder = false;
            item.Name            = Path.GetFileName(item.ContainingFolderPath);
            return(item);
        }
示例#2
0
        public override Video Resolve(ItemResolveArgs args)
        {
            var collectionType = args.GetCollectionType();

            // Find movies with their own folders
            if (args.IsDirectory)
            {
                if (IsInvalid(args.Parent, collectionType))
                {
                    return(null);
                }

                Video movie = null;
                var   files = args.GetActualFileSystemChildren().ToList();

                if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase))
                {
                    movie = FindMovie <MusicVideo>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, false);
                }

                if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase))
                {
                    movie = FindMovie <Video>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, false);
                }

                if (string.IsNullOrEmpty(collectionType))
                {
                    // Owned items will be caught by the plain video resolver
                    if (args.Parent == null)
                    {
                        // return FindMovie<Video>(args.Path, args.Parent, files, args.DirectoryService, collectionType);
                        return(null);
                    }

                    if (args.HasParent <Series>())
                    {
                        return(null);
                    }

                    movie = FindMovie <Movie>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, true);
                }

                if (string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase))
                {
                    movie = FindMovie <Movie>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, true);
                }

                // ignore extras
                return(movie?.ExtraType == null ? movie : null);
            }

            // Handle owned items
            if (args.Parent == null)
            {
                return(base.Resolve(args));
            }

            if (IsInvalid(args.Parent, collectionType))
            {
                return(null);
            }

            Video item = null;

            if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase))
            {
                item = ResolveVideo <MusicVideo>(args, false);
            }

            // To find a movie file, the collection type must be movies or boxsets
            else if (string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase))
            {
                item = ResolveVideo <Movie>(args, true);
            }
            else if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase) ||
                     string.Equals(collectionType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase))
            {
                item = ResolveVideo <Video>(args, false);
            }
            else if (string.IsNullOrEmpty(collectionType))
            {
                if (args.HasParent <Series>())
                {
                    return(null);
                }

                item = ResolveVideo <Video>(args, false);
            }

            // Ignore extras
            if (item?.ExtraType != null)
            {
                return(null);
            }

            if (item != null)
            {
                item.IsInMixedFolder = true;
            }

            return(item);
        }