Fix downloader bug, use plink and add icon to plugin template

This commit is contained in:
2025-12-28 15:23:12 -06:00
parent d3d04bb971
commit 5106c5dc6b
9 changed files with 35 additions and 18 deletions

View File

@@ -9,7 +9,9 @@ var TYTDResources = [
{path="/favicon.ico",value=embed("favicon.ico")},
{path="/tytd.svg",value=embed("tytd.svg")},
{path="/loading-indicator.svg",value=embed("loading-indicator.svg")},
{path="/theme.css",value=embed("theme.css")}
{path="/theme.css",value=embed("theme.css")},
{path="/video.min.js",value=embed("video.min.js")},
{path="/video-js.css",value=embed("video-js.css")},
];
var times=1;
@@ -41,6 +43,20 @@ class TYTDApp {
ctx.WithMimeType("text/html").SendText(Pages.ApiV1());
return true;
}
else if(ctx.Path == "/embed")
{
var v = ctx.QueryParams.TryGetFirst("v");
if(TypeIsString(v))
{
const video = this.TYTD.GetVideo(id);
if(TypeIsDefined(video))
{
ctx.WithMimeType("text/html").SendText(Pages.VideoEmbed(v, video.title));
return true;
}
}
return false;
}
else if(ctx.Path == "/api/v1/download")
{
var v = ctx.QueryParams.TryGetFirst("v");
@@ -51,14 +67,16 @@ class TYTDApp {
var path = this.TYTD.GetVideoPath(v,res);
if(path != null)
if(path != null && this.TYTD.Storage.FileExists(path))
{
var info = this.TYTD.GetVideo(v);
var filename = $"{info.title}-{info.videoId}-{res}{path.GetExtension()}";
var strm = this.TYTD.Storage.OpenFile(path,"rb");
ctx.WithMimeType(Net.Http.MimeType(path.ToString())).WithContentDisposition(filename,inline).SendStream(strm);
strm.Close();
return true;
}
return false;
}
else if(ctx.Path == "/api/v1/progress.json")
{
@@ -308,7 +326,7 @@ class TYTDApp {
ctx.WithMimeType("text/html").SendText(Pages.Settings(this.TYTD,ctx));
return true;
}
else if(ctx.Path == "/video")
else if(ctx.Path == "/watch" || ctx.Path == "/video")
{
ctx.WithMimeType("text/html").SendText(Pages.VideoInfo(this.TYTD,ctx));
return true;