Ejemplo n.º 1
0
 public Task <List <RssItem> > GetRssItemsAsync(Feed feed, int?limit = null)
 {
     try
     {
         var root        = _rssReader.Open(feed.Url);
         var channelNode = _rssParser.ParseChannel(root);
         return(Task.FromResult(_rssParser.ParseItems(channelNode, feed: feed, limit: limit)));
     }
     catch (WebException ex)
     {
         return(Task.FromResult(new List <RssItem>()));
     }
 }
Ejemplo n.º 2
0
        public async Task AddAsync(Feed feed)
        {
            _logger.LogDebug("Adding feed...");
            var nodeRoot    = _rssReader.Open(feed.Url);
            var nodeChannel = _rssParser.ParseChannel(nodeRoot);
            var rssFeed     = _rssParser.ParseFeed(nodeChannel);

            if (rssFeed != null)
            {
                feed.Description = rssFeed.Description;
                feed.ImageUrl    = rssFeed.Url;
            }
            await _repository.AddAsync(feed);

            await _repository.SaveAsync();
        }