예제 #1
0
        public static int EPNumberSorter(ProcessedEpisode e1, ProcessedEpisode e2)
        {
            int ep1 = e1.EpNum;
            int ep2 = e2.EpNum;

            return ep1 - ep2;
        }
예제 #2
0
 public ActionDownload(ShowItem si, ProcessedEpisode pe, FileInfo dest, string bannerPath)
 {
     this.Episode = pe;
     this.SI = si;
     this.Destination = dest;
     this.BannerPath = bannerPath;
 }
예제 #3
0
        public static int DVDOrderSorter(ProcessedEpisode e1, ProcessedEpisode e2)
        {
            int ep1 = e1.EpNum;
            int ep2 = e2.EpNum;

            string key = "DVD_episodenumber";
            if (e1.Items.ContainsKey(key) && e2.Items.ContainsKey(key))
            {
                string n1 = e1.Items[key];
                string n2 = e2.Items[key];
                if ((!string.IsNullOrEmpty(n1)) && (!string.IsNullOrEmpty(n2)))
                {
                    try
                    {
                        int t1 = (int) (1000.0 * double.Parse(n1));
                        int t2 = (int) (1000.0 * double.Parse(n2));
                        ep1 = t1;
                        ep2 = t2;
                    }
                    catch (FormatException)
                    {
                    }
                }
            }

            return ep1 - ep2;
        }
예제 #4
0
 public ActionCopyMoveRename(Op operation, FileInfo from, FileInfo to, ProcessedEpisode ep)
 {
     this.PercentDone = 0;
     this.Episode = ep;
     this.Operation = operation;
     this.From = from;
     this.To = to;
 }
예제 #5
0
 public ActionDownload(ShowItem si, ProcessedEpisode pe, FileInfo dest, string bannerPath, bool mede8erShrink)
 {
     this.Episode = pe;
     this.SI = si;
     this.Destination = dest;
     this.BannerPath = bannerPath;
     ShrinkLargeMede8erImage = mede8erShrink;
 }
예제 #6
0
 public ProcessedEpisode(ProcessedEpisode O)
     : base(O)
 {
     this.NextToAir = O.NextToAir;
     this.EpNum2 = O.EpNum2;
     this.Ignore = O.Ignore;
     this.SI = O.SI;
     this.OverallNumber = O.OverallNumber;
 }
 public ItemList ProcessEpisode(ProcessedEpisode dbep, FileInfo filo)
 {
     ItemList TheActionList = new ItemList();
     foreach (DownloadIdentifier di in Identifiers)
     {
         TheActionList.Add(di.ProcessEpisode(dbep,filo));
     }
     return TheActionList;
 }
        public CustomNameTagsFloatingWindow(ProcessedEpisode pe)
        {
            this.InitializeComponent();

            foreach (string s in CustomName.Tags)
            {
                string txt = s;
                if (pe != null)
                    txt += " - " + CustomName.NameForNoExt(pe, s);

                this.label1.Text += txt + "\r\n";
            }
        }
예제 #9
0
        public AddEditSearchEngine(Searchers s, ProcessedEpisode pe)
        {
            this.SampleEpisode = pe;
            this.InitializeComponent();
            this.Cntfw = null;

            this.SetupGrid();
            this.mSearchers = s;

            for (int i = 0; i < this.mSearchers.Count(); i++)
            {
                this.AddNewRow();
                this.Grid1[i + 1, 0].Value = this.mSearchers.Name(i);
                this.Grid1[i + 1, 1].Value = this.mSearchers.URL(i);
            }
        }
예제 #10
0
        public override ItemList ProcessEpisode(ProcessedEpisode dbep, FileInfo filo, bool forceRefresh)
        {
            if (TVSettings.Instance.Mede8erXML)
            {
                ItemList TheActionList = new ItemList();
                string fn = filo.Name;
                fn = fn.Substring(0, fn.Length - filo.Extension.Length);
                fn += ".xml";
                FileInfo nfo = FileHelper.FileInFolder(filo.Directory, fn);

                if (forceRefresh || !nfo.Exists || (dbep.Srv_LastUpdated > TimeZone.Epoch(nfo.LastWriteTime)))
                    TheActionList.Add(new ActionMede8erXML(nfo, dbep));

                return TheActionList;

            }
            return base.ProcessEpisode(dbep, filo, forceRefresh);
        }
예제 #11
0
        public string NameForExt(ProcessedEpisode pe, string extension, int folderNameLength)
        {
            // set folderNameLength to have the filename truncated if the total path length is too long

            string r = NameForNoExt(pe, this.StyleString);

            int maxLenOK = 200 - (folderNameLength + ((extension != null) ? extension.Length : 0));
            if (r.Length > maxLenOK)
                r = r.Substring(0, maxLenOK);

            if (!string.IsNullOrEmpty(extension))
            {
                if (!extension.StartsWith("."))
                    r += ".";
                r += extension;
            }
            return r;
        }
예제 #12
0
        public override ItemList ProcessEpisode(ProcessedEpisode dbep, FileInfo filo, bool forceRefresh)
        {
            if (TVSettings.Instance.pyTivoMeta)
            {
                ItemList TheActionList = new ItemList(); 
                string fn = filo.Name;
                fn += ".txt";
                string folder = filo.DirectoryName;
                if (TVSettings.Instance.pyTivoMetaSubFolder)
                    folder += "\\.meta";
                FileInfo meta = FileHelper.FileInFolder(folder, fn);

                if (!meta.Exists || (dbep.Srv_LastUpdated > TimeZone.Epoch(meta.LastWriteTime)))
                    TheActionList.Add(new ActionPyTivoMeta(meta, dbep));

                return TheActionList;
            }
            return base.ProcessEpisode(dbep, filo, forceRefresh);
        }
예제 #13
0
        public override ItemList ProcessEpisode(ProcessedEpisode dbep, FileInfo filo, bool forceRefresh)
        {
            if (TVSettings.Instance.EpJPGs)
            {
                ItemList TheActionList = new ItemList(); 
                string ban = dbep.GetItem("filename");
                if (!string.IsNullOrEmpty(ban))
                {
                    string basefn = filo.Name;
                    basefn = basefn.Substring(0, basefn.Length - filo.Extension.Length); //remove extension

                    FileInfo imgjpg = FileHelper.FileInFolder(filo.Directory, basefn + ".jpg");

                    if (forceRefresh || !imgjpg.Exists)
                        TheActionList.Add(new ActionDownload(dbep.SI, dbep, imgjpg, ban, TVSettings.Instance.ShrinkLargeMede8erImages));
                }

                return TheActionList;

            }

            return base.ProcessEpisode(dbep, filo, forceRefresh);
        }
예제 #14
0
        public override ItemList ProcessEpisode(ProcessedEpisode dbep, FileInfo filo,bool forceRefresh)
        {
            if (TVSettings.Instance.NFOs)
            {
                ItemList TheActionList = new ItemList();

                string fn = filo.Name;
                fn = fn.Substring(0, fn.Length - filo.Extension.Length);
                fn += ".nfo";
                FileInfo nfo = FileHelper.FileInFolder(filo.Directory, fn);

                if (!nfo.Exists || (dbep.Srv_LastUpdated > TimeZone.Epoch(nfo.LastWriteTime)) || forceRefresh)
                {
                    //If we do not already have plans to put the file into place
                    if (!(DownloadXBMCMetaData.doneNFO.Contains(nfo.FullName)))
                    {
                        TheActionList.Add(new ActionNFO(nfo, dbep));
                        doneNFO.Add(nfo.FullName);
                    }
                }
                return TheActionList;
            }
            return base.ProcessEpisode(dbep, filo, forceRefresh);
        }
