Esempio n. 1
0
            private void GenerateOpenMenu([NotNull] Season seas, ICollection <string> added)
            {
                Dictionary <int, List <string> > afl = show.AllExistngFolderLocations();

                if (!afl.ContainsKey(seas.SeasonNumber))
                {
                    return;
                }

                int  n     = gridSummary.mFoldersToOpen.Count;
                bool first = true;

                foreach (string folder in afl[seas.SeasonNumber])
                {
                    if (!string.IsNullOrEmpty(folder) && Directory.Exists(folder) && !added.Contains(folder))
                    {
                        added.Add(folder); // don't show the same folder more than once
                        if (first)
                        {
                            GenerateSeparator(gridSummary.showRightClickMenu);
                            first = false;
                        }

                        GenerateMenu(gridSummary.showRightClickMenu, "Open: " + folder,
                                     (int)RightClickCommands.kOpenFolderBase + n);

                        gridSummary.mFoldersToOpen.Add(folder);
                        n++;
                    }
                }
            }
Esempio n. 2
0
        private static string GetBestFolderLocationToOpen([NotNull] this ShowItem si, [NotNull] Season s)
        {
            Dictionary <int, List <string> > afl = si.AllExistngFolderLocations();

            int[] keys = new int[afl.Count];
            afl.Keys.CopyTo(keys, 0);

            if (afl.ContainsKey(s.SeasonNumber))
            {
                foreach (string folder in afl[s.SeasonNumber])
                {
                    if (Directory.Exists(folder))
                    {
                        return(folder);
                    }
                }
            }

            if (!string.IsNullOrEmpty(si.AutoAddFolderBase) && Directory.Exists(si.AutoAddFolderBase))
            {
                return(si.AutoAddFolderBase);
            }

            return(string.Empty);
        }
Esempio n. 3
0
        protected override void Check([NotNull] ShowItem si, [NotNull] DirFilesCache dfc, TVDoc.ScanSettings settings)
        {
            Dictionary <int, List <string> > allFolders = si.AllExistngFolderLocations();

            if (allFolders.Count == 0) // no folders defined for this show
            {
                return;                // so, nothing to do.
            }

            //This is the code that will iterate over the DownloadIdentifiers and ask each to ensure that
            //it has all the required files for that show
            if (!string.IsNullOrEmpty(si.AutoAddFolderBase) && (allFolders.Any()))
            {
                Doc.TheActionList.Add(downloadIdentifiers.ProcessShow(si));
            }

            //MS_TODO Put the banner refresh period into the settings file, we'll default to 3 months
            DateTime cutOff              = DateTime.Now.AddMonths(-3);
            DateTime lastUpdate          = si.BannersLastUpdatedOnDisk ?? DateTime.Now.AddMonths(-4);
            bool     timeForBannerUpdate = (cutOff.CompareTo(lastUpdate) == 1);

            if (TVSettings.Instance.NeedToDownloadBannerFile() && timeForBannerUpdate)
            {
                Doc.TheActionList.Add(
                    downloadIdentifiers.ForceUpdateShow(DownloadIdentifier.DownloadType.downloadImage, si));

                si.BannersLastUpdatedOnDisk = DateTime.Now;
                Doc.SetDirty();
            }

            // process each folder for each season...

            foreach (int snum in si.SeasonEpisodes.Keys.ToList())
            {
                if (settings.Token.IsCancellationRequested)
                {
                    return;
                }

                if (si.IgnoreSeasons.Contains(snum) || !allFolders.ContainsKey(snum))
                {
                    continue;
                }

                if ((snum == 0) && (si.CountSpecials))
                {
                    continue;
                }

                if ((snum == 0) && TVSettings.Instance.IgnoreAllSpecials)
                {
                    continue;
                }

                // all the folders for this particular season
                List <string> folders = allFolders[snum];

                CheckSeason(si, dfc, settings, snum, folders, timeForBannerUpdate);
            } // for each season of this show
        }
