]> fortfriendship.online Git - gnargle.github.io.git/blobdiff - RSSGen/Program.cs
use opengraph for rssgen
[gnargle.github.io.git] / RSSGen / Program.cs
index 19f6832f2b59a8b5a476f019cba08abda86e8afa..a574f9a89c45e00a43bae23480ddbf81569b2984 100644 (file)
@@ -1,4 +1,5 @@
-using RssFeedGenerator;
+using OpenGraphNet;
+using RssFeedGenerator;
 using System;
 using System.Collections.Generic;
 using System.IO;
@@ -76,9 +77,12 @@ myRSS.channel = new rssChannel
 
 foreach (var file in fileInfos)
 {
+    var htmlString = File.ReadAllText(file.FullName);
+    OpenGraph graph = OpenGraph.ParseHtml(htmlString);
     var item = new rssChannelItem()
     {
-        title = Path.GetFileNameWithoutExtension(file.Name),
+        title = graph.Title,
+        description = graph.Metadata["og:description"].First(),
         pubDate = file.CreationTimeUtc.ToString("r"),
     };
     if (file.FullName.Contains("entries"))
@@ -99,7 +103,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))
 {