/// <summary> /// Parses the supplied RSS data. /// </summary> /// <returns>A <see cref="PodcastEpisode"/> instance represented by the RSS data.</returns> public PodcastEpisode Parse() { PodcastEpisode episode = new PodcastEpisode(); episode.Title = GetStringFromChildElement("title", NodeToParse); episode.Link = GetStringFromChildElement("link", NodeToParse); episode.Description = GetStringFromChildElement("description", NodeToParse); GetAuthor(episode); episode.EnclosureUrl = GetStringFromChildElementAttribute("enclosure", "url", NodeToParse); episode.EnclosureSize = GetLongFromChildElementAttribute("enclosure", "length", NodeToParse); episode.EnclosureContentType = GetStringFromChildElementAttribute("enclosure", "type", NodeToParse); episode.Guid = GetStringFromChildElement("guid", NodeToParse); episode.PublishDate = GetDateTimeFromChildElement("pubDate", NodeToParse); episode.Subtitle = GetStringFromChildElement("itunes:subtitle", NodeToParse); episode.ITunesExplicit = GetBooleanFromChildElement("itunes:explicit", NodeToParse); episode.Duration = GetTimeSpanFromChildElement("itunes:duration", NodeToParse); GetImage(episode); SaveParseErrors(episode); if (RemoveParsedContent) { UnparsedContent.Seek(0, System.IO.SeekOrigin.Begin); episode.UnparsedRssData = new StreamReader(UnparsedContent).ReadToEnd(); } return(episode); }
/// <summary> /// Parses the RSS feed. /// </summary> /// <returns>The <see cref="PodcastChannel"/> instance represented by the RSS data.</returns> public PodcastChannel Parse() { XmlNode channelElement = ((XmlNode)NodeToParse).SelectSingleNode("rss/channel"); if (channelElement == null) { ParseErrors.Add("No rss/channel node found"); SaveParseErrors(_channel); return(_channel); } GetTitle(channelElement); GetLink(channelElement); GetRssUrl(channelElement); GetDescription(channelElement); GetLanguage(channelElement); GetCopyright(channelElement); GetLastBuildDate(channelElement); GetPublishDate(channelElement); GetAuthor(channelElement); GetImage(channelElement); GetCategories(channelElement); GetKeywords(channelElement); GetDocuments(channelElement); GetGenerator(channelElement); GetManagingEditor(channelElement); GetSubtitle(channelElement); _channel.ITunesExplicit = GetBooleanFromChildElement("itunes:explicit", channelElement); XmlNode ownerElement = channelElement.SelectSingleNode("itunes:owner", NamespaceManager); if (ownerElement != null) { _channel.OwnerEmail = GetStringFromChildElement("itunes:email", ownerElement); _channel.OwnerName = GetStringFromChildElement("itunes:name", ownerElement); if (RemoveParsedContent && ownerElement.ChildNodes.Count == 0) { channelElement.RemoveChild(ownerElement); SaveUnparsedContent(); } } if (RemoveParsedContent && channelElement.ChildNodes.Count == 0) { channelElement.ParentNode.RemoveChild(channelElement); SaveUnparsedContent(); } XmlNodeList items = channelElement.SelectNodes("item"); foreach (XmlNode item in items) { PodcastEpisodeParser p = new PodcastEpisodeParser(item, NamespaceManager); p.RemoveParsedContent = RemoveParsedContent; PodcastEpisode episode = p.Parse(); if (episode.Image.LocalPath == CachedImage.DefaultImage) { episode.Image = _channel.Image; } _channel.Episodes.Add(episode); if (RemoveParsedContent) { channelElement.RemoveChild(item); SaveUnparsedContent(); } } SaveParseErrors(_channel); if (RemoveParsedContent) { UnparsedContent.Seek(0, SeekOrigin.Begin); _channel.UnparsedRssData = new StreamReader(UnparsedContent).ReadToEnd(); } return(_channel); }