Ejemplo n.º 1
0
        protected virtual TVideoType ResolveVideo <TVideoType>(ItemResolveArgs args, bool parseName)
            where TVideoType : Video, new()
        {
            VideoFileInfo videoInfo = null;
            VideoType?    videoType = null;

            // If the path is a file check for a matching extensions
            if (args.IsDirectory)
            {
                // 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.IsDirectory)
                    {
                        if (IsDvdDirectory(child.FullName, filename, args.DirectoryService))
                        {
                            videoType = VideoType.Dvd;
                        }
                        else if (IsBluRayDirectory(filename))
                        {
                            videoType = VideoType.BluRay;
                        }
                    }
                    else if (IsDvdFile(filename))
                    {
                        videoType = VideoType.Dvd;
                    }

                    if (videoType == null)
                    {
                        continue;
                    }

                    videoInfo = VideoResolver.ResolveDirectory(args.Path, NamingOptions, parseName);
                    break;
                }
            }
            else
            {
                videoInfo = VideoResolver.Resolve(args.Path, false, NamingOptions, parseName);
            }

            if (videoInfo == null || (!videoInfo.IsStub && !VideoResolver.IsVideoFile(args.Path, NamingOptions)))
            {
                return(null);
            }

            var video = new TVideoType
            {
                Name           = videoInfo.Name,
                Path           = args.Path,
                ProductionYear = videoInfo.Year,
                ExtraType      = videoInfo.ExtraType
            };

            if (videoType.HasValue)
            {
                video.VideoType = videoType.Value;
            }
            else
            {
                SetVideoType(video, videoInfo);
            }

            Set3DFormat(video, videoInfo);

            return(video);
        }
Ejemplo n.º 2
0
 internal static bool IsOwnedByMedia(NamingOptions namingOptions, string file, string imageFilename)
 {
     return(VideoResolver.IsVideoFile(file, namingOptions) && IsOwnedByResolvedMedia(file, imageFilename));
 }
Ejemplo n.º 3
0
        protected virtual TVideoType ResolveVideo <TVideoType>(ItemResolveArgs args, bool parseName)
            where TVideoType : Video, new()
        {
            var namingOptions = NamingOptions;

            // If the path is a file check for a matching extensions
            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.IsDirectory)
                    {
                        if (IsDvdDirectory(child.FullName, filename, args.DirectoryService))
                        {
                            videoInfo = VideoResolver.ResolveDirectory(args.Path, namingOptions);

                            if (videoInfo == null)
                            {
                                return(null);
                            }

                            video = new TVideoType
                            {
                                Path           = args.Path,
                                VideoType      = VideoType.Dvd,
                                ProductionYear = videoInfo.Year
                            };
                            break;
                        }

                        if (IsBluRayDirectory(filename))
                        {
                            videoInfo = VideoResolver.ResolveDirectory(args.Path, namingOptions);

                            if (videoInfo == null)
                            {
                                return(null);
                            }

                            video = new TVideoType
                            {
                                Path           = args.Path,
                                VideoType      = VideoType.BluRay,
                                ProductionYear = videoInfo.Year
                            };
                            break;
                        }
                    }
                    else if (IsDvdFile(filename))
                    {
                        videoInfo = VideoResolver.ResolveDirectory(args.Path, namingOptions);

                        if (videoInfo == null)
                        {
                            return(null);
                        }

                        video = new TVideoType
                        {
                            Path           = args.Path,
                            VideoType      = VideoType.Dvd,
                            ProductionYear = videoInfo.Year
                        };
                        break;
                    }
                }

                if (video != null)
                {
                    video.Name = parseName ?
                                 videoInfo.Name :
                                 Path.GetFileName(args.Path);

                    Set3DFormat(video, videoInfo);
                }

                return(video);
            }
            else
            {
                var videoInfo = VideoResolver.Resolve(args.Path, false, namingOptions, false);

                if (videoInfo == null)
                {
                    return(null);
                }

                if (VideoResolver.IsVideoFile(args.Path, NamingOptions) || videoInfo.IsStub)
                {
                    var path = args.Path;

                    var video = new TVideoType
                    {
                        Path            = path,
                        IsInMixedFolder = true,
                        ProductionYear  = videoInfo.Year
                    };

                    SetVideoType(video, videoInfo);

                    video.Name = parseName ?
                                 videoInfo.Name :
                                 Path.GetFileNameWithoutExtension(args.Path);

                    Set3DFormat(video, videoInfo);

                    return(video);
                }
            }

            return(null);
        }