Ejemplo n.º 1
0
        private static async Task MainAsync()
        {
            IConfiguration config = new ConfigurationBuilder()
                                    .AddJsonFile($"appsettings.json", false)
                                    .Build();

            var feedUrl  = config["feed"];
            var location = config["location"];

            List <Video> videos = new List <Video>();

            var feed = await FeedReader.ReadAsync(feedUrl);

            var rss20feed = (CodeHollow.FeedReader.Feeds.AtomFeed)feed.SpecificFeed;

            foreach (var item in rss20feed.Items)
            {
                videos.Add(VideoMapper.XElementToVideo(item.Element));
            }

            var html = await RazorTemplateEngine.RenderAsync("~/Razor/index.cshtml", new IndexModel
            {
                Videos = videos,
            });

            await System.IO.File.WriteAllTextAsync($"{location}/Index.html", html);
        }