Ejemplo n.º 1
0
        private static (int seas, int ep, int maxEp) IdentifyEpisode(ShowConfiguration?si, [NotNull] Match m, TVSettings.FilenameProcessorRE re)
        {
            if (!int.TryParse(m.Groups["s"].ToString(), out int seas))
            {
                if (!re.RegExpression.Contains("<s>") && (si?.AppropriateSeasons().Count ?? 0) == 1)
                {
                    seas = 1;
                }
                else
                {
                    seas = -1;
                }
            }

            if (!int.TryParse(m.Groups["e"].ToString(), out int ep))
            {
                ep = -1;
            }

            if (!int.TryParse(m.Groups["f"].ToString(), out int maxEp))
            {
                maxEp = -1;
            }

            return(seas, ep, maxEp);
        }
Ejemplo n.º 2
0
        private static ShowSummaryData AddShowDetails([NotNull] ShowConfiguration si)
        {
            ShowSummaryData showSummary = new ShowSummaryData
            {
                ShowName          = si.ShowName,
                ShowConfiguration = si
            };

            if (si.CachedShow != null)
            {
                foreach (int snum in si.AppropriateSeasons().Keys)
                {
                    ShowSummaryData.ShowSummarySeasonData seasonData = GetSeasonDetails(si, snum);
                    if (seasonData != null)
                    {
                        showSummary.AddSeason(seasonData);
                    }
                }
            }
            return(showSummary);
        }
Ejemplo n.º 3
0
        private static ShowSummaryData.ShowSummarySeasonData?GetSeasonDetails([NotNull] ShowConfiguration si, int snum)
        {
            int             epCount         = 0;
            int             epGotCount      = 0;
            int             epAiredCount    = 0;
            DirFilesCache   dfc             = new DirFilesCache();
            ProcessedSeason processedSeason = null;

            if (snum >= 0 && si.AppropriateSeasons().TryGetValue(snum, out processedSeason))
            {
                List <ProcessedEpisode> eis = si.SeasonEpisodes[snum];

                foreach (ProcessedEpisode ei in eis)
                {
                    epCount++;

                    // if has air date and has been aired in the past
                    if (ei.FirstAired != null && ei.FirstAired < DateTime.Now)
                    {
                        epAiredCount++;
                    }

                    List <FileInfo> fl = dfc.FindEpOnDisk(ei, false);
                    if (fl.Count != 0)
                    {
                        epGotCount++;
                    }
                }
            }

            if (processedSeason != null)
            {
                return(new ShowSummaryData.ShowSummarySeasonData(snum, epCount, epAiredCount, epGotCount,
                                                                 processedSeason, si.IgnoreSeasons.Contains(snum)));
            }

            return(null);
        }
Ejemplo n.º 4
0
        public override ItemList?ProcessSeason(ShowConfiguration si, string folder, int snum, bool forceRefresh)
        {
            ProcessedSeason processedSeason = si.GetSeason(snum) ?? throw new ArgumentException($"ProcessSeason called for {si.ShowName} invalid season ({snum}), show has ({si.AppropriateSeasons().Keys.Select(i => i.ToString() ).ToCsv()})");
            DateTime?       updateTime      = processedSeason.LastAiredDate();

            if (!TVSettings.Instance.CorrectFileDates || !updateTime.HasValue)
            {
                return(null);
            }

            if (si.AutoAddType == ShowConfiguration.AutomaticFolderType.baseOnly && folder.Equals(si.AutoAddFolderBase))
            {
                //We do not need to look at the season folder - there is no such thing as it'll be covered by the show folder
                return(null);
            }

            DateTime newUpdateTime = Helpers.GetMinWindowsTime(updateTime.Value);

            DirectoryInfo di = new DirectoryInfo(folder);

            try
            {
                if (di.LastWriteTimeUtc != newUpdateTime && !doneFilesAndFolders.Contains(di.FullName))
                {
                    doneFilesAndFolders.Add(di.FullName);
                    return(new ItemList {
                        new ActionDateTouchSeason(di, processedSeason, newUpdateTime)
                    });
                }
            }
            catch (Exception)
            {
                doneFilesAndFolders.Add(di.FullName);
                return(new ItemList {
                    new ActionDateTouchSeason(di, processedSeason, newUpdateTime)
                });
            }

            return(null);
        }