Ejemplo n.º 1
0
        public BulkAddEditMovie([NotNull] PossibleNewMovie hint)
        {
            InitializeComponent();

            codeFinderControl = new CombinedCodeFinder("", MediaConfiguration.MediaType.movie, TVSettings.Instance.DefaultMovieProvider)
            {
                Dock = DockStyle.Fill
            };
            codeFinderControl.SelectionChanged      += CodeChanged;
            codeFinderControl.lvMatches.DoubleClick += MatchDoubleClick;

            label1.Text = $"Search for {TVSettings.Instance.DefaultMovieProvider} entry, by partial name or ID:";

            pnlCF.SuspendLayout();
            pnlCF.Controls.Add(codeFinderControl);
            pnlCF.ResumeLayout();

            if (hint.CodeKnown)
            {
                codeFinderControl.SetHint(hint.ProviderCode.ToString(), hint.Provider);
            }
            else
            {
                codeFinderControl.SetHint(string.IsNullOrWhiteSpace(hint.RefinedHint)
                    ? hint.Directory.Name
                    : hint.RefinedHint, TVSettings.Instance.DefaultMovieProvider);
            }
            Code     = -1;
            Provider = TVDoc.ProviderType.libraryDefault;
        }
Ejemplo n.º 2
0
        public BulkAddEditMovie([NotNull] PossibleNewMovie hint)
        {
            InitializeComponent();

            codeFinderControl = new TmdbCodeFinder("")
            {
                Dock = DockStyle.Fill
            };
            codeFinderControl.SelectionChanged      += CodeChanged;
            codeFinderControl.lvMatches.DoubleClick += MatchDoubleClick;

            pnlCF.SuspendLayout();
            pnlCF.Controls.Add(codeFinderControl);
            pnlCF.ResumeLayout();

            if (hint.CodeKnown)
            {
                codeFinderControl.SetHint(hint.TMDBCode.ToString()); //todo make generic
            }
            else
            {
                codeFinderControl.SetHint(string.IsNullOrWhiteSpace(hint.RefinedHint)
                    ? hint.Directory.Name
                    : hint.RefinedHint);
            }
            Code = -1;
        }
Ejemplo n.º 3
0
        private void AddNewMovieToLibrary(PossibleNewMovie ai, bool isInLibraryFolderFileFinder, string?matchingRoot)
        {
            // need to add a new showitem
            MovieConfiguration found = new MovieConfiguration(ai);

            mDoc.FilmLibrary.Add(found);

            mDoc.Stats().AutoAddedMovies++;

            bool inDefaultPath = ai.Directory.Name.Equals(
                CustomMovieName.NameFor(found, TVSettings.Instance.MovieFolderFormat),
                StringComparison.CurrentCultureIgnoreCase);

            if (inDefaultPath && isInLibraryFolderFileFinder)
            {
                found.UseAutomaticFolders       = true;
                found.UseCustomFolderNameFormat = false;
                found.AutomaticFolderRoot       = matchingRoot !;
                found.UseManualLocations        = false;
                return;
            }

            if (isInLibraryFolderFileFinder)
            {
                found.AutomaticFolderRoot = matchingRoot !;
            }

            found.UseAutomaticFolders       = false;
            found.UseCustomFolderNameFormat = false;
            found.UseManualLocations        = true;
            found.ManualLocations.Add(ai.Directory.FullName);
        }
Ejemplo n.º 4
0
        private void EditEntry([NotNull] PossibleNewMovie fme)
        {
            BulkAddEditMovie ed = new BulkAddEditMovie(fme);

            if (ed.ShowDialog(this) != DialogResult.OK || ed.Code == -1)
            {
                return;
            }

            fme.SetId(ed.Code, ed.Provider);
        }
Ejemplo n.º 5
0
        private void UpdateListItem(PossibleNewMovie ai, bool makevis)
        {
            foreach (ListViewItem lvi in lvFMNewShows.Items.Cast <ListViewItem>().Where(lvi => lvi.Tag == ai))
            {
                UpdateResultEntry(ai, lvi);

                if (makevis)
                {
                    lvi.EnsureVisible();
                }
            }
        }
Ejemplo n.º 6
0
        private void AddToLibrary([NotNull] PossibleNewMovie ai)
        {
            if (ai.CodeUnknown)
            {
                return;
            }

            string?matchingRoot = TVSettings.Instance.MovieLibraryFolders.FirstOrDefault(s => ai.Directory.FullName.IsSubfolderOf(s));
            bool   isInLibraryFolderFileFinder = matchingRoot.HasValue();

            // see if there is a matching show item
            MovieConfiguration found = mDoc.FilmLibrary.GetMovie(ai);

            if (found is null)
            {
                AddNewMovieToLibrary(ai, isInLibraryFolderFileFinder, matchingRoot);
                return;
            }

            //We are updating an existing record

            string targetDirectoryName = CustomMovieName.NameFor(found, TVSettings.Instance.MovieFolderFormat);
            bool   inDefaultPath       = ai.Directory.Name.Equals(
                targetDirectoryName,
                StringComparison.CurrentCultureIgnoreCase);

            bool existingLocationIsDefaultToo = found.UseAutomaticFolders && found.AutomaticFolderRoot.In(TVSettings.Instance.MovieLibraryFolders.ToArray());

            if (inDefaultPath && isInLibraryFolderFileFinder && !existingLocationIsDefaultToo)
            {
                found.UseAutomaticFolders       = true;
                found.UseCustomFolderNameFormat = false;
                found.AutomaticFolderRoot       = matchingRoot !;
                //leave found.UseManualLocations alone to retain any existing manual locations
                return;
            }

            //we have an existing record that we need to add manual folders to

            if (isInLibraryFolderFileFinder && !found.AutomaticFolderRoot.HasValue())
            {
                //Probably in the library
                found.AutomaticFolderRoot = matchingRoot !;
            }

            found.UseManualLocations = true;
            if (!found.ManualLocations.Contains(ai.Directory.FullName))
            {
                found.ManualLocations.Add(ai.Directory.FullName);
            }
        }
