// Loads the file data and puts it into the podcast list class public static void GetPodcastList() { if (File.Exists("data\\Podcast.txt")) { XDocument xdoc = XDocument.Load("data\\Podcast.txt"); xdoc.Descendants("Podcast").Select(p => new { Url = p.Element("Url").Value, Episodes = Convert.ToInt32(p.Element("Episodes").Value), Title = p.Element("Title").Value, Category = p.Element("Category").Value, Frequency = Convert.ToInt32(p.Element("Frequency").Value) }).ToList().ForEach(p => { Podcast pod = new Podcast( p.Url, p.Episodes, p.Title, p.Category, p.Frequency ); PodcastList.AddPodcast(pod); TheTimer.SetTimer(p.Url, p.Title, p.Category, p.Frequency); }); } }
// New RSS feed public static void RssFeed(string url, string cat, int freq) { // Reading the feed XmlReader reader = XmlReader.Create(url); SyndicationFeed feed = SyndicationFeed.Load(reader); reader.Close(); // Creating a Podcast object and adding it to PodcastList string podTitle = feed.Title.Text; int nrOfEp = feed.Items.Count(); Podcast podcast = new Podcast(url, nrOfEp, podTitle, cat, freq); PodcastList.AddPodcast(podcast); // Creating the Episodes objects and adding them to PodcastEpList foreach (SyndicationItem item in feed.Items) { string title = item.Title.Text; string description = item.Summary.Text; Episode episode = new Episode(podTitle, title, description); EpisodeList.AddEpisode(episode); } TheTimer.SetTimer(url, podTitle, cat, freq); }