Make it a little faster, queue is in sqlite now, fix db bug and more
Some checks failed
Build and Deploy on Tag / 🔨 Build for everything else (push) Failing after 11s
Build and Deploy on Tag / 🔨 Build for PowerPC (push) Failing after 20s

This commit is contained in:
2026-06-25 15:35:39 -05:00
parent ede1f92981
commit c82957cc61
53 changed files with 661 additions and 888 deletions

View File

@@ -58,6 +58,11 @@ class TYTDApp {
}
public Handle(ctx)
{
if(ctx.Path == "/api/v1/resolutions.json")
{
ctx.SendJson(Resolution.Resolutions);
return true;
}
if(ctx.Path == "/service_worker.js" || fileNames.Contains(ctx.Path))
{
const inm=ctx.RequestHeaders.TryGetFirst("If-None-Match");
@@ -176,6 +181,10 @@ class TYTDApp {
);
return true;
}
if(ctx.Path == "/queue-size")
{
return false;
}
if(ctx.Path == "/sso")
{
const app = ctx.QueryParams.TryGetFirst("app") ?? "";
@@ -570,6 +579,21 @@ class TYTDApp {
ctx.WithMimeType("application/json").SendJson(this.TYTD.GetChannelContents(id,page-1,count));
return true;
}
else if(ctx.Path == "/api/v1/queue.json")
{
if(ctx.Method == "GET")
{
var page = ctx.QueryParams.TryGetFirstInt("page");
var count = ctx.QueryParams.TryGetFirstInt("count");
if(TypeOf(page)!="Long") page = 1;
if(TypeOf(count)!="Long") count = 20;
var result = { entries = TYTD.GetQueueItems(page-1,count)};
ctx.WithMimeType("application/json").SendJson(result);
return true;
}
}
else if(ctx.Path == "/api/v1/downloads.json")
{
var q = ctx.QueryParams.TryGetFirst("q");
@@ -605,7 +629,7 @@ class TYTDApp {
if(!this.TYTD.SendDatabase(ctx))
{
ctx.WithMimeType("text/html").SendText(Components.Shell("Unauthorized","<h1>You are not authorized to download the database</h1>",3,/"api/v1/database.db"));
ctx.WithMimeType("text/html").SendText(Components.Shell("Unauthorized","<h1>You are not authorized to download the database</h1>",4,/"api/v1/database.db"));
}
return true;
}
@@ -773,6 +797,24 @@ class TYTDApp {
return true;
}
}
else if(ctx.Path == "/queue")
{
if(ctx.Method == "DELETE")
{
const id = ctx.QueryParams.TryGetFirstInt("id");
if(TypeIsLong(id))
{
this.TYTD.QueueRemoveItem(id);
}
else
{
this.TYTD.QueueClear();
}
}
ctx.WithMimeType("text/html").SendText(Pages.Queue(this.TYTD,ctx));
return true;
}
else if(ctx.Path == "/downloads")
{
ctx.WithMimeType("text/html").SendText(Pages.Downloads(this.TYTD,ctx));
@@ -793,7 +835,7 @@ class TYTDApp {
{
if(!UserFlags.IsAdmin(this.TYTD.IsLoggedIn(ctx)))
{
ctx.WithMimeType("text/html").SendText(Components.Shell("Unauthorized",<h1>You can{"'"}t modify admin settings as you are not an admin</h1>,3));
ctx.WithMimeType("text/html").SendText(Components.Shell("Unauthorized",<h1>You can{"'"}t modify admin settings as you are not an admin</h1>,4));
return true;
}
const user = ctx.QueryParams.TryGetFirst("user");
@@ -871,7 +913,7 @@ class TYTDApp {
{
if(!UserFlags.IsAdmin(this.TYTD.IsLoggedIn(ctx)))
{
ctx.WithMimeType("text/html").SendText(Components.Shell("Unauthorized",<h1>You can{"'"}t modify admin settings as you are not an admin</h1>,3));
ctx.WithMimeType("text/html").SendText(Components.Shell("Unauthorized",<h1>You can{"'"}t modify admin settings as you are not an admin</h1>,4));
return true;
}
if(ctx.Method == "POST")