예제 #15
0
파일: TVDoc.cs 프로젝트: mudboy/tvrename
        public static void ApplyRules(List<ProcessedEpisode> eis, List<ShowRule> rules, ShowItem si)
        {
            foreach (ShowRule sr in rules)
            {
                int nn1 = sr.First;
                int nn2 = sr.Second;

                int n1 = -1;
                int n2 = -1;
                // turn nn1 and nn2 from ep number into position in array
                for (int i = 0; i < eis.Count; i++)
                {
                    if (eis[i].EpNum == nn1)
                    {
                        n1 = i;
                        break;
                    }
                }
                for (int i = 0; i < eis.Count; i++)
                {
                    if (eis[i].EpNum == nn2)
                    {
                        n2 = i;
                        break;
                    }
                }

                if (sr.DoWhatNow == RuleAction.kInsert)
                {
                    // this only applies for inserting an episode, at the end of the list
                    if (nn1 == eis[eis.Count-1].EpNum+1) // after the last episode
                        n1 = eis.Count;
                }

                string txt = sr.UserSuppliedText;
                int ec = eis.Count;

                switch (sr.DoWhatNow)
                {
                    case RuleAction.kRename:
                        {
                            if ((n1 < ec) && (n1 >= 0))
                                eis[n1].Name = txt;
                            break;
                        }
                    case RuleAction.kRemove:
                        {
                            if ((n1 < ec) && (n1 >= 0) && (n2 < ec) && (n2 >= 0))
                                eis.RemoveRange(n1, 1 + n2 - n1);
                            else if ((n1 < ec) && (n1 >= 0) && (n2 == -1))
                                eis.RemoveAt(n1);
                            break;
                        }
                    case RuleAction.kIgnoreEp:
                        {
                            if (n2 == -1)
                                n2 = n1;
                            for (int i = n1; i <= n2; i++)
                            {
                                if ((i < ec) && (i >= 0))
                                    eis[i].Ignore = true;
                            }
                            break;
                        }
                    case RuleAction.kSplit:
                        {
                            // split one episode into a multi-parter
                            if ((n1 < ec) && (n1 >= 0))
                            {
                                ProcessedEpisode ei = eis[n1];
                                string nameBase = ei.Name;
                                eis.RemoveAt(n1); // remove old one
                                for (int i = 0; i < nn2; i++) // make n2 new parts
                                {
                                    ProcessedEpisode pe2 = new ProcessedEpisode(ei, si)
                                                               {
                                                                   Name = nameBase + " (Part " + (i + 1) + ")",
                                                                   EpNum = -2,
                                                                   EpNum2 = -2
                                                               };
                                    eis.Insert(n1 + i, pe2);
                                }
                            }
                            break;
                        }
                    case RuleAction.kMerge:
                    case RuleAction.kCollapse:
                        {
                            if ((n1 != -1) && (n2 != -1) && (n1 < ec) && (n2 < ec) && (n1 < n2))
                            {
                                ProcessedEpisode oldFirstEI = eis[n1];
                                string combinedName = eis[n1].Name + " + ";
                                string combinedSummary = eis[n1].Overview + "<br/><br/>";
                                //int firstNum = eis[n1]->TVcomEpCount();
                                for (int i = n1 + 1; i <= n2; i++)
                                {
                                    combinedName += eis[i].Name;
                                    combinedSummary += eis[i].Overview;
                                    if (i != n2)
                                    {
                                        combinedName += " + ";
                                        combinedSummary += "<br/><br/>";
                                    }
                                }

                                eis.RemoveRange(n1, n2 - n1);

                                eis.RemoveAt(n1);

                                ProcessedEpisode pe2 = new ProcessedEpisode(oldFirstEI, si)
                                                           {
                                                               Name = ((string.IsNullOrEmpty(txt)) ? combinedName : txt),
                                                               EpNum = -2
                                                           };
                                if (sr.DoWhatNow == RuleAction.kMerge)
                                    pe2.EpNum2 = -2 + n2 - n1;
                                else
                                    pe2.EpNum2 = -2;

                                pe2.Overview = combinedSummary;
                                eis.Insert(n1, pe2);
                            }
                            break;
                        }
                    case RuleAction.kSwap:
                        {
                            if ((n1 != -1) && (n2 != -1) && (n1 < ec) && (n2 < ec))
                            {
                                ProcessedEpisode t = eis[n1];
                                eis[n1] = eis[n2];
                                eis[n2] = t;
                            }
                            break;
                        }
                    case RuleAction.kInsert:
                        {
                            if ((n1 < ec) && (n1 >= 0))
                            {
                                ProcessedEpisode t = eis[n1];
                                ProcessedEpisode n = new ProcessedEpisode(t.TheSeries, t.TheSeason, si)
                                                         {
                                                             Name = txt,
                                                             EpNum = -2,
                                                             EpNum2 = -2
                                                         };
                                eis.Insert(n1, n);
                            }
                            else if (n1 == eis.Count)
                            {
                                ProcessedEpisode t = eis[n1-1];
                                ProcessedEpisode n = new ProcessedEpisode(t.TheSeries, t.TheSeason, si)
                                {
                                    Name = txt,
                                    EpNum = -2,
                                    EpNum2 = -2
                                };
                                eis.Add(n);
                            }
                            break;
                        }
                } // switch DoWhatNow

                Renumber(eis);
            } // for each rule
            // now, go through and remove the ignored ones (but don't renumber!!)
            for (int i = eis.Count - 1; i >= 0; i--)
            {
                if (eis[i].Ignore)
                    eis.RemoveAt(i);
            }
        }
예제 #16
0
 public ActionDateTouch(FileInfo f, ProcessedEpisode pe, DateTime date)
 {
     Episode    = pe;
     whereFile  = f;
     updateTime = date;
 }
예제 #17
0
 public ActionDateTouchEpisode(FileInfo f, ProcessedEpisode pe, DateTime date) : base(f, date)
 {
     Episode = pe;
 }
예제 #18
0
 public ActionDownload(ShowItem si, ProcessedEpisode pe, FileInfo dest, string bannerPath) : this(si, pe, dest, bannerPath, false) { }
예제 #19
0
 public ItemList ProcessEpisode(ProcessedEpisode dbep, FileInfo filo) => ProcessEpisode(dbep, filo, false);
예제 #20
0
        public ShowItem SI; // if for an entire show, rather than specific episode

        public ActionNFO(FileInfo nfo, ProcessedEpisode pe)
        {
            this.SI      = null;
            this.Episode = pe;
            this.Where   = nfo;
        }
예제 #21
0
 public static string NameForNoExt(ProcessedEpisode pe, string styleString)
 {
     return(NameForNoExt(pe, styleString, false));
 }
예제 #22
0
파일: Beta.cs 프로젝트: sauv0168/tvrename
 private static bool EpisodesMatch([NotNull] ProcessedEpisode pep, ProcessedEpisode comparePep)
 {
     return(pep.FirstAired.HasValue && comparePep.FirstAired.HasValue &&
            pep.FirstAired == comparePep.FirstAired && pep.EpisodeId < comparePep.EpisodeId);
 }
예제 #23
0
파일: Beta.cs 프로젝트: sauv0168/tvrename
        private static bool IsOneFound([NotNull] StringBuilder output, DirFilesCache dfc, [NotNull] ProcessedEpisode pep, [NotNull] ProcessedEpisode comparePep, ref bool largerFileSize)
        {
            output.AppendLine("####### POSSIBLE DUPLICATE DUE TO NAME##########");

            //Do the missing Test (ie is one missing and not the other)
            bool pepFound        = dfc.FindEpOnDisk(pep).Any();
            bool comparePepFound = dfc.FindEpOnDisk(comparePep).Any();
            bool oneFound        = (pepFound ^ comparePepFound);

            if (oneFound)
            {
                output.AppendLine(
                    "####### POSSIBLE DUPLICATE DUE TO ONE MISSING AND ONE FOUND ##########");

                ProcessedEpisode possibleDupEpisode = pepFound ? pep : comparePep;
                //Test the file sizes in the season
                //More than 40% longer
                FileInfo   possibleDupFile   = dfc.FindEpOnDisk(possibleDupEpisode)[0];
                int        dupMovieLength    = possibleDupFile.GetFilmLength();
                List <int> otherMovieLengths = new List <int>();
                foreach (FileInfo file in possibleDupFile.Directory.EnumerateFiles())
                {
                    if (file.IsMovieFile())
                    {
                        otherMovieLengths.Add(file.GetFilmLength());
                    }
                }

                int averageMovieLength = (otherMovieLengths.Count == 1)
                    ?otherMovieLengths.Sum()
                    :(otherMovieLengths.Sum() - dupMovieLength) / (otherMovieLengths.Count - 1);

                largerFileSize = (dupMovieLength > averageMovieLength * 1.4);
                if (largerFileSize)
                {
                    {
                        output.AppendLine(
                            "######################################################################");

                        output.AppendLine(
                            "####### SURELY WE HAVE ONE NOW                              ##########");

                        output.AppendLine(
                            $"####### {possibleDupEpisode.AiredEpNum}({possibleDupEpisode.Name}) has length {dupMovieLength} greater than the average in the directory of {averageMovieLength}");

                        output.AppendLine(
                            "######################################################################");
                    }
                }
            }

            return(oneFound);
        }
