Esempio n. 1
0
        private ShowSummaryData.ShowSummarySeasonData getSeasonDetails(ShowItem si, SeriesInfo ser, int snum)
        {
            int           epCount      = 0;
            int           epGotCount   = 0;
            int           epAiredCount = 0;
            DirFilesCache dfc          = new DirFilesCache();

            Season season = null;

            Dictionary <int, Season> seasons = si.DVDOrder ? ser.DVDSeasons : ser.AiredSeasons;

            if ((snum >= 0) && (seasons.ContainsKey(snum)))
            {
                season = seasons[snum];

                List <ProcessedEpisode> eis;

                if (si.SeasonEpisodes.ContainsKey(snum))
                {
                    eis = si.SeasonEpisodes[snum]; // use processed episodes if they are available
                }
                else
                {
                    eis = ShowItem.ProcessedListFromEpisodes(season.Episodes, si);
                }

                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 <Alphaleonis.Win32.Filesystem.FileInfo> fl = TVDoc.FindEpOnDisk(dfc, ei, false);
                    if (fl != null)
                    {
                        if (fl.Count != 0)
                        {
                            epGotCount++;
                        }
                    }
                }
            }
            return(new ShowSummaryData.ShowSummarySeasonData(snum, epCount, epAiredCount, epGotCount, season));
        }
Esempio n. 2
0
        public static string GetSeasonHtmlOverview(this ShowItem si, Season s)
        {
            StringBuilder sb  = new StringBuilder();
            DirFilesCache dfc = new DirFilesCache();
            Color         col = Color.FromName("ButtonFace");

            sb.AppendLine(HTMLHeader(10, col));
            sb.AppendSeason(s, si, col);
            foreach (ProcessedEpisode ep in GetBestEpisodes(si, s))
            {
                List <FileInfo> fl = TVDoc.FindEpOnDisk(dfc, ep);
                sb.AppendEpisode(ep, fl, col);
            }
            sb.AppendLine(HTMLFooter());
            return(sb.ToString());
        }
Esempio n. 3
0
        public override void Run()
        {
            if (Active())
            {
                try
                {
                    //Create the directory if needed
                    Directory.CreateDirectory(Path.GetDirectoryName(Location()) ?? "");

                    List <ProcessedEpisode> lpe = doc.Library.RecentEpisodes(TVSettings.Instance.WTWRecentDays);
                    DirFilesCache           dfc = new DirFilesCache();

                    //Write Contents to file
                    using (StreamWriter file = new StreamWriter(Location()))
                    {
                        file.WriteLine(GenerateHeader());
                        foreach (ProcessedEpisode episode in lpe)
                        {
                            List <FileInfo> files = TVDoc.FindEpOnDisk(dfc, episode, false);

                            if (!files.Any())
                            {
                                continue;
                            }

                            string name   = TVSettings.Instance.NamingStyle.NameFor(episode);
                            int    length = files.First().GetFilmLength();

                            file.WriteLine(GenerateRecord(episode, files.First(), name, length));
                        }
                        file.WriteLine(GenerateFooter());
                    }

                    LOGGER.Info("Output File to: {0}", Location());
                }
                catch (Exception e)
                {
                    LOGGER.Error(e, "Failed to Output File to: {0}", Location());
                }
            }
            else
            {
                LOGGER.Trace("Skipped (Disabled) Output File to: {0}", Location());
            }
        }
