First commit

This commit is contained in:
2026-03-15 22:15:34 -05:00
commit 0858a8a751
79 changed files with 6010 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
using Tesses.WebServer;
using Scriban;
using System.Web;
using YoutubeExplode.Search;
using System.Collections.Concurrent;
using System.Security.Cryptography;
using Newtonsoft.Json;
namespace Tesses.YouTubeDownloader2025Companion;
public static partial class Pages {
private static ReloadingScript log_page = new ReloadingScript("wwwroot/pages/log.sbnhtml");
public static async Task<string> LogAsync(ServerContext ctx)
{
var cfg = Program.Config ?? new AuthConfig();
int page=1;
if(!ctx.QueryParams.TryGetFirstInt32("page",out page))
page = 1;
List<object> entries=new List<object>();
using(var db = new Database())
{
foreach(var vid in await db.GetLogEntriesAsync((page-1) * 20))
{
var time = vid.DateTime.DateTime;
if(vid.HasStrings)
{
entries.Add(new{
Time = $"{time.ToShortDateString()} {time.ToShortTimeString()}",
vid.Type,
Videotitle = HttpUtility.HtmlEncode(vid.VideoTitle),
Videourl = HttpUtility.HtmlAttributeEncode($"{cfg.TYTDUrl.TrimEnd('/')}/watch?v={HttpUtility.UrlEncode(vid.VideoId)}"),
Channeltitle = HttpUtility.HtmlEncode(vid.ChannelTitle),
Channelurl = HttpUtility.HtmlAttributeEncode($"{cfg.TYTDUrl.TrimEnd('/')}/channel?id={HttpUtility.UrlEncode(vid.ChannelId)}"),
});
}
else {
entries.Add(new {
Time = $"{time.ToShortDateString()} {time.ToShortTimeString()}",
vid.Type
});
}
}
}
return Components.Shell("Logs",log_page.Render(new{
Entries=entries,
Prev = HttpUtility.HtmlAttributeEncode($"/log?page={(page == 1 ? 1 : page - 1)}"),
Current = page,
Next = HttpUtility.HtmlAttributeEncode($"/log?page={page + 1}")
}),Program.DefaultLinks());
}
}