예제 #24
0
 public string NameFor([NotNull] ProcessedEpisode pe) => NameFor(pe, string.Empty, 0);
예제 #25
0
        public static string NameForNoExt([NotNull] ProcessedEpisode pe, [NotNull]  string styleString, bool urlEncode)
        {
            string name = styleString;

            string showname = pe.Show.ShowName;
            string epname   = pe.Name;

            if (urlEncode)
            {
                showname = Uri.EscapeDataString(showname);
                epname   = Uri.EscapeDataString(epname);
            }

            name = name.ReplaceInsensitive("{ShowName}", showname);
            name = name.ReplaceInsensitive("{Season}", pe.AppropriateSeasonNumber.ToString());
            name = name.ReplaceInsensitive("{Season:2}", pe.AppropriateSeasonNumber.ToString("00"));
            name = name.ReplaceInsensitive("{SeasonNumber}", pe.AppropriateSeasonIndex.ToString());
            name = name.ReplaceInsensitive("{SeasonNumber:2}", pe.AppropriateSeasonIndex.ToString("00"));
            if (pe.AppropriateSeason.Episodes.Count >= 100)
            {
                name = name.ReplaceInsensitive("{Episode}", pe.AppropriateEpNum.ToString("000"));
                name = name.ReplaceInsensitive("{Episode2}", pe.EpNum2.ToString("000"));
            }
            else
            {
                name = name.ReplaceInsensitive("{Episode}", pe.AppropriateEpNum.ToString("00"));
                name = name.ReplaceInsensitive("{Episode2}", pe.EpNum2.ToString("00"));
            }
            name = name.ReplaceInsensitive("{EpisodeName}", epname);
            name = name.ReplaceInsensitive("{Number}", pe.OverallNumber.ToString());
            name = name.ReplaceInsensitive("{Number:2}", pe.OverallNumber.ToString("00"));
            name = name.ReplaceInsensitive("{Number:3}", pe.OverallNumber.ToString("000"));
            name = name.ReplaceInsensitive("{Year}", pe.TheSeries.MinYear.ToString());
            name = name.ReplaceInsensitive("{SeasonYear}", pe.AppropriateSeason.MinYear().ToString());
            name = name.ReplaceInsensitive("{Imdb}", pe.ImdbCode);
            name = name.ReplaceInsensitive("{ShowImdb}", pe.Show?.TheSeries()?.Imdb ?? string.Empty);

            name = ReplaceDates(urlEncode, name, pe.GetAirDateDt(false));

            string allEps = "";

            for (int i = pe.AppropriateEpNum; i <= pe.EpNum2; i++)
            {
                allEps += "E" + i.ToString("00");
            }

            name = Regex.Replace(name, "{AllEpisodes}", allEps, RegexOptions.IgnoreCase);

            if (pe.EpNum2 == pe.AppropriateEpNum)
            {
                name = Regex.Replace(name, "([^\\\\])\\[.*?[^\\\\]\\]", "$1"); // remove optional parts
            }
            else
            {
                name = Regex.Replace(name, "([^\\\\])\\[(.*?[^\\\\])\\]", "$1$2"); // remove just the brackets
            }

            name = name.Replace("\\[", "[");
            name = name.Replace("\\]", "]");

            return(name.Trim());
        }
예제 #26
0
 public static string NameForNoExt([NotNull] ProcessedEpisode pe, [NotNull]  string styleString) => NameForNoExt(pe, styleString, false);
예제 #27
0
파일: TVDoc.cs 프로젝트: mudboy/tvrename
        public bool MatchesSequentialNumber(string filename, ref int seas, ref int ep, ProcessedEpisode pe)
        {
            if (pe.OverallNumber == -1)
                return false;

            string num = pe.OverallNumber.ToString();

            bool found = Regex.Match("X" + filename + "X", "[^0-9]0*" + num + "[^0-9]").Success; // need to pad to let it match non-numbers at start and end
            if (found)
            {
                seas = pe.SeasonNumber;
                ep = pe.EpNum;
            }
            return found;
        }
예제 #28
0
        public static string NameForNoExt(ProcessedEpisode pe, String styleString, bool urlEncode)
        {
            String name = styleString;

            string showname = pe.SI.ShowName;
            string epname   = pe.Name;

            if (urlEncode)
            {
                showname = System.Web.HttpUtility.UrlEncode(showname);
                epname   = System.Web.HttpUtility.UrlEncode(epname);
            }

            name = name.Replace("{ShowName}", showname);
            name = name.Replace("{Season}", pe.SeasonNumber.ToString());
            name = name.Replace("{Season:2}", pe.SeasonNumber.ToString("00"));
            name = name.Replace("{Episode}", pe.EpNum.ToString("00"));
            name = name.Replace("{Episode2}", pe.EpNum2.ToString("00"));
            name = name.Replace("{EpisodeName}", epname);
            name = name.Replace("{Number}", pe.OverallNumber.ToString());
            name = name.Replace("{Number:2}", pe.OverallNumber.ToString("00"));
            name = name.Replace("{Number:3}", pe.OverallNumber.ToString("000"));
            DateTime?airdt = pe.GetAirDateDT(false);

            if (airdt != null)
            {
                DateTime dt = (DateTime)airdt;
                name = name.Replace("{ShortDate}", dt.ToString("d"));
                name = name.Replace("{LongDate}", dt.ToString("D"));
                string ymd = dt.ToString("yyyy/MM/dd");
                if (urlEncode)
                {
                    ymd = System.Web.HttpUtility.UrlEncode(ymd);
                }
                name = name.Replace("{YMDDate}", ymd);
            }
            else
            {
                name = name.Replace("{ShortDate}", "---");
                name = name.Replace("{LongDate}", "------");
                string ymd = "----/--/--";
                if (urlEncode)
                {
                    ymd = System.Web.HttpUtility.UrlEncode(ymd);
                }
                name = name.Replace("{YMDDate}", ymd);
            }

            String allEps = "";

            for (int i = pe.EpNum; i <= pe.EpNum2; i++)
            {
                allEps += "E" + i.ToString("00");
            }
            name = Regex.Replace(name, "{AllEpisodes}", allEps);

            if (pe.EpNum2 == pe.EpNum)
            {
                name = Regex.Replace(name, "([^\\\\])\\[.*?[^\\\\]\\]", "$1"); // remove optional parts
            }
            else
            {
                name = Regex.Replace(name, "([^\\\\])\\[(.*?[^\\\\])\\]", "$1$2"); // remove just the brackets
            }
            name = name.Replace("\\[", "[");
            name = name.Replace("\\]", "]");

            return(name);
        }
