// 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); }
// 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); }); } }
public static void GetPodcastFromRss(string category, int updateFrequency, string url) { using (var reader = XmlReader.Create(url)) { try { var feed = SyndicationFeed.Load(reader); var podcastName = feed.Title.Text; int episodeCount = 0; foreach (SyndicationItem s in feed.Items) { var episodeName = s.Title.Text; var detail = s.Summary.Text; var episode = new Episode(episodeName, podcastName, detail); EpisodeList.Add(episode); episodeCount++; } PodcastList.AddPodcast(new Podcast(podcastName, category, updateFrequency, episodeCount, url)); PodcastUpdate.pUpdate(podcastName, category, updateFrequency, url); } catch (Exception) { System.Windows.Forms.MessageBox.Show("Cannot read RSS"); } } }