Esempio n. 4
0
        public void ForceUpdateImages([NotNull] ShowItem si)
        {
            TheActionList = new ItemList();

            Logger.Info("*******************************");
            Logger.Info("Force Update Images: " + si.ShowName);

            Dictionary <int, List <string> > allFolders = si.AllExistngFolderLocations();

            if (!string.IsNullOrEmpty(si.AutoAddFolderBase) && (allFolders.Any()))
            {
                TheActionList.Add(
                    downloadIdentifiers.ForceUpdateShow(DownloadIdentifier.DownloadType.downloadImage, si));

                si.BannersLastUpdatedOnDisk = DateTime.Now;
                SetDirty();
            }

            // process each folder for each season...
            int[] numbers = new int[si.SeasonEpisodes.Keys.Count];
            si.SeasonEpisodes.Keys.CopyTo(numbers, 0);

            foreach (int snum in numbers)
            {
                if ((si.IgnoreSeasons.Contains(snum)) || (!allFolders.ContainsKey(snum)))
                {
                    continue; // ignore/skip this season
                }

                if ((snum == 0) && (si.CountSpecials))
                {
                    continue; // don't process the specials season, as they're merged into the seasons themselves
                }

                if ((snum == 0) && TVSettings.Instance.IgnoreAllSpecials)
                {
                    continue;
                }

                // all the folders for this particular season
                List <string> folders = allFolders[snum];

                foreach (string folder in folders)
                {
                    //Image series checks here
                    TheActionList.Add(
                        downloadIdentifiers.ForceUpdateSeason(DownloadIdentifier.DownloadType.downloadImage, si, folder,
                                                              snum));
                }
            } // for each season of this show

            RemoveIgnored();
        }
Esempio n. 5
0
        private static string GetBestFolderLocationToOpen([NotNull] this ShowItem si)
        {
            if (!string.IsNullOrEmpty(si.AutoAddFolderBase) && Directory.Exists(si.AutoAddFolderBase))
            {
                return(si.AutoAddFolderBase);
            }

            Dictionary <int, List <string> > afl = si.AllExistngFolderLocations();

            foreach (KeyValuePair <int, List <string> > season in afl)
            {
                foreach (string folder in season.Value)
                {
                    if (!string.IsNullOrWhiteSpace(folder) && Directory.Exists(folder))
                    {
                        return(folder);
                    }
                }
            }
            return(string.Empty);
        }