예제 #29
0
파일: TVDoc.cs 프로젝트: mudboy/tvrename
        public static List<ProcessedEpisode> GenerateEpisodes(ShowItem si, SeriesInfo ser, int snum, bool applyRules)
        {
            List<ProcessedEpisode> eis = new List<ProcessedEpisode>();

            if ((ser == null) || !ser.Seasons.ContainsKey(snum))
                return null; // todo.. something?

            Season seas = ser.Seasons[snum];

            if (seas == null)
                return null; // TODO: warn user

            foreach (Episode e in seas.Episodes)
                eis.Add(new ProcessedEpisode(e, si)); // add a copy

            if (si.DVDOrder)
            {
                eis.Sort(new System.Comparison<ProcessedEpisode>(ProcessedEpisode.DVDOrderSorter));
                Renumber(eis);
            }
            else
                eis.Sort(new System.Comparison<ProcessedEpisode>(ProcessedEpisode.EPNumberSorter));

            if (si.CountSpecials && ser.Seasons.ContainsKey(0))
            {
                // merge specials in
                foreach (Episode ep in ser.Seasons[0].Episodes)
                {
                    if (ep.Items.ContainsKey("airsbefore_season") && ep.Items.ContainsKey("airsbefore_episode"))
                    {
                        string seasstr = ep.Items["airsbefore_season"];
                        string epstr = ep.Items["airsbefore_episode"];
                        if ((string.IsNullOrEmpty(seasstr)) || (string.IsNullOrEmpty(epstr)))
                            continue;
                        int sease = int.Parse(seasstr);
                        if (sease != snum)
                            continue;
                        int epnum = int.Parse(epstr);
                        for (int i = 0; i < eis.Count; i++)
                        {
                            if ((eis[i].SeasonNumber == sease) && (eis[i].EpNum == epnum))
                            {
                                ProcessedEpisode pe = new ProcessedEpisode(ep, si)
                                                          {
                                                              TheSeason = eis[i].TheSeason,
                                                              SeasonID = eis[i].SeasonID
                                                          };
                                eis.Insert(i, pe);
                                break;
                            }
                        }
                    }
                }
                // renumber to allow for specials
                int epnumr = 1;
                for (int j = 0; j < eis.Count; j++)
                {
                    eis[j].EpNum2 = epnumr + (eis[j].EpNum2 - eis[j].EpNum);
                    eis[j].EpNum = epnumr;
                    epnumr++;
                }
            }

            if (applyRules)
            {
                List<ShowRule> rules = si.RulesForSeason(snum);
                if (rules != null)
                    ApplyRules(eis, rules, si);
            }

            return eis;
        }
예제 #30
0
 public ActionDateTouch(FileInfo f, ProcessedEpisode pe, DateTime date)
 {
     this.Episode    = pe;
     this.WhereFile  = f;
     this.updateTime = date;
 }
예제 #31
0
 public ActionNfo(FileInfo nfo, ProcessedEpisode pe) : base(nfo, null)
 {
     Episode = pe;
 }
예제 #32
0
        protected override void DoCheck(SetProgressDelegate prog, ICollection <ShowItem> showList, TVDoc.ScanSettings settings)
        {
            if (TVSettings.Instance.SearchRSSManualScanOnly && settings.Unattended)
            {
                LOGGER.Info("Searching RSS Feeds is cancelled as this is an unattended scan");
                return;
            }
            int c = ActionList.MissingItems().Count() + 2;
            int n = 1;

            UpdateStatus(n, c, "Searching on RSS Feed...");

            // ReSharper disable once InconsistentNaming
            RssItemList RSSList = new RssItemList();

            foreach (string s in TVSettings.Instance.RSSURLs)
            {
                RSSList.DownloadRSS(s, TVSettings.Instance.FNPRegexs, TVSettings.Instance.RSSUseCloudflare);
            }

            ItemList newItems = new ItemList();
            ItemList toRemove = new ItemList();

            foreach (ItemMissing action in ActionList.MissingItems().ToList())
            {
                if (settings.Token.IsCancellationRequested)
                {
                    return;
                }

                UpdateStatus(n++, c, action.Filename);

                ProcessedEpisode pe               = action.Episode;
                string           simpleShowName   = Helpers.SimplifyName(pe.Show.ShowName);
                string           simpleSeriesName = Helpers.SimplifyName(pe.TheSeries.Name);
                ItemList         newItemsForThisMissingEpisode = new ItemList();

                foreach (RSSItem rss in RSSList)
                {
                    if (
                        !FileHelper.SimplifyAndCheckFilename(rss.ShowName, simpleShowName, true, false) &&
                        !(
                            string.IsNullOrEmpty(rss.ShowName) &&
                            FileHelper.SimplifyAndCheckFilename(rss.Title, simpleSeriesName, true, false)
                            )
                        )
                    {
                        continue;
                    }

                    if (rss.Season != pe.AppropriateSeasonNumber)
                    {
                        continue;
                    }
                    if (rss.Episode != pe.AppropriateEpNum)
                    {
                        continue;
                    }

                    LOGGER.Info($"Adding {rss.URL} from RSS feed as it appears to be match for {action.Episode.Show.ShowName} S{action.Episode.AppropriateSeasonNumber}E{action.Episode.AppropriateEpNum}");
                    newItemsForThisMissingEpisode.Add(new ActionTDownload(rss, action.TheFileNoExt, pe, action));
                    toRemove.Add(action);
                }

                foreach (ActionTDownload x in FindDuplicates(newItemsForThisMissingEpisode))
                {
                    newItemsForThisMissingEpisode.Remove(x);
                }

                newItems.AddNullableRange(newItemsForThisMissingEpisode);
            }
            ActionList.Replace(toRemove, newItems);
        }
예제 #33
0
 public virtual ItemList ProcessEpisode(ProcessedEpisode dbep, FileInfo filo, bool forceRefresh) => null;
예제 #34
0
 public ActionTDownload(string name, long sizeBytes, string url, string toWhereNoExt, ProcessedEpisode pe, ItemMissing me)
 {
     Episode         = pe;
     SourceName      = name;
     this.url        = url;
     theFileNoExt    = toWhereNoExt;
     UndoItemMissing = me;
     this.sizeBytes  = sizeBytes;
 }
예제 #35
0
 public ActionTRemove(IDownloadProvider source, TorrentEntry lastFoundEntry, ProcessedEpisode episode)
 {
     Episode = episode;
     client  = source;
     name    = lastFoundEntry;
 }
예제 #36
0
        private ProcessedEpisode?GetNextMostRecentProcessedEpisode(int nDaysFuture, ICollection <ProcessedEpisode> found, DateTime notBefore)
        {
            ProcessedEpisode nextAfterThat = null;
            TimeSpan         howClose      = TimeSpan.MaxValue;

            foreach (ShowConfiguration si in GetSortedShowItems())
            {
                lock (si.Provider == TVDoc.ProviderType.TVmaze ? TVmaze.LocalCache.Instance.SERIES_LOCK : TheTVDB.LocalCache.Instance.SERIES_LOCK)
                {
                    if (!si.ShowNextAirdate)
                    {
                        continue;
                    }

                    foreach (KeyValuePair <int, List <ProcessedEpisode> > v in si.ActiveSeasons.ToList())
                    {
                        if (si.IgnoreSeasons.Contains(v.Key))
                        {
                            continue; // ignore this season
                        }

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

                        if (v.Value is null)
                        {
                            continue;
                        }

                        foreach (ProcessedEpisode ei in v.Value)
                        {
                            if (found.Contains(ei))
                            {
                                continue;
                            }

                            DateTime?airdt = ei.GetAirDateDt(true);

                            if (airdt is null || airdt == DateTime.MaxValue)
                            {
                                continue;
                            }

                            DateTime dt = airdt.Value;

                            TimeSpan timeUntil = dt.Subtract(DateTime.Now);
                            if (timeUntil.TotalDays > nDaysFuture)
                            {
                                continue; //episode is too far in the future
                            }

                            TimeSpan ts = dt.Subtract(notBefore);
                            if (ts.TotalSeconds < 0)
                            {
                                continue; //episode is too far in the past
                            }

                            //if we have a closer match
                            if (TimeSpan.Compare(ts, howClose) < 0)
                            {
                                howClose      = ts;
                                nextAfterThat = ei;
                            }
                        }
                    }
                }
            }

            return(nextAfterThat);
        }
