/// <summary>
        /// Converts the media path import database into a MovieModel DB.
        /// </summary>
        public static void ConvertMediaPathImportToDB()
        {
            cancelImport = false;

            var db = MediaPathDBFactory.GetMediaPathMoviesUnsorted();

            var count = 0;

            MovieDBFactory.ImportProgressMaximum = db.Count;

            ImportDatabase.Clear();
            ImportDuplicatesDatabase.Clear();

            var getFiles = new string[1];
            var currentGetPathFiles = string.Empty;

            UI.Windows7UIFactory.StartProgressState(db.Count);
            
            foreach (var file in db)
            {
                if (cancelImport)
                {
                    break;
                }

                MovieDBFactory.ImportProgressCurrent = count;

                MovieDBFactory.ImportProgressStatus = string.Format("Processing: " + file.PathAndFileName.Replace("{", "{{").Replace("}", "}}"));

                if (file.Path != currentGetPathFiles)
                {
                    getFiles = FileHelper.GetFilesRecursive(file.Path, "*.*").ToArray();
                    currentGetPathFiles = file.Path;
                }

                var videoSource = file.DefaultVideoSource;

                if (MovieNaming.IsBluRay(file.PathAndFileName))
                {
                    videoSource = "Bluray";
                }
                else if (MovieNaming.IsDVD(file.PathAndFileName))
                {
                    videoSource = "DVD";
                }
                else
                {
                    var detect = Tools.IO.DetectType.FindVideoSource(file.PathAndFileName);

                    if (!string.IsNullOrEmpty(detect))
                    {
                        videoSource = detect;
                    }
                }

                string title = MovieNaming.GetMovieName(file.PathAndFileName, file.MediaPathType);
                var movieModel = new MovieModel
                    {
                        Title = title,
                        Year = MovieNaming.GetMovieYear(file.PathAndFileName),
                        ScraperGroup = file.ScraperGroup,
                        VideoSource = videoSource,
                        NfoPathOnDisk = FindNFO(file.FilenameWithOutExt, FindFilePath(title, file), getFiles),
                        PosterPathOnDisk = FindPoster(file.FilenameWithOutExt, FindFilePath(title, file), getFiles),
                        FanartPathOnDisk = FindFanart(file.FilenameWithOutExt, FindFilePath(title, file), getFiles)
                    };

                if (!string.IsNullOrEmpty(movieModel.NfoPathOnDisk))
                {
                    InOut.OutFactory.LoadMovie(movieModel);
                    movieModel.ChangedText = false;
                }

                var result = (from m in ImportDatabase where (m.Title.ToLower().Trim() == movieModel.Title.ToLower().Trim()) select m).ToList();

                if (result.Count == 0)
                {
                    if (!string.IsNullOrEmpty(movieModel.PosterPathOnDisk))
                    {
                        movieModel.GenerateSmallPoster(movieModel.PosterPathOnDisk);
                        movieModel.ChangedPoster = false;
                    }

                    if (!string.IsNullOrEmpty(movieModel.FanartPathOnDisk))
                    {
                        movieModel.GenerateSmallFanart(movieModel.FanartPathOnDisk);
                        movieModel.ChangedFanart = false;
                    }

                    movieModel.AssociatedFiles.AddToMediaCollection(file);

                    // Does the movie exist in our current DB?
                    var result2 = (from m in MovieDBFactory.MovieDatabase where (m.Title.ToLower().Trim() == movieModel.Title.ToLower().Trim()) select m).ToList();
                    if (result2.Count > 0)
                    {
                        if (movieModel.Year != null)
                        {
                            var r = (from m in result2 where m.Year == movieModel.Year select m).ToList();
                            if (r.Count > 0)
                            {
                                // We already have a movie with that name and year, mark as dupe
                                ImportDuplicatesDatabase.Add(movieModel);
                            }
                        }
                        else
                        {
                            // No year, so we can't ensure it's a dupe
                            ImportDuplicatesDatabase.Add(movieModel);
                        }
                    }
                    
                    // Add it to the list anyway, since there's no implementation of any action on duplicates.
                    ImportDatabase.Add(movieModel);
                }
                else
                {
                    var r = (from m in result where m.Year == movieModel.Year select m).ToList();
                    if (Regex.IsMatch(file.PathAndFileName.ToLower(), @"(disc|disk|part|cd|vob|ifo|bup)", RegexOptions.IgnoreCase))
                    {
                        // Only associate with an existing movie if its not a dupe
                        result[0].AssociatedFiles.AddToMediaCollection(file);
                    }
                    else if (r.Count == 0)
                    {
                        // Same title, different year
                        ImportDatabase.Add(movieModel);
                    }
                    else
                    {
                        // Dont count a disc or part as a dupe or movies with different years
                        ImportDuplicatesDatabase.Add(movieModel);
                        // Add it to the list anyway, since there's no implementation of any action on duplicates.
                        ImportDatabase.Add(movieModel);
                    }
                }

                count++;
                UI.Windows7UIFactory.SetProgressValue(count);
            }

            UI.Windows7UIFactory.StopProgressState();
        }
        /// <summary>
        /// Converts the media path import database into a MovieModel DB.
        /// </summary>
        public static void ConvertMediaPathImportToDB()
        {
            var db = MediaPathDBFactory.GetMediaPathMoviesUnsorted();

            var count = 0;

            MovieDBFactory.ImportProgressMaximum = db.Count;

            ImportDatabase.Clear();

            var getFiles = new string[1];
            var currentGetPathFiles = string.Empty;

            foreach (var file in db)
            {
                MovieDBFactory.ImportProgressCurrent = count;

                MovieDBFactory.ImportProgressStatus = string.Format("Processing: " + file.PathAndFileName);

                if (file.Path != currentGetPathFiles)
                {
                    var files = FastDirectoryEnumerator.EnumerateFiles(file.Path, "*.*", SearchOption.TopDirectoryOnly);
                    getFiles = (from f in files select f.Path).ToArray();

                    currentGetPathFiles = file.Path;
                }

                var movieModel = new MovieModel
                    {
                        Title = Tools.Importing.MovieNaming.GetMovieName(file.PathAndFileName, file.MediaPathType),
                        Year = Tools.Importing.MovieNaming.GetMovieYear(file.PathAndFileName),
                        ScraperGroup = file.ScraperGroup,
                        VideoSource = file.DefaultVideoSource,
                        NfoPathOnDisk = FindNFO(file.FilenameWithOutExt, file.Path, getFiles),
                        PosterPathOnDisk = FindPoster(file.FilenameWithOutExt, file.Path, getFiles),
                        FanartPathOnDisk = FindFanart(file.FilenameWithOutExt, file.Path, getFiles)
                    };

                var result = (from m in ImportDatabase where m.Title == movieModel.Title select m).ToList();

                if (result.Count == 0)
                {
                    if (!string.IsNullOrEmpty(movieModel.NfoPathOnDisk))
                    {
                        InOut.OutFactory.LoadMovie(movieModel);
                        movieModel.ChangedText = false;
                    }

                    if (!string.IsNullOrEmpty(movieModel.PosterPathOnDisk))
                    {
                        movieModel.GenerateSmallPoster(movieModel.PosterPathOnDisk);
                        movieModel.ChangedPoster = false;
                    }

                    if (!string.IsNullOrEmpty(movieModel.FanartPathOnDisk))
                    {
                        movieModel.GenerateSmallFanart(movieModel.FanartPathOnDisk);
                        movieModel.ChangedFanart = false;
                    }

                    movieModel.AssociatedFiles.AddToMediaCollection(file);
                    ImportDatabase.Add(movieModel);
                }
                else
                {
                    // result[0].AssociatedFiles.GetMediaCollection().Clear();
                    result[0].AssociatedFiles.AddToMediaCollection(file);
                }

                count++;
            }
        }