예제 #1
0
        private static void UpgradeFile(string message, FileInfo keepFile, MovieConfiguration movie, FileInfo removeFile)
        {
            LOGGER.Info($"{message} remove {removeFile.FullName} as it is not as good quality than {keepFile.FullName}");
            try
            {
                if (movie.ManualLocations.Contains(removeFile.DirectoryName))
                {
                    movie.ManualLocations.Remove(removeFile.DirectoryName);
                }

                removeFile.Delete();

                if (removeFile.Directory.GetDirectories().Length > 0)
                {
                    return;
                }

                if (removeFile.Directory.GetFiles().Any(f => f.IsMovieFile()))
                {
                    return;
                }

                FileHelper.DoTidyUp(removeFile.Directory, TVSettings.Instance.Tidyup);
            }
            catch (System.IO.FileNotFoundException)
            { //ignored}
            }
            catch (System.IO.DirectoryNotFoundException)
            { //ignored}
            }
            catch (System.IO.IOException)
            { //ignored}
            }
        }
예제 #2
0
        private void ProcessMovie(MovieConfiguration movie)
        {
            List <FileInfo> files = movie.Locations
                                    .Select(s => new DirectoryInfo(s))
                                    .Where(info => info.Exists)
                                    .SelectMany(d => d.GetFiles())
                                    .Where(f => f.IsMovieFile())
                                    .Distinct()
                                    .ToList();

            if (files.Count > 1)
            {
                DuplicateMovie duplicateMovie = new DuplicateMovie {
                    Movie = movie, Files = files
                };
                dupMovies.Add(duplicateMovie);

                duplicateMovie.IsSample  = files.Any(f => f.IsSampleFile());
                duplicateMovie.IsDeleted = files.Any(f => f.IsDeletedStubFile());

                if (files.Count == 2)
                {
                    duplicateMovie.IsDoublePart = FileHelper.IsDoublePartMovie(files[0], files[1]);
                }
            }
        }