예제 #37
0
 public ActionPyTivoMeta(FileInfo nfo, ProcessedEpisode pe)
 {
     this.Episode = pe;
     this.Where   = nfo;
 }
예제 #38
0
 protected override string GenerateRecord(ProcessedEpisode ep, [NotNull] FileInfo file, string name, int length)
 {
     return($"#EXTINF:{length},{file.Name}\r\n{file.UrlPathFullName()}");
 }
예제 #39
0
        private FileInfo CheckFile([NotNull] string folder, FileInfo fi, [NotNull] FileInfo actualFile, string newName, ProcessedEpisode ep, IEnumerable <FileInfo> files)
        {
            if (TVSettings.Instance.RetainLanguageSpecificSubtitles)
            {
                (bool isSubtitleFile, string subtitleExtension) = fi.IsLanguageSpecificSubtitle();

                if (isSubtitleFile && actualFile.Name != newName)
                {
                    newName = TVSettings.Instance.FilenameFriendly(
                        TVSettings.Instance.NamingStyle.NameFor(ep, subtitleExtension, folder.Length));
                }
            }

            FileInfo newFile = FileHelper.FileInFolder(folder, newName); // rename updates the filename

            if (newFile.FullName != actualFile.FullName)
            {
                //Check that the file does not already exist
                //if (FileHelper.FileExistsCaseSensitive(newFile.FullName))
                if (FileHelper.FileExistsCaseSensitive(files, newFile))
                {
                    LOGGER.Warn(
                        $"Identified that {actualFile.FullName} should be renamed to {newName}, but it already exists.");
                }
                else
                {
                    LOGGER.Info($"Identified that {actualFile.FullName} should be renamed to {newName}.");
                    Doc.TheActionList.Add(new ActionCopyMoveRename(ActionCopyMoveRename.Op.rename, fi,
                                                                   newFile, ep, false, null, Doc));

                    //The following section informs the DownloadIdentifers that we already plan to
                    //copy a file in the appropriate place and they do not need to worry about downloading
                    //one for that purpose
                    downloadIdentifiers.NotifyComplete(newFile);

                    if (newFile.IsMovieFile())
                    {
                        return(newFile);
                    }
                }
            }
            else
            {
                if (actualFile.IsMovieFile())
                {
                    //File is correct name
                    LOGGER.Debug($"Identified that {actualFile.FullName} is in the right place. Marking it as 'seen'.");
                    //Record this episode as seen

                    TVSettings.Instance.PreviouslySeenEpisodes.EnsureAdded(ep);
                    if (TVSettings.Instance.IgnorePreviouslySeen)
                    {
                        Doc.SetDirty();
                    }
                }
            }

            return(null);
        }
