Beispiel #1
0
        protected override void DoCheck(SetProgressDelegate prog, ICollection <ShowItem> showList, TVDoc.ScanSettings settings)
        {
            // have a look around for any missing episodes
            List <Finder> appropriateFinders      = finders.Where(f => f.DisplayType() == CurrentType() && f.Active()).ToList();
            int           currentMatchingFinderId = 0;
            int           totalMatchingFinders    = appropriateFinders.Count;

            foreach (Finder f in appropriateFinders)
            {
                if (settings.Token.IsCancellationRequested)
                {
                    return;
                }

                if (!MDoc.TheActionList.MissingItems().Any())
                {
                    continue;
                }

                f.ActionList = MDoc.TheActionList;

                currentMatchingFinderId++;
                int startPos = 100 * (currentMatchingFinderId - 1) / totalMatchingFinders;
                int endPos   = 100 * currentMatchingFinderId / totalMatchingFinders;
                f.Check(prog, startPos, endPos, showList, settings);

                MDoc.RemoveIgnored();
            }
        }
        protected override void DoCheck([NotNull] SetProgressDelegate prog, ICollection <ShowItem> showList, TVDoc.ScanSettings settings)
        {
            BulkAddManager bam = new BulkAddManager(MDoc);

            bam.CheckFolders(settings.Token, prog, false, !settings.Unattended);
            AskUserAboutShows(settings, bam);

            if (!bam.AddItems.Any(s => s.CodeKnown))
            {
                return;
            }

            List <int> idsToAdd = bam.AddItems.Where(s => s.CodeKnown).Select(folder => folder.TVDBCode).ToList();

            bam.AddAllToMyShows();

            MDoc.SetDirty();
            MDoc.DoDownloadsFG(settings.Unattended, settings.Hidden);

            List <ShowItem> addedShows = idsToAdd.Select(s => MDoc.Library.ShowItem(s)).ToList();

            //add each new show into the shows being scanned
            foreach (ShowItem si in addedShows)
            {
                showList.Add(si);
            }
            LOGGER.Info("Added new shows called: {0}", addedShows.Select(si => si?.ShowName).ToCsv());

            MDoc.DoWhenToWatch(true, settings.Unattended, settings.Hidden);

            MDoc.WriteUpcoming();
            MDoc.WriteRecent();
        }
        protected override void DoCheck(SetProgressDelegate prog, TVDoc.ScanSettings settings)
        {
            BulkAddSeriesManager bam = new BulkAddSeriesManager(MDoc);

            bam.CheckFolders(settings.Token, prog, false, !settings.Unattended);
            AskUserAboutShows(settings, bam);

            if (!bam.AddItems.Any(s => s.CodeKnown))
            {
                return;
            }

            var idsToAdd = bam.AddItems.Where(s => s.CodeKnown).Select(folder => new { Code = folder.ProviderCode, folder.Provider }).ToList();

            bam.AddAllToMyShows();
            List <ShowConfiguration> addedShows = idsToAdd.Select(s => MDoc.TvLibrary.GetShowItem(s.Code, s.Provider)).ToList();

            //add each new show into the shows being scanned
            foreach (ShowConfiguration si in addedShows)
            {
                settings.Shows.Add(si);
            }
            LOGGER.Info("Added new shows called: {0}", addedShows.Select(si => si.ShowName).ToCsv());

            MDoc.TvAddedOrEdited(true, settings.Unattended, settings.Hidden, settings.Owner, addedShows);
        }
        protected override void DoCheck(SetProgressDelegate prog,
                                        TVDoc.ScanSettings settings)
        {
            //for each directory in settings directory
            //for each file in directory
            //for each saved show (order by recent)
            //does show match selected file?
            //if so add cachedSeries to list of cachedSeries scanned
            if (!Active())
            {
                LOGGER.Info("Not looking for new media as 'Auto-Add' is turned off");
                return;
            }

            //Don't support unattended mode
            if (settings.Unattended || settings.Hidden)
            {
                LOGGER.Info("Not looking for new media as app is unattended");
                return;
            }

            IEnumerable <FileInfo>    possibleShowNames = GetPossibleShowNameStrings();
            List <MediaConfiguration> addedShows        = FinderHelper.FindMedia(possibleShowNames, MDoc, settings.Owner);

            IEnumerable <ShowConfiguration> addedTVShows = addedShows.OfType <ShowConfiguration>();

            if (addedTVShows.Any())
            {
                MDoc.TvLibrary.AddRange(addedTVShows);
                MDoc.ShowAddedOrEdited(false, false, false, settings.Owner);
                MDoc.ShowAddedOrEdited(true, false, false, settings.Owner);
                //add each new show into the shows being scanned
                foreach (ShowConfiguration si in addedTVShows)
                {
                    settings.Shows.Add(si);
                }
                LOGGER.Info("Added new shows called: {0}", addedTVShows.Select(s => s.ShowName).ToCsv());
            }


            IEnumerable <MovieConfiguration> addedMovies = addedShows.OfType <MovieConfiguration>();

            if (addedMovies.Any())
            {
                MDoc.FilmLibrary.AddRange(addedMovies);
                MDoc.MovieAddedOrEdited(false, false, false, settings.Owner);
                MDoc.MovieAddedOrEdited(true, false, false, settings.Owner);

                foreach (MovieConfiguration si in addedMovies)
                {
                    settings.Movies.Add(si);
                }
                LOGGER.Info("Added new movies called: {0}", addedMovies.Select(s => s.ShowName).ToCsv());
            }
        }
