// Adapted from Monopod private void LoadPodcastFeedFromXml() { title = StringUtils.StripHTML(FeedUtil.GetXmlNodeText(xml_doc, "/rss/channel/title")).Trim(); if (title == "") { throw new ApplicationException(Catalog.GetString("Feed has no title")); } feed_link = FeedUtil.GetXmlNodeText(xml_doc, "/rss/channel/link").Trim(); image_url = FeedUtil.GetXmlNodeText(xml_doc, "/rss/channel/image/url").Trim(); description = StringUtils.StripHTML(FeedUtil.GetXmlNodeText(xml_doc, "/rss/channel/description").Trim()); }
private void DoUpdate() { PodcastFeedParser feed_parser; try { XmlDocument doc; doc = FeedUtil.FetchXmlDocument(feed_url.ToString().Trim(), lastUpdate); if (doc == null) { return; } feed_parser = PodcastFeedParser.Create(doc, this); feed_parser.Parse(); } catch (FeedNotModifiedException) { SyncPodcasts(); return; } catch { return; } Title = feed_parser.Title; link = feed_parser.Link; image = feed_parser.Image; description = feed_parser.Description; Commit(); PodcastInfo[] remote_podcasts = feed_parser.Podcasts; if (remote_podcasts != null) { UpdatePodcasts(remote_podcasts); } SyncPodcasts(); lastUpdate = DateTime.Now; Commit(); }
// Adapted from Monopod private void LoadPodcastsFromXml() { string enc_url; string mime_type; string pubDate; Hashtable tmp_podcast_hash = new Hashtable(); PodcastInfo tmpPi; XmlNodeList items = xml_doc.SelectNodes("//item"); foreach (XmlNode item in items) { try { enc_url = FeedUtil.GetXmlNodeText(item, "enclosure/@url").Trim(); if (enc_url == String.Empty) { continue; } mime_type = FeedUtil.GetXmlNodeText(item, "enclosure/@type").Trim(); if (!FeedUtil.KnownType(mime_type)) { continue; } tmpPi = new PodcastInfo(feed, enc_url); tmpPi.MimeType = mime_type; try { tmpPi.Length = Convert.ToInt64( FeedUtil.GetXmlNodeText(item, "enclosure/@length").Trim() ); } catch { tmpPi.Length = 0; } tmpPi.Title = StringUtils.StripHTML(FeedUtil.GetXmlNodeText(item, "title").Trim()); tmpPi.Author = StringUtils.StripHTML(FeedUtil.GetXmlNodeText(item, "author").Trim()); tmpPi.Link = FeedUtil.GetXmlNodeText(item, "link").Trim(); tmpPi.Description = StringUtils.StripHTML(FeedUtil.GetXmlNodeText(item, "description").Trim()); pubDate = FeedUtil.GetXmlNodeText(item, "pubDate").Trim(); try { tmpPi.PubDate = RFC822DateTime.Parse(pubDate); } catch { tmpPi.PubDate = DateTime.MinValue; } // Some feeds actually release multiple episodes w\ the same file name. Gah! if (tmp_podcast_hash.Contains(enc_url)) { continue; } tmp_podcast_hash.Add(enc_url, tmpPi); } catch { continue; } } if (tmp_podcast_hash.Values.Count > 0) { PodcastInfo[] tmp_podcasts = new PodcastInfo [tmp_podcast_hash.Values.Count]; tmp_podcast_hash.Values.CopyTo(tmp_podcasts, 0); Array.Sort(tmp_podcasts); podcasts = tmp_podcasts; } }