public Form1() { InitializeComponent(); _opml = new Opml(); _opml.ReadSubscriptions(@"C:\Users\jls\Google Drive\all-subscriptions.opml"); _titleAndUrls = TitleAndUrlRepository.BuildTitleAndUrls(_opml); LoadControls(); }
public static IEnumerable <TitleAndUrl> BuildTitleAndUrls(Opml opml) { var titleAndUrls = new List <TitleAndUrl>(); foreach (var opmlOutline in opml.Outlines) { var titleAndUrl = new TitleAndUrl(); titleAndUrls.Add(titleAndUrl); titleAndUrl.Podcasts = new List <Podcast>(); if (opmlOutline.Attributes.ContainsKey(TitleAttribute)) { titleAndUrl.Title = opmlOutline.Attributes[TitleAttribute]; } if (!opmlOutline.Attributes.ContainsKey(XmlUrlAttribute)) { continue; } titleAndUrl.Url = new Uri(opmlOutline.Attributes[XmlUrlAttribute]); if (titleAndUrl.Title != null) { continue; } var settings = new SyndicationResourceLoadSettings(); var feed = RssFeed.Create(titleAndUrl.Url, settings); foreach (var item in feed.Channel.Items) { var podcast = new Podcast(); podcast.Title = item.Title; podcast.Url = item.Link; titleAndUrl.Podcasts.Add(podcast); } } return(titleAndUrls); }
public static IEnumerable<TitleAndUrl> BuildTitleAndUrls(Opml opml) { var titleAndUrls = new List<TitleAndUrl>(); foreach (var opmlOutline in opml.Outlines) { var titleAndUrl = new TitleAndUrl(); titleAndUrls.Add(titleAndUrl); titleAndUrl.Podcasts = new List<Podcast>(); if (opmlOutline.Attributes.ContainsKey(TitleAttribute)) { titleAndUrl.Title = opmlOutline.Attributes[TitleAttribute]; } if (!opmlOutline.Attributes.ContainsKey(XmlUrlAttribute)) continue; titleAndUrl.Url = new Uri(opmlOutline.Attributes[XmlUrlAttribute]); if (titleAndUrl.Title != null) continue; var settings = new SyndicationResourceLoadSettings(); var feed = RssFeed.Create(titleAndUrl.Url, settings); foreach (var item in feed.Channel.Items) { var podcast = new Podcast(); podcast.Title = item.Title; podcast.Url = item.Link; titleAndUrl.Podcasts.Add(podcast); } } return titleAndUrls; }