public async Task AddSource(FeedSource source) { await Console.Error.WriteLineAsync("[Builder] Downloading content"); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(source.Feed.Url); request.UserAgent = UserAgentHelper.UserAgent; WebResponse response = await request.GetResponseAsync(); await Console.Error.WriteLineAsync("[Builder] Generating feed header"); // Write the header await feed.WriteGenerator("Polyfeed", "https://github.com/sbrl/PolyFeed.git", Program.GetProgramVersion()); await feed.WriteId(source.Feed.Url); await feed.Write(new SyndicationLink(new Uri(source.Feed.Url), AtomLinkTypes.Self)); string lastModified = response.Headers.Get("last-modified"); if (string.IsNullOrWhiteSpace(lastModified)) { await feed.WriteUpdated(DateTimeOffset.Now); } else { await feed.WriteUpdated(DateTimeOffset.Parse(lastModified)); } string contentType = response.Headers.Get("content-type"); IParserProvider provider = GetProvider(source.Feed.SourceType); if (provider == null) { throw new ApplicationException($"Error: A provider for the source type {source.Feed.SourceType} wasn't found."); } provider.SetOutputFeed(feed, xml); await provider.ParseWebResponse(source, response); await Console.Error.WriteLineAsync("[Builder] Done!"); }