Esempio n. 6
0
        private static bool RejectFolderIfIncludedInShow(bool fullLogging, [NotNull] ShowItem si, string theFolder)
        {
            if (si.AutoAddNewSeasons() && !string.IsNullOrEmpty(si.AutoAddFolderBase) &&
                theFolder.IsSubfolderOf(si.AutoAddFolderBase))
            {
                // we're looking at a folder that is a subfolder of an existing show
                if (fullLogging)
                {
                    Logger.Info("Rejecting {0} as it's already part of {1}.", theFolder, si.ShowName);
                }

                return(true);
            }

            if (si.UsesManualFolders())
            {
                Dictionary <int, List <string> > afl = si.AllExistngFolderLocations();
                foreach (KeyValuePair <int, List <string> > kvp in afl)
                {
                    foreach (string folder in kvp.Value)
                    {
                        if (!string.Equals(theFolder, folder, StringComparison.CurrentCultureIgnoreCase))
                        {
                            continue;
                        }

                        if (fullLogging)
                        {
                            Logger.Info("Rejecting {0} as it's already part of {1}:{2}.", theFolder, si.ShowName,
                                        folder);
                        }

                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 7
0
        protected override void Check(ShowItem si, DirFilesCache dfc, TVDoc.ScanSettings settings)
        {
            if (settings.Token.IsCancellationRequested)
            {
                throw new TVRenameOperationInterruptedException();
            }

            if (!Active())
            {
                return;
            }

            Dictionary <int, List <string> > allFolders = si.AllExistngFolderLocations();

            if (allFolders.Count == 0) // no folders defined for this show
            {
                return;                // so, nothing to do.
            }

            // process each folder for each season...
            foreach (int snum in si.GetSeasonKeys())
            {
                if (settings.Token.IsCancellationRequested)
                {
                    throw new TVRenameOperationInterruptedException();
                }

                if (si.IgnoreSeasons.Contains(snum) || !allFolders.ContainsKey(snum))
                {
                    continue;
                }

                // all the folders for this particular season
                MergeShowEpisodes(si, dfc, settings.Token, snum, allFolders[snum]);
            } // for each season of this show
        }
        protected override void Check(ShowItem si, DirFilesCache dfc, TVDoc.ScanSettings settings)
        {
            if (settings.Token.IsCancellationRequested)
            {
                throw new TVRenameOperationInterruptedException();
            }

            if (!TVSettings.Instance.AutoMergeLibraryEpisodes)
            {
                return;
            }

            Dictionary <int, List <string> > allFolders = si.AllExistngFolderLocations();

            if (allFolders.Count == 0) // no folders defined for this show
            {
                return;                // so, nothing to do.
            }

            int[] numbers = new int[si.SeasonEpisodes.Keys.Count];
            si.SeasonEpisodes.Keys.CopyTo(numbers, 0);

            // process each folder for each season...
            foreach (int snum in numbers)
            {
                if (settings.Token.IsCancellationRequested)
                {
                    throw new TVRenameOperationInterruptedException();
                }

                if ((si.IgnoreSeasons.Contains(snum)) || (!allFolders.ContainsKey(snum)))
                {
                    continue; // ignore/skip this season
                }

                if ((snum == 0) && (si.CountSpecials))
                {
                    continue; // don't process the specials season, as they're merged into the seasons themselves
                }

                if ((snum == 0) && TVSettings.Instance.IgnoreAllSpecials)
                {
                    continue;
                }

                // all the folders for this particular season
                List <string> folders = allFolders[snum];

                List <ProcessedEpisode> eps = si.SeasonEpisodes[snum];

                List <ShowRule> rulesToAdd = new List <ShowRule>();

                foreach (string folder in folders)
                {
                    if (settings.Token.IsCancellationRequested)
                    {
                        throw new TVRenameOperationInterruptedException();
                    }

                    FileInfo[] files = dfc.GetFiles(folder);
                    if (files is null)
                    {
                        continue;
                    }

                    foreach (FileInfo fi in files)
                    {
                        if (settings.Token.IsCancellationRequested)
                        {
                            throw new TVRenameOperationInterruptedException();
                        }

                        if (!fi.IsMovieFile())
                        {
                            continue; //not a video file, so ignore
                        }

                        if (!FinderHelper.FindSeasEp(fi, out int seasNum, out int epNum, out int maxEp, si,
                                                     out TVSettings.FilenameProcessorRE _))
                        {
                            continue; // can't find season & episode, so this file is of no interest to us
                        }

                        if (seasNum == -1)
                        {
                            seasNum = snum;
                        }

                        int epIdx = eps.FindIndex(x =>
                                                  ((x.AppropriateEpNum == epNum) && (x.AppropriateSeasonNumber == seasNum)));

                        if (epIdx == -1)
                        {
                            continue; // season+episode number don't correspond to any episode we know of from thetvdb
                        }

                        ProcessedEpisode ep = eps[epIdx];

                        if (ep.Type != ProcessedEpisode.ProcessedEpisodeType.merged && maxEp != -1)
                        {
                            LOGGER.Info(
                                $"Looking at {ep.Show.ShowName} and have identified that episode {epNum} and {maxEp} of season {seasNum} should be merged into one file {fi.FullName}");

                            ShowRule sr = new ShowRule
                            {
                                DoWhatNow = RuleAction.kMerge,
                                First     = epNum,
                                Second    = maxEp
                            };

                            rulesToAdd.Add(sr);
                        }
                    } // foreach file in folder
                }     // for each folder for this season of this show

                foreach (ShowRule sr in rulesToAdd)
                {
                    si.AddSeasonRule(snum, sr);
                    LOGGER.Info($"Added new rule automatically for {sr}");

                    //Regenerate the episodes with the new rule added
                    ShowLibrary.GenerateEpisodeDict(si);
                }
            } // for each season of this show
        }