mirror of
https://onedev.site.tesses.net/tytd2025
synced 2026-06-01 18:05:32 +00:00
Fix downloader bug, use plink and add icon to plugin template
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user