예제 #3
0
        private void MergeConfigurationAndFiles(MovieConfiguration mlastSelectedMovie, FileInfo file1, FileInfo file2, UI ui)
        {
            FileHelper.VideoComparison result = FileHelper.BetterQualityFile(file1, file2);

            FileHelper.VideoComparison newResult = result;

            switch (newResult)
            {
            case FileHelper.VideoComparison.secondFileBetter:
                //remove first file and combine locations
                UpgradeFile("System had identified to", file2, mlastSelectedMovie, file1);
                break;

            case FileHelper.VideoComparison.cantTell:
            case FileHelper.VideoComparison.similar:
            {
                AskUserAboutFileReplacement(file1, file2, mlastSelectedMovie, ui);
                return;
            }

            //the other cases of the files being the same or the existing file being better are not enough to save the file
            case FileHelper.VideoComparison.firstFileBetter:
            case FileHelper.VideoComparison.same:
                //remove second file and combine locations
                UpgradeFile("System had identified to", file1, mlastSelectedMovie, file2);
                return;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #4
0
        private void AddToLibrary(CachedMovieInfo si)
        {
            // need to add a new showitem
            MovieConfiguration found = new MovieConfiguration(si.TmdbCode, TVDoc.ProviderType.TMDB);
            QuickLocateForm    f     = new QuickLocateForm(si.Name, MediaConfiguration.MediaType.movie);

            if (f.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            if (found.ConfigurationProvider == TVSettings.Instance.DefaultMovieProvider)
            {
                found.ConfigurationProvider = TVDoc.ProviderType.libraryDefault;
            }

            if (f.FolderNameChanged)
            {
                found.UseAutomaticFolders = false;
                found.UseManualLocations  = true;
                found.ManualLocations.Add(f.DirectoryFullPath);
            }
            else if (f.RootDirectory.HasValue())
            {
                found.AutomaticFolderRoot = f.RootDirectory !;
                found.UseAutomaticFolders = true;
            }

            mDoc.Add(found);
            mDoc.SetDirty();
            mDoc.ExportMovieInfo();
        }
예제 #5
0
        private void olvDuplicates_CellRightClick(object sender, CellRightClickEventArgs e)
        {
            if (e.Model is null)
            {
                return;
            }

            possibleMergedEpisodeRightClickMenu.Items.Clear();
            if (olvDuplicates.SelectedObjects.Count == 1)
            {
                SettingsCheck mlastSelected = (SettingsCheck)e.Model;

                if (mlastSelected is MovieCheck mcheck)
                {
                    MovieConfiguration si = mcheck.Movie;
                    AddRcMenuItem("Force Refresh",
                                  (o, args) => mainUi.ForceMovieRefresh(new List <MovieConfiguration> {
                        si
                    }, false));

                    AddRcMenuItem("Edit Movie", (o, args) => mainUi.EditMovie(si));

                    possibleMergedEpisodeRightClickMenu.Items.Add(new ToolStripSeparator());
                    foreach (string?f in si.Locations)
                    {
                        AddRcMenuItem("Visit " + f, (o, args) => Helpers.OpenFolder(f));
                    }
                }
                else if (mlastSelected is TvShowCheck tcheck)
                {
                    ShowConfiguration si = tcheck.Show;
                    AddRcMenuItem("Force Refresh",
                                  (o, args) => mainUi.ForceRefresh(new List <ShowConfiguration> {
                        si
                    }, false));

                    AddRcMenuItem("Edit TV Show", (o, args) => mainUi.EditShow(si));
                }

                possibleMergedEpisodeRightClickMenu.Items.Add(new ToolStripSeparator());
                AddRcMenuItem("Fix Issue", (o, args) => Remedy(mlastSelected));
            }
            else
            {
                AddRcMenuItem("Fix Issues", (o, args) =>
                {
                    foreach (SettingsCheck?selected in olvDuplicates.SelectedObjects.OfType <SettingsCheck>())
                    {
                        Remedy(selected);
                    }
                    mDoc.SetDirty();
                });
            }
        }
예제 #6
0
        private void AddToLibrary(int mlastSelectedKey, TVDoc tvDoc)
        {
            switch (media)
            {
            case MediaConfiguration.MediaType.tv:
                ShowConfiguration show = new ShowConfiguration(mlastSelectedKey, TVDoc.ProviderType.TMDB);
                tvDoc.Add(show);
                break;

            case MediaConfiguration.MediaType.movie:
                MovieConfiguration newMovie = new MovieConfiguration(mlastSelectedKey, TVDoc.ProviderType.TMDB);
                tvDoc.Add(newMovie);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #7
0
        private void AddToLibrary(CachedMovieInfo si)
        {
            // need to add a new showitem
            MovieConfiguration found = new MovieConfiguration(si.TmdbCode, TVDoc.ProviderType.TMDB);
            QuickLocateForm    f     = new QuickLocateForm(si.Name, MediaConfiguration.MediaType.movie);

            if (f.ShowDialog(this) == DialogResult.OK)
            {
                if (f.RootDirectory.HasValue())
                {
                    found.AutomaticFolderRoot = f.RootDirectory !;
                    found.UseAutomaticFolders = true;
                }

                ///TODO put UI to get folder - check they have not adjusted path - if so add as manual folders
                mDoc.Add(found);
                mDoc.SetDirty();
                mDoc.ExportMovieInfo();
            }
        }
예제 #8
0
        private void olvDuplicates_CellRightClick(object sender, BrightIdeasSoftware.CellRightClickEventArgs e)
        {
            if (e.Model is null)
            {
                return;
            }

            DuplicateMovie     mlastSelected = (DuplicateMovie)e.Model;
            MovieConfiguration si            = mlastSelected.Movie;

            possibleMergedEpisodeRightClickMenu.Items.Clear();

            AddRcMenuItem("Force Refresh", (o, args) =>
            {
                mainUi.ForceMovieRefresh(new List <MovieConfiguration> {
                    si
                }, false);
                Update(mlastSelected);
            });
            AddRcMenuItem("Update", (o, args) =>
            {
                Update(mlastSelected);
            });
            AddRcMenuItem("Edit Movie", (o, args) =>
            {
                mainUi.EditMovie(si);
                Update(mlastSelected);
            });
            AddRcMenuItem("Choose Best", (o, args) => MergeItems(mlastSelected, mainUi));

            possibleMergedEpisodeRightClickMenu.Items.Add(new ToolStripSeparator());

            foreach (FileInfo?f in mlastSelected.Files)
            {
                AddRcMenuItem("Visit " + f.FullName, (o, args) =>
                {
                    Helpers.OpenFolderSelectFile(f.FullName);
                    Update(mlastSelected);
                });
            }
        }
예제 #9
0
 protected MovieCheck(MovieConfiguration movie)
 {
     Movie = movie;
 }
예제 #10
0
        private static void AskUserAboutFileReplacement(FileInfo file1, FileInfo file2, [NotNull] MovieConfiguration pep, IDialogParent owner)
        {
            try
            {
                ChooseFile question = new ChooseFile(file1, file2);

                owner.ShowChildDialog(question);
                ChooseFile.ChooseFileDialogResult result = question.Answer;
                question.Dispose();

                switch (result)
                {
                case ChooseFile.ChooseFileDialogResult.ignore:
                    LOGGER.Info($" User has selected keeping {file1.FullName} and {file2.FullName} and they will not be merged");
                    return;

                case ChooseFile.ChooseFileDialogResult.left:
                    UpgradeFile("User selected to", file1, pep, file2);
                    return;

                case ChooseFile.ChooseFileDialogResult.right:
                    UpgradeFile("User selected to", file2, pep, file1);
                    return;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (System.IO.FileNotFoundException)
            {
                return;
            }
        }
예제 #11
0
 public MovieService(MovieConfiguration config)
 {
     _config = config;
 }
예제 #12
0
 protected MovieCheck(MovieConfiguration movie, TVDoc doc) : base(doc)
 {
     Movie = movie;
 }