X-Git-Url: https://fortfriendship.online/gitweb/gnargle.github.io.git/blobdiff_plain/d7a192ed0520e86077032d5b9d814077c542da4c..55454859a4aa3c6b00f17e57534af25db5543d79:/RSSGen/Program.cs?ds=inline diff --git a/RSSGen/Program.cs b/RSSGen/Program.cs index 19f6832..1224192 100644 --- a/RSSGen/Program.cs +++ b/RSSGen/Program.cs @@ -1,4 +1,5 @@ -using RssFeedGenerator; +using OpenGraphNet; +using RssFeedGenerator; using System; using System.Collections.Generic; using System.IO; @@ -76,10 +77,14 @@ myRSS.channel = new rssChannel foreach (var file in fileInfos) { + var htmlString = File.ReadAllText(file.FullName); + OpenGraph graph = OpenGraph.ParseHtml(htmlString); + var publishDate = DateTime.Parse(graph.Metadata["article:published_time"].First()); var item = new rssChannelItem() { - title = Path.GetFileNameWithoutExtension(file.Name), - pubDate = file.CreationTimeUtc.ToString("r"), + title = graph.Title, + description = graph.Metadata["og:description"].First(), + pubDate = publishDate.ToString("r"), }; if (file.FullName.Contains("entries")) { @@ -99,7 +104,16 @@ foreach (var file in fileInfos) var output = Generator.SerializeRSS(myRSS); -var rssPath = Path.Combine(Directory.GetCurrentDirectory(), "../../../../feed.xml"); +var rssPath = String.Empty; + +if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) +{ + rssPath = Path.Combine(Directory.GetCurrentDirectory(), "../feed.xml"); +} +else +{ + rssPath = Path.Combine(Directory.GetCurrentDirectory(), "../../../../feed.xml"); +} if (File.Exists(rssPath)) {