예제 #40
0
        private static void AppendEpisode([NotNull] this StringBuilder sb, [NotNull] ProcessedEpisode ep, [CanBeNull] IReadOnlyCollection <FileInfo> fl, Color backgroundColour)
        {
            string stars          = StarRating(ep.EpisodeRating);
            string episodeUrl     = TheTVDB.WebsiteUrl(ep.SeriesId, ep.SeasonId, ep.EpisodeId);
            bool   ratingIsNumber = float.TryParse(ep.EpisodeRating, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, CultureInfo.CreateSpecificCulture("en-US"), out float rating);
            string siteRating     = ratingIsNumber && rating > 0
                ? rating + "/10" + AddRatingCount(ep.SiteRatingCount ?? 0)
                : "";

            string imdbLink       = string.IsNullOrWhiteSpace(ep.ImdbCode) ? string.Empty : "http://www.imdb.com/title/" + ep.ImdbCode;
            string productionCode = string.IsNullOrWhiteSpace(ep.ProductionCode)
                ? string.Empty
                : "Production Code <br/>" + ep.ProductionCode;

            string episodeDescriptor = CustomEpisodeName.NameForNoExt(ep, CustomEpisodeName.OldNStyle(6)); // may need to include (si.DVDOrder && snum == 0)? ep.Name:
            string writersHtml       = string.IsNullOrWhiteSpace(ep.Writer) ? string.Empty : "<b>Writers:</b> " + string.Join(", ", ep.Writers);
            string directorsHtml     = string.IsNullOrWhiteSpace(ep.EpisodeDirector) ? string.Empty : "<b>Directors:</b> " + string.Join(", ", ep.Directors);
            string guestHtml         = string.IsNullOrWhiteSpace(ep.EpisodeGuestStars) ? string.Empty : "<b>Guest Stars:</b> " + string.Join(", ", ep.GuestStars);
            string possibleBreak1    = string.IsNullOrWhiteSpace(writersHtml) || string.IsNullOrWhiteSpace(directorsHtml)
                ? string.Empty
                : "<br />";
            string possibleBreak2 = string.IsNullOrWhiteSpace(writersHtml) && string.IsNullOrWhiteSpace(directorsHtml) || string.IsNullOrWhiteSpace(guestHtml)
                ? string.Empty
                : "<br />";

            string searchButton = (fl is null || fl.Count == 0) && ep.HasAired()
                ? CreateButton(TVSettings.Instance.BTSearchURL(ep), "<i class=\"fas fa-search\"></i>", "Search for Torrent...")
                : string.Empty;

            string viewButton     = string.Empty;
            string explorerButton = string.Empty;

            if (fl != null)
            {
                foreach (string urlFilename in fl.Select(fi => Uri.EscapeDataString(fi.FullName)))
                {
                    viewButton     += CreateButton($"{UI.WATCH_PROXY}{urlFilename}", "<i class=\"far fa-eye\"></i>", "Watch Now");
                    explorerButton += CreateButton($"{UI.EXPLORE_PROXY}{urlFilename}", "<i class=\"far fa-folder-open\"></i>", "Open Containing Folder");
                }
            }

            string tvdbButton = CreateButton(episodeUrl, "TVDB.com", "View on TVDB");
            string imdbButton = CreateButton(imdbLink, "IMDB.com", "View on IMDB");
            string tvButton   = CreateButton(ep.ShowUrl, "TV.com", "View on TV.com");

            sb.AppendLine($@"
                <div class=""card card-body"" style=""background-color:{backgroundColour.HexColour()}"">
                 <div class=""row"">
                  <div class=""col-md-5"">{ep.ScreenShotHtml()}</div>
                   <div class=""col-md-7 d-flex flex-column"">
                    <div class=""row"">
                     <div class=""col-md-8""><h2>{episodeDescriptor}</h2></div>
                     <div class=""col-md-4 text-right"">{ep.DateDetailsHtml()}</div>
                    </div>
				   <div>
                    <blockquote>
                     {writersHtml}{possibleBreak1}
                     {directorsHtml}{possibleBreak2}
                     {guestHtml}
                    </blockquote>
                   </div>
                   <div><p class=""lead"">{ep.HiddenOverview()}</p></div>
                   <div>
                    {searchButton}
                    {viewButton}
                    {explorerButton}
                    {tvdbButton}
                    {imdbButton}
                    {tvButton}
                   </div>
		           <div class=""row align-items-bottom flex-grow-1"">
                    <div class=""col-md-6 align-self-end"">{stars}<br>{siteRating}</div>
                    <div class=""col-md-6 align-self-end text-right"">{productionCode}</div>
                   </div>
                  </div>
                 </div>
                </div>");
        }
예제 #41
0
 public ItemDownloading(IDownloadInformation dl, ProcessedEpisode pe, string desiredLocationNoExt, DownloadingFinder.DownloadApp tApp, ItemMissing me) : this(dl, desiredLocationNoExt, tApp, me)
 {
     Episode = pe;
 }
예제 #42
0
파일: UI.cs 프로젝트: madams74/tvrename
 public void RightClickOnMyShows(ShowItem si, Point pt)
 {
     this.mLastShowsClicked = new List<ShowItem>() { si };
     this.mLastEpClicked = null;
     this.mLastSeasonClicked = null;
     this.mLastActionsClicked = null;
     this.BuildRightClickMenu(pt);
 }
예제 #43
0
파일: TVDoc.cs 프로젝트: mudboy/tvrename
 public void DoBTSearch(ProcessedEpisode ep)
 {
     if (ep == null)
         return;
     TVDoc.SysOpen(this.Settings.BTSearchURL(ep));
 }
예제 #44
0
파일: UI.cs 프로젝트: madams74/tvrename
        public void WTWRightClickOnShow(List<ProcessedEpisode> eps, Point pt)
        {
            if (eps.Count == 0)
                return;
            ProcessedEpisode ep = eps[0];

            List<ShowItem> sis = new List<ShowItem>();
            foreach (var e in eps)
            {
                sis.Add(e.SI);
            }

            this.mLastEpClicked = ep;
            this.mLastShowsClicked = sis;
            this.mLastSeasonClicked = ep != null ? ep.TheSeason : null;
            this.mLastActionsClicked = null;
            this.BuildRightClickMenu(pt);
        }
예제 #45
0
파일: TVDoc.cs 프로젝트: mudboy/tvrename
 public List<System.IO.FileInfo> FindEpOnDisk(ProcessedEpisode pe)
 {
     return this.FindEpOnDisk(pe.SI, pe);
 }
예제 #46
0
파일: UI.cs 프로젝트: madams74/tvrename
        public void UpdateWTW(ProcessedEpisode pe, ListViewItem lvi)
        {
            lvi.Tag = pe;

            // group 0 = just missed
            //       1 = this week
            //       2 = future / unknown

            DateTime? airdt = pe.GetAirDateDT(true);
            if (airdt == null)
            {
                // TODO: something!
                return;
            }
            DateTime dt = (DateTime)airdt;

            double ttn = (dt.Subtract(DateTime.Now)).TotalHours;

            if (ttn < 0)
                lvi.Group = this.lvWhenToWatch.Groups[0];
            else if (ttn < (7 * 24))
                lvi.Group = this.lvWhenToWatch.Groups[1];
            else if (!pe.NextToAir)
                lvi.Group = this.lvWhenToWatch.Groups[3];
            else
                lvi.Group = this.lvWhenToWatch.Groups[2];

            int n = 1;
            lvi.Text = pe.SI.ShowName;
            lvi.SubItems[n++].Text = (pe.SeasonNumber != 0) ? pe.SeasonNumber.ToString() : "Special";
            string estr = (pe.EpNum > 0) ? pe.EpNum.ToString() : "";
            if ((pe.EpNum > 0) && (pe.EpNum2 != pe.EpNum) && (pe.EpNum2 > 0))
                estr += "-" + pe.EpNum2;
            lvi.SubItems[n++].Text = estr;
            lvi.SubItems[n++].Text = dt.ToShortDateString();
            lvi.SubItems[n++].Text = dt.ToString("t");
            lvi.SubItems[n++].Text = dt.ToString("ddd");
            lvi.SubItems[n++].Text = pe.HowLong();
            lvi.SubItems[n++].Text = pe.Name;

            // icon..

            if (airdt.Value.CompareTo(DateTime.Now) < 0) // has aired
            {
                System.Collections.Generic.List<System.IO.FileInfo> fl = this.mDoc.FindEpOnDisk(pe);
                if ((fl != null) && (fl.Count > 0))
                    lvi.ImageIndex = 0;
                else if (pe.SI.DoMissingCheck)
                    lvi.ImageIndex = 1;
            }
        }
예제 #47
0
파일: TVDoc.cs 프로젝트: mudboy/tvrename
        private void ThumbnailAndNFOCheck(ProcessedEpisode dbep, FileInfo filo, ItemList addTo)
        {
            if (this.Settings.EpImgs)
            {
                string ban = dbep.GetItem("filename");
                if (!string.IsNullOrEmpty(ban))
                {
                    string fn = filo.Name;
                    fn = fn.Substring(0, fn.Length - filo.Extension.Length);
                    fn += ".tbn";
                    FileInfo img = Helpers.FileInFolder(filo.Directory, fn);
                    if (!img.Exists)
                        addTo.Add(new ActionDownload(dbep.SI, dbep, img, ban));
                }
            }
            if (this.Settings.NFOs)
            {
                string fn = filo.Name;
                fn = fn.Substring(0, fn.Length - filo.Extension.Length);
                fn += ".nfo";
                FileInfo nfo = Helpers.FileInFolder(filo.Directory, fn);

                if (!nfo.Exists || (dbep.Srv_LastUpdated > TimeZone.Epoch(nfo.LastWriteTime)))
                    addTo.Add(new ActionNFO(nfo, dbep));
            }
            if (this.Settings.pyTivoMeta)
            {
                string fn = filo.Name;
                fn += ".txt";
                string folder = filo.DirectoryName;
                if (this.Settings.pyTivoMetaSubFolder)
                    folder += "\\.meta";
                FileInfo meta = Helpers.FileInFolder(folder, fn);

                if (!meta.Exists || (dbep.Srv_LastUpdated > TimeZone.Epoch(meta.LastWriteTime)))
                    addTo.Add(new ActionPyTivoMeta(meta, dbep));
            }
        }
예제 #48
0
파일: UI.cs 프로젝트: madams74/tvrename
        public UI(TVDoc doc)
        {
            this.mDoc = doc;

            this.Busy = 0;
            this.mLastEpClicked = null;
            this.mLastFolderClicked = null;
            this.mLastSeasonClicked = null;
            this.mLastShowsClicked = null;
            this.mLastActionsClicked = null;

            this.mInternalChange = 0;
            this.mFoldersToOpen = new List<String>();

            this.InternalCheckChange = false;

            this.InitializeComponent();

            this.SetupIPC();

            try
            {
                this.LoadLayoutXML();
            }
            catch
            {
                // silently fail, doesn't matter too much
            }

            this.SetProgress += this.SetProgressActual;

            this.lvWhenToWatch.ListViewItemSorter = new DateSorterWTW();

            if (this.mDoc.Args.Hide)
            {
                this.WindowState = FormWindowState.Minimized;
                this.Visible = false;
                this.Hide();
            }

            this.Text = this.Text + " " + Version.DisplayVersionString();

            this.FillMyShows();
            this.UpdateSearchButton();
            this.SetGuideHTMLbody("");
            this.mDoc.DoWhenToWatch(true);
            this.FillWhenToWatchList();
            this.mDoc.WriteUpcomingRSSandXML();
            this.ShowHideNotificationIcon();

            int t = this.mDoc.Settings.StartupTab;
            if (t < this.tabControl1.TabCount)
                this.tabControl1.SelectedIndex = this.mDoc.Settings.StartupTab;
            this.tabControl1_SelectedIndexChanged(null, null);

            this.mAutoFolderMonitor = new TVRename.AutoFolderMonitor(mDoc,this);
            if (this.mDoc.Settings.MonitorFolders)
                this.mAutoFolderMonitor.StartMonitor();


        }
예제 #49
0
 public ActionPyTivoMeta(FileInfo nfo, ProcessedEpisode pe)
 {
     this.Episode = pe;
     this.Where = nfo;
 }
예제 #50
0
        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.
            }

            // 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; // 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
        }