Ejemplo n.º 7
0
        private void AutoMatchMovie(CancellationTokenSource cts, PossibleNewMovie ai, BackgroundWorker bw, int total)
        {
            if (cts.IsCancellationRequested)
            {
                return;
            }

            if (ai.CodeKnown)
            {
                return;
            }

            ai.GuessMovie(true);
            Interlocked.Increment(ref VolatileCounter);
            bw.ReportProgress((int)100.0 * VolatileCounter / total, ai);
        }
Ejemplo n.º 8
0
        public MovieConfiguration(PossibleNewMovie movie) : this()
        {
            TmdbCode = movie.TMDBCode ?? -1;
            TvdbCode = movie.TvdbCode ?? -1;

            if (!movie.TmdbCodeUnknown)
            {
                ConfigurationProvider = TVSettings.Instance.DefaultMovieProvider == TVDoc.ProviderType.TMDB
                    ? TVDoc.ProviderType.libraryDefault
                    : TVDoc.ProviderType.TMDB;
            }
            else if (!movie.TvdbCodeUnknown)
            {
                ConfigurationProvider = TVSettings.Instance.DefaultMovieProvider == TVDoc.ProviderType.TheTVDB
                    ? TVDoc.ProviderType.libraryDefault
                    : TVDoc.ProviderType.TheTVDB;
            }
        }
Ejemplo n.º 9
0
 private static void UpdateResultEntry([NotNull] PossibleNewMovie ai, [NotNull] ListViewItem lvi)
 {
     lvi.SubItems.Clear();
     lvi.Text = ai.Directory.FullName;
     if (ai.CodeKnown)
     {
         CachedMovieInfo?x = ai.CachedMovie;
         lvi.SubItems.Add(x?.Name);
         string val = x?.FirstAired?.Year.ToString();
         lvi.SubItems.Add(val ?? string.Empty);
         lvi.SubItems.Add(ai.CodeString);
     }
     else
     {
         lvi.SubItems.Add(ai.RefinedHint);
         lvi.SubItems.Add(ai.PossibleYear.ToString());
         lvi.SubItems.Add(string.Empty);
     }
     lvi.Tag        = ai;
     lvi.ImageIndex = ai.CodeKnown && !string.IsNullOrWhiteSpace(ai.MovieStub)?1:0;
 }
Ejemplo n.º 10
0
        public MovieConfiguration(PossibleNewMovie movie) : this()
        {
            if (movie.CodeUnknown)
            {
                return;
            }
            switch (movie.Provider)
            {
            case TVDoc.ProviderType.TheTVDB:
                TvdbCode = movie.ProviderCode;
                break;

            case TVDoc.ProviderType.TMDB:
                TmdbCode = movie.ProviderCode;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            ConfigurationProvider = TVSettings.Instance.DefaultMovieProvider == movie.Provider
                ? TVDoc.ProviderType.libraryDefault
                : movie.Provider;
        }
Ejemplo n.º 11
0
        public (bool finished, DirectoryInfo[]? subDirs) CheckFolderForMovies([NotNull] DirectoryInfo di2, bool andGuess, bool fullLogging, bool showErrorMsgBox)
        {
            CurrentPhaseDirectory++;
            try
            {
                // ..and not already a folder for one of our shows
                string theFolder = di2.FullName.ToLower();
                foreach (MovieConfiguration?si in mDoc.FilmLibrary.Movies)
                {
                    if (RejectFolderIfIncludedInShow(fullLogging, si, theFolder))
                    {
                        return(true, null);
                    }
                } // for each showitem

                //We don't have it already
                DirectoryInfo[] subDirectories = GetValidDirectories(di2);

                //This is an indication that something is wrong
                if (subDirectories is null)
                {
                    return(false, null);
                }

                /*
                 * bool hasSubFolders = subDirectories.Length > 0;
                 * if (hasSubFolders)
                 * {
                 *  return (false, subDirectories);
                 * }*/

                if (TVSettings.Instance.BulkAddIgnoreRecycleBin && IsRecycleBin(di2))
                {
                    return(false, subDirectories);
                }

                List <FileInfo> films = FilmFiles(di2);
                if (TVSettings.Instance.BulkAddCompareNoVideoFolders && !films.Any())
                {
                    return(false, subDirectories);
                }
                if (!films.Any())
                {
                    Logger.Warn($"Checked {di2.FullName} and it had no movie files.");
                    if (!di2.GetFiles().Any() && !di2.GetDirectories().Any())
                    {
                        di2.Delete(false);
                    }
                }

                foreach (FileInfo newFilm in films)
                {
                    // ....its good!
                    Logger.Info("Adding {0} as a new Movie", newFilm.FullName);
                    PossibleNewMovie ai = new PossibleNewMovie(newFilm, andGuess, showErrorMsgBox);
                    AddItems.AddIfNew(ai);
                }

                return(false, subDirectories);
            }
            catch (UnauthorizedAccessException)
            {
                Logger.Info("Can't access {0}, so ignoring it", di2.FullName);
                return(true, null);
            }
        }
Ejemplo n.º 12
0
 public MovieConfiguration?GetMovie(PossibleNewMovie ai)
 {
     return(GetMovie(ai.TMDBCode ?? 0)); //todo revisit this when we can have a genuine multisource library
 }
Ejemplo n.º 13
0
 public MovieConfiguration?GetMovie(PossibleNewMovie ai)
 {
     return(GetMovie(ai.ProviderCode, ai.Provider));
 }