Exemplo n.º 1
0
        public override void Run(ItemList TheActionList)
        {
            if (TVSettings.Instance.ExportMissingXML)
            {
                XmlWriterSettings settings = new XmlWriterSettings();
                //XmlWriterSettings settings = gcnew XmlWriterSettings();
                settings.Indent = true;
                settings.NewLineOnAttributes = true;
                using (XmlWriter writer = XmlWriter.Create(Location(), settings))
                {
                    writer.WriteStartDocument();

                    writer.WriteStartElement("TVRename");
                    XMLHelper.WriteAttributeToXML(writer, "Version", "2.1");
                    writer.WriteStartElement("MissingItems");

                    foreach (Item Action in TheActionList)
                    {
                        if (Action is ItemMissing)
                        {
                            ItemMissing Missing = (ItemMissing)(Action);
                            writer.WriteStartElement("MissingItem");

                            XMLHelper.WriteElementToXML(writer, "id", Missing.Episode.SI.TVDBCode);
                            XMLHelper.WriteElementToXML(writer, "title", Missing.Episode.TheSeries.Name);
                            XMLHelper.WriteElementToXML(writer, "season", Helpers.pad(Missing.Episode.SeasonNumber));
                            XMLHelper.WriteElementToXML(writer, "episode", Helpers.pad(Missing.Episode.EpNum));
                            XMLHelper.WriteElementToXML(writer, "episodeName", Missing.Episode.Name);
                            XMLHelper.WriteElementToXML(writer, "description", Missing.Episode.Overview);

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

                            writer.WriteEndElement(); // MissingItem
                        }
                    }
                    writer.WriteEndElement(); // MissingItems
                    writer.WriteEndElement(); // tvrename
                    writer.WriteEndDocument();
                    writer.Close();
                }
            }
        }
Exemplo n.º 2
0
        public override void Run()
        {
            if (!Active())
            {
                return;
            }

            try
            {
                XmlWriterSettings settings = new XmlWriterSettings
                {
                    Indent = true,
                    NewLineOnAttributes = true,
                    Encoding            = Encoding.ASCII
                };


                using (XmlWriter writer = XmlWriter.Create(Location(), settings))
                {
                    writer.WriteStartDocument();

                    writer.WriteStartElement("TVRename");
                    XMLHelper.WriteAttributeToXML(writer, "Version", "2.1");
                    writer.WriteStartElement("MissingItems");

                    foreach (Item action in this.TheActionList)
                    {
                        if (!(action is ItemMissing))
                        {
                            continue;
                        }

                        ItemMissing missing = (ItemMissing)(action);
                        writer.WriteStartElement("MissingItem");

                        XMLHelper.WriteElementToXML(writer, "id", missing.Episode.SI.TVDBCode);
                        XMLHelper.WriteElementToXML(writer, "title", missing.Episode.TheSeries.Name);
                        XMLHelper.WriteElementToXML(writer, "season", Helpers.pad(missing.Episode.AppropriateSeasonNumber));
                        XMLHelper.WriteElementToXML(writer, "episode", Helpers.pad(missing.Episode.AppropriateEpNum));
                        XMLHelper.WriteElementToXML(writer, "episodeName", missing.Episode.Name);
                        XMLHelper.WriteElementToXML(writer, "description", missing.Episode.Overview);

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

                        writer.WriteEndElement(); // MissingItem
                    }
                    writer.WriteEndElement();     // MissingItems
                    writer.WriteEndElement();     // tvrename
                    writer.WriteEndDocument();
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }
Exemplo n.º 3
0
        protected override bool  Generate(System.IO.Stream str, List <ProcessedEpisode> elist)
        {
            DirFilesCache dfc = new DirFilesCache();

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

                    foreach (ProcessedEpisode ei in elist)
                    {
                        string niceName = TVSettings.Instance.NamingStyle.NameForExt(ei, null, 0);

                        writer.WriteStartElement("item");
                        XMLHelper.WriteElementToXML(writer, "id", ei.TheSeries.TVDBCode);
                        XMLHelper.WriteElementToXML(writer, "SeriesName", ei.TheSeries.Name);
                        XMLHelper.WriteElementToXML(writer, "SeasonNumber", Helpers.pad(ei.SeasonNumber));
                        XMLHelper.WriteElementToXML(writer, "EpisodeNumber", Helpers.pad(ei.EpNum));
                        XMLHelper.WriteElementToXML(writer, "EpisodeName", ei.Name);

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

                        if (airdt.Value.CompareTo(DateTime.Now) < 0) // has aired
                        {
                            List <FileInfo> fl = mDoc.FindEpOnDisk(dfc, ei);
                            if ((fl != null) && (fl.Count > 0))
                            {
                                writer.WriteValue("true");
                            }
                            else if (ei.SI.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.GetFilename());

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