Beispiel #5
0
        protected override void DoCheck(SetProgressDelegate prog, ICollection <ShowItem> showList, TVDoc.ScanSettings settings)
        {
            MDoc.TheActionList = new ItemList();

            if (TVSettings.Instance.RenameCheck)
            {
                MDoc.Stats().RenameChecksDone++;
            }

            if (TVSettings.Instance.MissingCheck)
            {
                MDoc.Stats().MissingChecksDone++;
            }

            if (settings.Type == TVSettings.ScanType.Full)
            {
                // only do episode count if we're doing all shows and seasons
                MDoc.CurrentStats.NsNumberOfEpisodes = 0;
                showList = MDoc.Library.Values;
            }

            DirFilesCache dfc = new DirFilesCache();

            int c = 0;

            UpdateStatus(c, showList.Count, "Checking shows");
            foreach (ShowItem si in showList.OrderBy(item => item.ShowName))
            {
                UpdateStatus(c++, showList.Count, si.ShowName);
                if (settings.Token.IsCancellationRequested)
                {
                    return;
                }

                LOGGER.Info("Rename and missing check: " + si.ShowName);
                try
                {
                    new CheckAllFoldersExist(MDoc).CheckIfActive(si, dfc, settings);
                    new MergeLibraryEpisodes(MDoc).CheckIfActive(si, dfc, settings);
                    new RenameAndMissingCheck(MDoc).CheckIfActive(si, dfc, settings);
                }
                catch (TVRenameOperationInterruptedException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    LOGGER.Error(e, $"Failed to scan {si.ShowName}. Please double check settings for this show: {si.TvdbCode}: {si.AutoAddFolderBase}");
                }
            } // for each show

            MDoc.RemoveIgnored();
        }
        protected override void DoCheck(SetProgressDelegate prog, ICollection <ShowItem> showList, TVDoc.ScanSettings settings)
        {
            //for each directory in settings directory
            //for each file in directory
            //for each saved show (order by recent)
            //does show match selected file?
            //if so add series to list of series scanned
            if (!Active())
            {
                LOGGER.Info("Not looking for new shows as 'Auto-Add' is turned off");
                return;
            }

            //Don't support unattended mode
            if (settings.Unattended || settings.Hidden)
            {
                LOGGER.Info("Not looking for new shows as app is unattended");
                return;
            }

            List <string>   possibleShowNames = GetPossibleShowNameStrings();
            List <ShowItem> addedShows        = FinderHelper.FindShows(possibleShowNames, MDoc);

            if (addedShows.Count <= 0)
            {
                return;
            }

            lock (TheTVDB.SERIES_LOCK)
            {
                MDoc.Library.AddRange(addedShows);
                MDoc.ShowAddedOrEdited(false, false, false);
            }
            MDoc.ShowAddedOrEdited(true, false, false);

            LOGGER.Info("Added new shows called: {0}", string.Join(",", addedShows.Select(s => s.ShowName)));

            //add each new show into the shows being scanned
            foreach (ShowItem si in addedShows)
            {
                showList.Add(si);
            }
        }