55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
using System;
|
|
using OllamaSharp;
|
|
using System.Linq;
|
|
using Microsoft.Extensions.Configuration;
|
|
using SaltMiner.Data;
|
|
using System.Formats.Tar;
|
|
|
|
|
|
namespace SaltMiner
|
|
{
|
|
internal class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
|
|
var configurationBuilder = new ConfigurationBuilder();
|
|
|
|
configurationBuilder.SetBasePath(System.IO.Directory.GetCurrentDirectory());
|
|
configurationBuilder.AddJsonFile(path: "appSettings.json", optional: false, reloadOnChange: true);
|
|
|
|
var config = configurationBuilder.Build();
|
|
|
|
String linkID = "3yyupi";
|
|
|
|
using(var ctx = new RedditContext())
|
|
{
|
|
var link = ctx.Links.Where(l => l.LinkId == linkID).First();
|
|
var comments = ctx.Comments.Where(c => c.LinkId == linkID).ToList();
|
|
Submission sub = new Submission();
|
|
sub.Title = link.Title;
|
|
sub.Author = link.Author;
|
|
sub.Link = link.Url;
|
|
sub.Body = link.SelfText;
|
|
foreach(var comment in comments.Where(c => c.ParentId == null))
|
|
{ //top level
|
|
sub.Replies.Add(PopulateComments(sub, comments, comment));
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static Comments PopulateComments(Submission sub, IEnumerable<Data.Comment> comments, Data.Comment targetComment)
|
|
{
|
|
Comments comment = new Comments();
|
|
comment.Author = targetComment.Author;
|
|
comment.Body = targetComment.Body;
|
|
foreach(var reply in comments.Where(c => c.ParentId == targetComment.CommentId))
|
|
{
|
|
comment.Replies.Add(PopulateComments(sub, comments, reply));
|
|
}
|
|
return comment;
|
|
}
|
|
}
|
|
} |