Esempio n. 4
0
            public override void OnMouseDown(CellContext sender, MouseEventArgs e)
            {
                if (e.Button != MouseButtons.Right)
                {
                    return;
                }
                this.gridSummary.showRightClickMenu.Items.Clear();

                Season seas = this.season;

                this.gridSummary.mLastFileList  = new List <FileInfo>();
                this.gridSummary.mFoldersToOpen = new List <String>();

                this.gridSummary.mLastShowClicked   = this.show;
                this.gridSummary.mLastSeasonClicked = this.season;

                List <String> added = new List <String>();

                if (this.show != null && seas == null)
                {
                    GenerateMenu(this.gridSummary.showRightClickMenu, "Force Refresh", RightClickCommands.kForceRefreshSeries);
                    GenerateSeparator(this.gridSummary.showRightClickMenu);
                    GenerateMenu(this.gridSummary.showRightClickMenu, "Visit thetvdb.com", RightClickCommands.kVisitTVDBSeries);
                }

                if (this.show != null && seas != null)
                {
                    GenerateMenu(this.gridSummary.showRightClickMenu, "Visit thetvdb.com", RightClickCommands.kVisitTVDBSeason);
                }

                if ((seas != null) && (this.show != null) && (this.show.AllFolderLocations().ContainsKey(seas.SeasonNumber)))
                {
                    int  n     = this.gridSummary.mFoldersToOpen.Count;
                    bool first = true;
                    foreach (string folder in this.show.AllFolderLocations()[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(this.gridSummary.showRightClickMenu);
                                first = false;
                            }

                            GenerateMenu(this.gridSummary.showRightClickMenu, "Open: " + folder, (int)RightClickCommands.kOpenFolderBase + n);
                            this.gridSummary.mFoldersToOpen.Add(folder);
                            n++;
                        }
                    }
                }
                else if (this.show != null)
                {
                    int  n     = this.gridSummary.mFoldersToOpen.Count;
                    bool first = true;

                    foreach (KeyValuePair <int, List <String> > kvp in this.show.AllFolderLocations())
                    {
                        foreach (string folder in kvp.Value)
                        {
                            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(this.gridSummary.showRightClickMenu);
                                    first = false;
                                }

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

                if (seas != null && this.show != null)
                {
                    // for each episode in season, find it on disk
                    bool first = true;
                    foreach (ProcessedEpisode epds in this.show.SeasonEpisodes[seas.SeasonNumber])
                    {
                        List <FileInfo> fl = TVDoc.FindEpOnDisk(new DirFilesCache(), epds, false);
                        if ((fl != null) && (fl.Count > 0))
                        {
                            if (first)
                            {
                                GenerateSeparator(this.gridSummary.showRightClickMenu);
                                first = false;
                            }

                            int n = this.gridSummary.mLastFileList.Count;
                            foreach (FileInfo fi in fl)
                            {
                                GenerateMenu(this.gridSummary.showRightClickMenu, "Watch: " + fi.FullName, (int)RightClickCommands.kWatchBase + n);
                                this.gridSummary.mLastFileList.Add(fi);
                                n++;
                            }
                        }
                    }
                }

                Point pt = new Point(e.X, e.Y);

                this.gridSummary.showRightClickMenu.Show(sender.Grid.PointToScreen(pt));
            }
Esempio n. 5
0
        protected override bool  Generate(System.IO.Stream str, List <ProcessedEpisode> elist)
        {
            DirFilesCache dfc = new DirFilesCache();

            try
            {
                XmlWriterSettings settings = new XmlWriterSettings
                {
                    Indent = true,
                    NewLineOnAttributes = true,
                    Encoding            = System.Text.Encoding.ASCII
                };
                using (XmlWriter writer = XmlWriter.Create(str, settings))
                {
                    writer.WriteStartDocument();
                    writer.WriteStartElement("WhenToWatch");

                    foreach (ProcessedEpisode ei in elist)
                    {
                        writer.WriteStartElement("item");
                        XmlHelper.WriteElementToXml(writer, "id", ei.TheSeries.TvdbCode);
                        XmlHelper.WriteElementToXml(writer, "SeriesName", ei.TheSeries.Name);
                        XmlHelper.WriteElementToXml(writer, "SeasonNumber", Helpers.Pad(ei.AppropriateSeasonNumber));
                        XmlHelper.WriteElementToXml(writer, "EpisodeNumber", Helpers.Pad(ei.AppropriateEpNum));
                        XmlHelper.WriteElementToXml(writer, "EpisodeName", ei.Name);

                        writer.WriteStartElement("available");
                        DateTime?airdt = ei.GetAirDateDT(true);

                        if (airdt.HasValue && airdt.Value.CompareTo(DateTime.Now) < 0) // has aired
                        {
                            List <FileInfo> fl = TVDoc.FindEpOnDisk(dfc, ei);
                            if ((fl != null) && (fl.Count > 0))
                            {
                                writer.WriteValue("true");
                            }
                            else if (ei.Show.DoMissingCheck)
                            {
                                writer.WriteValue("false");
                            }
                        }

                        writer.WriteEndElement();
                        XmlHelper.WriteElementToXml(writer, "Overview", ei.Overview);

                        writer.WriteStartElement("FirstAired");
                        DateTime?dt = ei.GetAirDateDT(true);
                        if (dt != null)
                        {
                            writer.WriteValue(dt.Value.ToString("F"));
                        }
                        writer.WriteEndElement();

                        XmlHelper.WriteElementToXml(writer, "Rating", ei.EpisodeRating);
                        XmlHelper.WriteElementToXml(writer, "filename", ei.Filename);

                        writer.WriteEndElement(); // item
                    }
                    writer.WriteEndElement();
                    writer.WriteEndDocument();
                }
                return(true);
            } // try
            catch (Exception e)
            {
                if ((!Doc.Args.Unattended) && (!Doc.Args.Hide))
                {
                    MessageBox.Show(e.Message);
                }
                LOGGER.Error(e);
                return(false);
            }
        }