예제 #51
0
        private void CheckSeasonFolder(ShowItem si, DirFilesCache dfc, TVDoc.ScanSettings settings, int snum,
                                       bool timeForBannerUpdate, string folder)
        {
            if (settings.Token.IsCancellationRequested)
            {
                return;
            }

            if (TVSettings.Instance.NeedToDownloadBannerFile() && timeForBannerUpdate)
            {
                //Image series checks here
                Doc.TheActionList.Add(
                    downloadIdentifiers.ForceUpdateSeason(DownloadIdentifier.DownloadType.downloadImage, si,
                                                          folder, snum));
            }

            //Image series checks here
            Doc.TheActionList.Add(downloadIdentifiers.ProcessSeason(si, folder, snum));

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

            bool renCheck =
                TVSettings.Instance.RenameCheck && si.DoRename &&
                Directory.Exists(folder); // renaming check needs the folder to exist

            bool missCheck = TVSettings.Instance.MissingCheck && si.DoMissingCheck;

            if (!renCheck && !missCheck)
            {
                return;
            }

            Dictionary <int, FileInfo> localEps = new Dictionary <int, FileInfo>();
            int maxEpNumFound = 0;

            if (!si.SeasonEpisodes.ContainsKey(snum))
            {
                return;
            }

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

            foreach (FileInfo fi in files)
            {
                if (settings.Token.IsCancellationRequested)
                {
                    return;
                }

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

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

                ProcessedEpisode ep = eps.Find(x => x.AppropriateEpNum == epNum && x.AppropriateSeasonNumber == seasNum);

                if (ep is null)
                {
                    continue; // season+episode number don't correspond to any episode we know of from thetvdb
                }

                FileInfo actualFile = fi;

                // == RENAMING CHECK ==
                if (renCheck && TVSettings.Instance.FileHasUsefulExtension(fi, true))
                {
                    // Note that the extension of the file may not be fi.extension as users can put ".mkv.t" for example as an extension
                    string otherExtension = TVSettings.Instance.FileHasUsefulExtensionDetails(fi, true);

                    string newName = TVSettings.Instance.FilenameFriendly(
                        TVSettings.Instance.NamingStyle.NameFor(ep, otherExtension, folder.Length));

                    FileInfo fileWorthAdding = CheckFile(folder, fi, actualFile, newName, ep, files);

                    if (fileWorthAdding != null)
                    {
                        localEps[epNum] = fileWorthAdding;
                    }
                }

                // == MISSING CHECK part 1/2 ==
                if (missCheck && fi.IsMovieFile())
                {
                    // first pass of missing check is to tally up the episodes we do have
                    if (!localEps.ContainsKey(epNum))
                    {
                        localEps[epNum] = actualFile;
                    }

                    if (epNum > maxEpNumFound)
                    {
                        maxEpNumFound = epNum;
                    }
                }
            } // foreach file in folder

            // == MISSING CHECK part 2/2 (includes NFO and Thumbnails) ==
            // look at the official list of episodes, and look to see if we have any gaps

            DateTime today = DateTime.Now;

            foreach (ProcessedEpisode dbep in eps)
            {
                if (!localEps.ContainsKey(dbep.AppropriateEpNum)) // not here locally
                {
                    // second part of missing check is to see what is missing!
                    if (missCheck)
                    {
                        DateTime?dt   = dbep.GetAirDateDt(true);
                        bool     dtOk = dt != null;

                        bool notFuture =
                            dtOk && dt.Value.CompareTo(today) < 0; // isn't an episode yet to be aired

                        // only add to the missing list if, either:
                        // - force check is on
                        // - there are no aired dates at all, for up to and including this season
                        // - there is an aired date, and it isn't in the future
                        bool noAirdatesUntilNow    = si.NoAirdatesUntilNow(snum);
                        bool siForceCheckFuture    = (si.ForceCheckFuture || notFuture) && dtOk;
                        bool siForceCheckNoAirdate = si.ForceCheckNoAirdate && !dtOk;

                        if (noAirdatesUntilNow || siForceCheckFuture || siForceCheckNoAirdate)
                        {
                            // then add it as officially missing
                            Doc.TheActionList.Add(new ItemMissing(dbep, folder));
                        }
                    }// if doing missing check
                }
                else
                {
                    if (settings.Type == TVSettings.ScanType.Full)
                    {
                        Doc.CurrentStats.NsNumberOfEpisodes++;
                    }

                    // do NFO and thumbnail checks if required
                    FileInfo
                        filo = localEps[dbep.AppropriateEpNum]; // filename (or future filename) of the file

                    Doc.TheActionList.Add(downloadIdentifiers.ProcessEpisode(dbep, filo));
                }
            } // up to date check, for each episode in thetvdb
        }
예제 #52
0
 public ActionRSS(RSSItem rss, string toWhereNoExt, ProcessedEpisode pe)
 {
     this.Episode      = pe;
     this.RSS          = rss;
     this.TheFileNoExt = toWhereNoExt;
 }
예제 #53
0
파일: UI.cs 프로젝트: madams74/tvrename
 public void RightClickOnMyShows(Season seas, Point pt)
 {
     this.mLastShowsClicked =  new List<ShowItem>() { this.mDoc.GetShowItem(seas.TheSeries.TVDBCode) };
     this.mLastEpClicked = null;
     this.mLastSeasonClicked = seas;
     this.mLastActionsClicked = null;
     this.BuildRightClickMenu(pt);
 }
예제 #54
0
 public ActionWdtvMeta(FileInfo where, ProcessedEpisode pe) : base(where, pe.Show)
 {
     Episode = pe;
 }
