public ActionResult Index(string url) { var uri = new Uri(url); var subFetcher = new SubscriptionFetcher(); var xml = subFetcher.Download(Texts.FromUriHost(uri), uri.PathAndQuery); var opml = new Opml(); opml.LoadFromXML(xml); var subscription = new RssSubscription(opml); var fetcher = new SyndicationFetcher(); var feeds = fetcher.DownloadAll(subscription); return Content("Feeds " + feeds.Count); }
public IQuerySetOne<RiverSubscription> FetchDefaultRivers() { string cacheKey = "DEFAULT_RIVERS"; var cache = HttpContext.Cache[cacheKey] as RiverSubscription; if (cache != null) { return new QuerySetOne<RiverSubscription>(cache); } else { var fetcher = new SubscriptionFetcher(); #if DEBUG var xml = fetcher.Download(Texts.FromUriHost(Request.Url), "api/1/default/RiversSubscription"); #else var xml = fetcher.Download("http://hobihobi.apphb.com", "api/1/default/RiversSubscription"); #endif var opml = new Opml(); var res = opml.LoadFromXML(xml); if (res.IsTrue) { var subscriptionList = new RiverSubscription(opml); HttpContext.Cache.Add(cacheKey, subscriptionList, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 10, 0), CacheItemPriority.Default, null); return new QuerySetOne<RiverSubscription>(subscriptionList); } else { return new QuerySetOne<RiverSubscription>(null); } } }