mirror of
https://onedev.site.tesses.net/tytd2025
synced 2026-02-08 09:45:44 +00:00
Fix downloader bug, use plink and add icon to plugin template
This commit is contained in:
@@ -24,7 +24,6 @@ func Components.AddVideo(id)
|
||||
|
||||
<button name="action" value="add"><i>add</i></button>
|
||||
<button name="action" value="download"><i>download</i></button>
|
||||
<button name="action" value="play"><i>play_arrow</i></button>
|
||||
</div>
|
||||
</form>;
|
||||
}
|
||||
@@ -27,7 +27,6 @@ func Components.Add()
|
||||
<button name="action" value="add"><i>add</i></button>
|
||||
<button name="action" value="info"><i>info</i></button>
|
||||
<button name="action" value="download"><i>download</i></button>
|
||||
<button name="action" value="play"><i>play_arrow</i></button>
|
||||
</div>
|
||||
</form>;
|
||||
}
|
||||
@@ -11,7 +11,7 @@ func Components.DiscoverEntry(item)
|
||||
<div class="max">
|
||||
<div class="col">
|
||||
<div class="min">
|
||||
<a target="_blank" href={$"./video?v={Net.Http.UrlEncode(item.id)}"}>{item.title}</a>
|
||||
<a target="_blank" href={$"./watch?v={Net.Http.UrlEncode(item.id)}"}>{item.title}</a>
|
||||
</div>
|
||||
<div class="min">
|
||||
<span>{item.views} • {item.uploaded}</span>
|
||||
|
||||
@@ -8,7 +8,7 @@ func Components.DownloadedVideo(item)
|
||||
<div class="max">
|
||||
<div class="col">
|
||||
<div class="min">
|
||||
<a hx-get={$"./video?v={Net.Http.UrlEncode(item.videoId)}"} hx-target="body" hx-push-url="true" href={$"./video?v={Net.Http.UrlEncode(item.videoId)}"}>{item.title}</a>
|
||||
<a hx-get={$"./watch?v={Net.Http.UrlEncode(item.videoId)}"} hx-target="body" hx-push-url="true" href={$"./watch?v={Net.Http.UrlEncode(item.videoId)}"}>{item.title}</a>
|
||||
</div>
|
||||
<div class="min">
|
||||
<span>{item.viewCountStr} (when downloaded)</span>
|
||||
@@ -34,7 +34,7 @@ func Components.DownloadedPlaylist(item)
|
||||
<div class="max">
|
||||
<div class="col">
|
||||
<div class="min">
|
||||
<a hx-get={$"./playlist?id={Net.Http.UrlEncode(item.playlistId)}"} href={$"./playlist?id={Net.Http.UrlEncode(item.playlistId)}"} hx-target="body" hx-push-url="true">{item.title}</a>
|
||||
<a hx-get={$"./playlist?list={Net.Http.UrlEncode(item.playlistId)}"} href={$"./playlist?list={Net.Http.UrlEncode(item.playlistId)}"} hx-target="body" hx-push-url="true">{item.title}</a>
|
||||
</div>
|
||||
<div class="min">
|
||||
<a hx-get={$"./channel?id={Net.Http.UrlEncode(item.channelId)}"} href={$"./channel?id={Net.Http.UrlEncode(item.channelId)}"} hx-target="body" hx-push-url="true">{item.channelTitle}</a>
|
||||
|
||||
@@ -4,9 +4,9 @@ func Components.Progress(tytd)
|
||||
var vid = tytd.CurrentVideo;
|
||||
|
||||
var html = <div hx-trigger="every 1500ms" hx-indicator="none" hx-get="./progress" hx-swap="outerHTML">
|
||||
<h2>{vid.Title}</h2>
|
||||
<h4>{vid.Channel}</h4>
|
||||
<progress value={tytd.CurrentVideoProgress * 100.0} max="100" min="0"></progress>
|
||||
<h2><a hx-target="body" hx-push-url="true" hx-get={$"./watch?v={Net.Http.UrlEncode(vid.VideoId)}"} href={$"./watch?v={Net.Http.UrlEncode(vid.VideoId)}"}>{vid.Title}</a></h2>
|
||||
<h4><a hx-target="body" hx-push-url="true" hx-get={$"./channel?id={Net.Http.UrlEncode(vid.ChannelId)}"} href={$"./channel?id={Net.Http.UrlEncode(vid.ChannelId)}"}>{vid.Channel}</a></h4>
|
||||
<progress class="wavy light-green-text" value={tytd.CurrentVideoProgress * 100.0} max="100" min="0"></progress>
|
||||
</div>;
|
||||
progress++;
|
||||
return html;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
func Pages.PlaylistInfo(tytd,ctx)
|
||||
{
|
||||
var id = ctx.QueryParams.TryGetFirst("id");
|
||||
var id = ctx.QueryParams.TryGetFirst("list") ?? ctx.QueryParams.TryGetFirst("id");
|
||||
var page = ctx.QueryParams.TryGetFirstInt("page");
|
||||
if(TypeOf(page) != "Long") page = 1;
|
||||
page--;
|
||||
@@ -27,7 +27,7 @@ func Pages.PlaylistInfo(tytd,ctx)
|
||||
</each>
|
||||
<footer class="row center-align">
|
||||
|
||||
<button hx-get={$"./playlist?id={Net.Http.UrlEncode(id)}&page={page}"} hx-target="body" hx-push-url="true" >Prev</button>{page+1}<button hx-get={$"./playlist?id={Net.Http.UrlEncode(id)}&type=videos&page={page+2}"} hx-target="body" hx-push-url="true" >Next</button>
|
||||
<button hx-get={$"./playlist?list={Net.Http.UrlEncode(id)}&page={page}"} hx-target="body" hx-push-url="true" >Prev</button>{page+1}<button hx-get={$"./playlist?list={Net.Http.UrlEncode(id)}&type=videos&page={page+2}"} hx-target="body" hx-push-url="true" >Next</button>
|
||||
|
||||
</footer>
|
||||
</null>;
|
||||
|
||||
@@ -9,10 +9,11 @@ func Pages.VideoInfo(tytd,ctx)
|
||||
{
|
||||
html = <div class="col">
|
||||
<div class="min">
|
||||
<img src={$"./api/v1/video-thumbnail?v={Net.Http.UrlEncode(vi.videoId)}"}>
|
||||
<iframe src={$"./embed?v={Net.Http.UrlEncode(vi.videoId)}"} style="overflow: hidden;" width="640"
|
||||
height="360" scrolling="no"></iframe>
|
||||
</div>
|
||||
<div class="min">
|
||||
<raw(Components.AddVideo($"https://www.youtube.com/watch?v={vi.videoId}"))>
|
||||
<raw(Components.AddVideo($"https://www.youtube.com/watch?v={Net.Http.UrlEncode(vi.videoId)}"))>
|
||||
</div>
|
||||
<div class="min">
|
||||
<raw(Components.AddToPersonalList(tytd,vi.videoId))>
|
||||
|
||||
@@ -167,15 +167,15 @@ class TYTD.Downloader {
|
||||
|
||||
if(vid != null)
|
||||
{
|
||||
return $"./video?v={Net.Http.UrlEncode(vid)}";
|
||||
return $"./watch?v={Net.Http.UrlEncode(vid)}";
|
||||
}
|
||||
else if(pid != null)
|
||||
{
|
||||
return $"./playlist?id={Net.Http.UrlEncode(pid)}";
|
||||
return $"./playlist?list={Net.Http.UrlEncode(pid)}";
|
||||
}
|
||||
else if(cid != null)
|
||||
{
|
||||
return $"./playlist?id={Net.Http.UrlEncode(cid)}";
|
||||
return $"./channel?id={Net.Http.UrlEncode(cid)}";
|
||||
}
|
||||
return "./";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user