예제 #55
0
파일: UI.cs 프로젝트: madams74/tvrename
        public void showRightClickMenu_ItemClicked(object sender, System.Windows.Forms.ToolStripItemClickedEventArgs e)
        {
            this.showRightClickMenu.Close();
            RightClickCommands n = (RightClickCommands) e.ClickedItem.Tag;

            ShowItem si = (this.mLastShowsClicked != null) && (this.mLastShowsClicked.Count > 0)
                              ? this.mLastShowsClicked[0]
                              : null;

            switch (n)
            {
                case RightClickCommands.kEpisodeGuideForShow: // epguide
                    if (this.mLastEpClicked != null)
                        this.GotoEpguideFor(this.mLastEpClicked, true);
                    else
                    {
                        if (si != null)
                            this.GotoEpguideFor(si, true);
                    }
                    break;

                case RightClickCommands.kVisitTVDBEpisode: // thetvdb.com
                    {
                        this.TVDBFor(this.mLastEpClicked);
                        break;
                    }

                case RightClickCommands.kVisitTVDBSeason:
                    {
                        this.TVDBFor(this.mLastSeasonClicked);
                        break;
                    }

                case RightClickCommands.kVisitTVDBSeries:
                    {
                        if (si != null)
                            this.TVDBFor(si);
                        break;
                    }
                case RightClickCommands.kScanSpecificSeries:
                    {
                        if (mLastShowsClicked != null)
                        {
                            this.Scan(mLastShowsClicked);
                            this.tabControl1.SelectTab(this.tbAllInOne);
                        }
                        break;
                    }

                case RightClickCommands.kWhenToWatchSeries: // when to watch
                    {
                        int code = -1;
                        if (this.mLastEpClicked != null)
                            code = this.mLastEpClicked.TheSeries.TVDBCode;
                        if (si != null)
                            code = si.TVDBCode;

                        if (code != -1)
                        {
                            this.tabControl1.SelectTab(this.tbWTW);

                            for (int i = 0; i < this.lvWhenToWatch.Items.Count; i++)
                                this.lvWhenToWatch.Items[i].Selected = false;

                            for (int i = 0; i < this.lvWhenToWatch.Items.Count; i++)
                            {
                                ListViewItem lvi = this.lvWhenToWatch.Items[i];
                                ProcessedEpisode ei = (ProcessedEpisode) (lvi.Tag);
                                if ((ei != null) && (ei.TheSeries.TVDBCode == code))
                                    lvi.Selected = true;
                            }
                            this.lvWhenToWatch.Focus();
                        }
                        break;
                    }
                case RightClickCommands.kForceRefreshSeries:
                    if (si != null)
                        this.ForceRefresh(mLastShowsClicked);
                    break;
                case RightClickCommands.kEditShow:
                    if (si != null)
                        this.EditShow(si);
                    break;
                case RightClickCommands.kDeleteShow:
                    if (si != null)
                        this.DeleteShow(si);
                    break;
                case RightClickCommands.kEditSeason:
                    if (si != null)
                        this.EditSeason(si, this.mLastSeasonClicked.SeasonNumber);
                    break;
                case RightClickCommands.kBTSearchFor:
                    {
                        foreach (ListViewItem lvi in this.lvAction.SelectedItems)
                        {
                            ItemMissing m = (ItemMissing) (lvi.Tag);
                            if (m != null)
                                this.mDoc.DoBTSearch(m.Episode);
                        }
                    }
                    break;
                case RightClickCommands.kActionAction:
                    this.ActionAction(false);
                    break;
                case RightClickCommands.kActionBrowseForFile:
                    {
                        if ((this.mLastActionsClicked != null) && (this.mLastActionsClicked.Count > 0))
                        {
                            ItemMissing mi = (ItemMissing) this.mLastActionsClicked[0];
                            if (mi != null)
                            {
                                // browse for mLastActionClicked
                                this.openFile.Filter = "Video Files|" +
                                                       this.mDoc.Settings.GetVideoExtensionsString().Replace(".", "*.") +
                                                       "|All Files (*.*)|*.*";

                                if (this.openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                {
                                    // make new Item for copying/moving to specified location
                                    FileInfo from = new FileInfo(this.openFile.FileName);
                                    this.mDoc.TheActionList.Add(
                                        new ActionCopyMoveRename(
                                            this.mDoc.Settings.LeaveOriginals
                                                ? ActionCopyMoveRename.Op.Copy
                                                : ActionCopyMoveRename.Op.Move, from,
                                            new FileInfo(mi.TheFileNoExt + from.Extension), mi.Episode));
                                    // and remove old Missing item
                                    this.mDoc.TheActionList.Remove(mi);
                                }
                            }
                            this.mLastActionsClicked = null;
                            this.FillActionList();
                        }

                        break;
                    }
                case RightClickCommands.kActionIgnore:
                    this.IgnoreSelected();
                    break;
                case RightClickCommands.kActionIgnoreSeason:
                    {
                        // add season to ignore list for each show selected
                        if ((this.mLastActionsClicked != null) && (this.mLastActionsClicked.Count > 0))
                        {
                            foreach (Item ai in this.mLastActionsClicked)
                            {
                                ScanListItem er = ai as ScanListItem;
                                if ((er == null) || (er.Episode == null))
                                    continue;

                                int snum = er.Episode.SeasonNumber;

                                if (!er.Episode.SI.IgnoreSeasons.Contains(snum))
                                    er.Episode.SI.IgnoreSeasons.Add(snum);

                                // remove all other episodes of this season from the Action list
                                ItemList remove = new ItemList();
                                foreach (Item action in this.mDoc.TheActionList)
                                {
                                    ScanListItem er2 = action as ScanListItem;

                                    if ((er2 != null) && (er2.Episode != null) && (er2.Episode.SeasonNumber == snum))
                                        remove.Add(action);
                                }

                                foreach (Item action in remove)
                                    this.mDoc.TheActionList.Remove(action);

                                if (remove.Count > 0)
                                    this.mDoc.SetDirty();
                            }
                            this.FillMyShows();
                        }
                        this.mLastActionsClicked = null;
                        this.FillActionList();
                        break;
                    }
                case RightClickCommands.kActionDelete:
                    this.ActionDeleteSelected();
                    break;
                default:
                    {
                        if ((n >= RightClickCommands.kWatchBase) && (n < RightClickCommands.kOpenFolderBase))
                        {
                            int wn = n - RightClickCommands.kWatchBase;
                            if ((this.mLastFL != null) && (wn >= 0) && (wn < this.mLastFL.Count))
                                TVDoc.SysOpen(this.mLastFL[wn].FullName);
                        }
                        else if (n >= RightClickCommands.kOpenFolderBase)
                        {
                            int fnum = n - RightClickCommands.kOpenFolderBase;

                            if (fnum < this.mFoldersToOpen.Count)
                            {
                                string folder = this.mFoldersToOpen[fnum];

                                if (Directory.Exists(folder))
                                    TVDoc.SysOpen(folder);
                            }
                            return;
                        }
                        else
                            System.Diagnostics.Debug.Fail("Unknown right-click action " + n);
                        break;
                    }
            }

            this.mLastEpClicked = null;
        }
예제 #56
0
 public static List <FileInfo> FindEpOnDisk(this DirFilesCache?dfc, ProcessedEpisode pe,
                                            bool checkDirectoryExist = true)
 {
     return(FindEpOnDisk(dfc, pe.Show, pe, checkDirectoryExist));
 }
예제 #57
0
파일: UI.cs 프로젝트: madams74/tvrename
        private void lvAction_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            UpdateSearchButton();

            LVResults lvr = new LVResults(this.lvAction, false);

            if (lvr.Count == 0)
            {
                // disable everything
                this.bnActionBTSearch.Enabled = false;
                return;
            }

            this.bnActionBTSearch.Enabled = lvr.Download.Count <= 0;

            this.mLastShowsClicked = null;
            this.mLastEpClicked = null;
            this.mLastSeasonClicked = null;
            this.mLastActionsClicked = null;

            this.showRightClickMenu.Items.Clear();
            this.mFoldersToOpen = new List<String>();
            this.mLastFL = new System.Collections.Generic.List<System.IO.FileInfo>();

            this.mLastActionsClicked = new ItemList();

            foreach (Item ai in lvr.FlatList)
                this.mLastActionsClicked.Add(ai);

            if ((lvr.Count == 1) && (this.lvAction.FocusedItem != null) && (this.lvAction.FocusedItem.Tag != null))
            {
                ScanListItem action = this.lvAction.FocusedItem.Tag as ScanListItem;
                if (action != null)
                {
                    this.mLastEpClicked = action.Episode;
                    if (action.Episode != null)
                    {
                        this.mLastSeasonClicked = action.Episode.TheSeason;
                        this.mLastShowsClicked = new List<ShowItem>() { action.Episode.SI };
                    }
                    else
                    {
                        this.mLastSeasonClicked = null;
                        this.mLastShowsClicked = null;
                    }

                    if ((this.mLastEpClicked != null) && (this.mDoc.Settings.AutoSelectShowInMyShows))
                        this.GotoEpguideFor(this.mLastEpClicked, false);
                }
            }
        }
예제 #58
0
        private static List <FileInfo> FindEpOnDisk(DirFilesCache?dfc, ShowConfiguration si, ProcessedEpisode epi,
                                                    bool checkDirectoryExist = true)
        {
            DirFilesCache cache = dfc ?? new DirFilesCache();

            List <FileInfo> ret = new List <FileInfo>();

            int seasWanted = epi.AppropriateSeasonNumber;
            int epWanted   = epi.AppropriateEpNum;

            int snum = seasWanted;

            Dictionary <int, SafeList <string> > dirs = si.AllFolderLocationsEpCheck(checkDirectoryExist);

            if (!dirs.ContainsKey(snum))
            {
                return(ret);
            }

            foreach (string folder in dirs[snum])
            {
                FileInfo[] files = cache.GetFiles(folder);

                foreach (FileInfo fiTemp in files.Where(fiTemp => fiTemp.IsMovieFile()))
                {
                    if (!FindSeasEp(fiTemp, out int seasFound, out int epFound, out int _, si))
                    {
                        continue;
                    }

                    if (seasFound == -1)
                    {
                        seasFound = seasWanted;
                    }

                    if (seasFound == seasWanted && epFound == epWanted)
                    {
                        ret.Add(fiTemp);
                    }
                }
            }

            return(ret);
        }
예제 #59
0
파일: UI.cs 프로젝트: madams74/tvrename
        public void TVDBFor(ProcessedEpisode e)
        {
            if (e == null)
                return;

            TVDoc.SysOpen(this.mDoc.GetTVDB(false, "").WebsiteURL(e.SI.TVDBCode, e.SeasonID, false));
        }
예제 #60
0
 public ItemSABnzbd(SAB.queueSlotsSlot qss, ProcessedEpisode pe, string desiredLocationNoExt)
 {
     this.Episode = pe;
     this.DesiredLocationNoExt = desiredLocationNoExt;
     this.Entry = qss;
 }