示例#1
0
        private static Action SetupDirectoryRemoval([NotNull] DirectoryInfo di, [NotNull] IReadOnlyList <ShowItem> matchingShows)
        {
            ShowItem si = matchingShows[0]; //Choose the first series

            FinderHelper.FindSeasEp(di, out int seasF, out int epF, si, out TVSettings.FilenameProcessorRE _);
            SeriesInfo s = si.TheSeries();

            if (s is null)
            {
                throw new ArgumentNullException(nameof(s));
            }

            ProcessedEpisode pep = si.GetEpisode(seasF, epF);

            LOGGER.Info(
                $"Removing {di.FullName} as it matches {matchingShows[0].ShowName} and no episodes are needed");

            return(new ActionDeleteDirectory(di, pep, TVSettings.Instance.Tidyup));
        }
示例#2
0
        public static bool EpisodeNeeded([NotNull] ShowItem si, DirFilesCache dfc, int seasF, int epF,
                                         [NotNull] FileSystemInfo fi)
        {
            if (si is null)
            {
                throw new ArgumentNullException(nameof(si));
            }

            if (fi is null)
            {
                throw new ArgumentNullException(nameof(fi));
            }

            try
            {
                SeriesInfo s = si.TheSeries();
                if (s is null)
                {
                    //We have not downloaded the series, so have to assume that we need the episode/file
                    return(true);
                }

                ProcessedEpisode pep = si.GetEpisode(seasF, epF);

                foreach (FileInfo testFileInfo in FindEpOnDisk(dfc, si, pep))
                {
                    //We will check that the file that is found is not the one we are testing
                    if (fi.FullName == testFileInfo.FullName)
                    {
                        continue;
                    }

                    //We have found another file that matches
                    return(false);
                }
            }
            catch (ShowItem.EpisodeNotFoundException)
            {
                //Ignore exception, we may need the file
                return(true);
            }
            return(true);
        }