X-Git-Url: https://fortfriendship.online/gitweb/gnargle.github.io.git/blobdiff_plain/d933b194e20ea4b95562a7e9e1f0831f284bb8ba..d8dd50adc5df73d2f66407d7217dc60d3a5ed54f:/RSSGen/Program.cs?ds=inline diff --git a/RSSGen/Program.cs b/RSSGen/Program.cs index dde1a52..a8ebb78 100644 --- a/RSSGen/Program.cs +++ b/RSSGen/Program.cs @@ -120,11 +120,90 @@ if (File.Exists(rssPath)) File.Delete(rssPath); } -Console.WriteLine("RSS generated, outputting to console and file"); -Console.WriteLine(output); +Console.WriteLine("Main RSS generated, outputting to file"); File.WriteAllText(rssPath, output); +Console.WriteLine("Generating hentai subseries feed"); + +folder = FindDirectory("diversions/hentaigames"); + +filePaths = Directory.EnumerateFiles(folder); +fileInfos = new List(); + +if (filePaths.Any()) +{ + foreach (var path in filePaths) + { + if (Path.GetFileNameWithoutExtension(path).Equals("template", StringComparison.InvariantCultureIgnoreCase)) + continue; + if (Path.GetFileNameWithoutExtension(path).Equals("list", StringComparison.InvariantCultureIgnoreCase)) + continue; + var fInfo = new FileInfo(path); + fileInfos.Add(fInfo); + } +} + +fileInfos = fileInfos.OrderByDescending(f => f.CreationTimeUtc).Take(20).ToList(); + +myRSS = new rss(); + +myRSS.version = 2.0m; + +myRSS.channel = new rssChannel +{ + title = "athene.gay - hentai games subseries entries", + description = "entries in the hentai game sub-series for athene.gay", + language = "en-GB", + link = "https://athene.gay/hentaigames/list.html", + item = new List(), + link1 = new link + { + href = "https://athene.gay/hentaigames.xml", + rel = "self", + type = "application/rss+xml", + } +}; + +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 = graph.Title, + description = graph.Metadata["og:description"].First(), + pubDate = publishDate.ToString("r"), + link = "https://athene.gay/diversions/hentaigames/" + Path.GetFileName(file.Name) + }; + item.guid = new rssChannelItemGuid() + { + isPermaLink = true, + Value = item.link + }; + myRSS.channel.item.Add(item); +} + +output = Generator.SerializeRSS(myRSS); + +rssPath = Path.Combine(Directory.GetCurrentDirectory(), "../hentaigames.xml"); + +if (!File.Exists(rssPath)) +{ + rssPath = Path.Combine(Directory.GetCurrentDirectory(), "../../../../hentaigames.xml"); +} + +if (File.Exists(rssPath)) +{ + File.Delete(rssPath); +} + +Console.WriteLine("Hentai Games RSS generated, outputting to file"); + +File.WriteAllText(rssPath, output); + + string FindDirectory(string folderName) { var folder = Path.Combine(Directory.GetCurrentDirectory(), $"../{folderName}");