From 5106c5dc6b3f95d422ce4d9d94265e50c104f2c2 Mon Sep 17 00:00:00 2001 From: Mike Nolan Date: Sun, 28 Dec 2025 15:23:12 -0600 Subject: [PATCH] Fix downloader bug, use plink and add icon to plugin template --- .../src/components/add-video.tcross | 1 - .../src/components/add.tcross | 1 - .../src/components/discover_entry.tcross | 2 +- .../src/components/downloaded-entry.tcross | 4 ++-- .../src/components/progress.tcross | 6 ++--- .../src/main.tcross | 24 ++++++++++++++++--- .../src/pages/playlist/info.tcross | 4 ++-- .../src/pages/video/info.tcross | 5 ++-- .../src/YouTubeDownloader.tcross | 6 ++--- 9 files changed, 35 insertions(+), 18 deletions(-) diff --git a/Tesses.YouTubeDownloader.Server/src/components/add-video.tcross b/Tesses.YouTubeDownloader.Server/src/components/add-video.tcross index 057dbd7..e027c93 100644 --- a/Tesses.YouTubeDownloader.Server/src/components/add-video.tcross +++ b/Tesses.YouTubeDownloader.Server/src/components/add-video.tcross @@ -24,7 +24,6 @@ func Components.AddVideo(id) - ; } \ No newline at end of file diff --git a/Tesses.YouTubeDownloader.Server/src/components/add.tcross b/Tesses.YouTubeDownloader.Server/src/components/add.tcross index 122f9bb..0eb7ac5 100644 --- a/Tesses.YouTubeDownloader.Server/src/components/add.tcross +++ b/Tesses.YouTubeDownloader.Server/src/components/add.tcross @@ -27,7 +27,6 @@ func Components.Add() - ; } \ No newline at end of file diff --git a/Tesses.YouTubeDownloader.Server/src/components/discover_entry.tcross b/Tesses.YouTubeDownloader.Server/src/components/discover_entry.tcross index 5013e62..59d2893 100644 --- a/Tesses.YouTubeDownloader.Server/src/components/discover_entry.tcross +++ b/Tesses.YouTubeDownloader.Server/src/components/discover_entry.tcross @@ -11,7 +11,7 @@ func Components.DiscoverEntry(item)
{item.views} • {item.uploaded} diff --git a/Tesses.YouTubeDownloader.Server/src/components/downloaded-entry.tcross b/Tesses.YouTubeDownloader.Server/src/components/downloaded-entry.tcross index 4649a7c..45fbf95 100644 --- a/Tesses.YouTubeDownloader.Server/src/components/downloaded-entry.tcross +++ b/Tesses.YouTubeDownloader.Server/src/components/downloaded-entry.tcross @@ -8,7 +8,7 @@ func Components.DownloadedVideo(item)
{item.viewCountStr} (when downloaded) @@ -34,7 +34,7 @@ func Components.DownloadedPlaylist(item)
{item.channelTitle} diff --git a/Tesses.YouTubeDownloader.Server/src/components/progress.tcross b/Tesses.YouTubeDownloader.Server/src/components/progress.tcross index 660eeae..ea20ea9 100644 --- a/Tesses.YouTubeDownloader.Server/src/components/progress.tcross +++ b/Tesses.YouTubeDownloader.Server/src/components/progress.tcross @@ -4,9 +4,9 @@ func Components.Progress(tytd) var vid = tytd.CurrentVideo; var html =
-

{vid.Title}

-

{vid.Channel}

- +

{vid.Title}

+

{vid.Channel}

+
; progress++; return html; diff --git a/Tesses.YouTubeDownloader.Server/src/main.tcross b/Tesses.YouTubeDownloader.Server/src/main.tcross index c7e3b34..9135861 100644 --- a/Tesses.YouTubeDownloader.Server/src/main.tcross +++ b/Tesses.YouTubeDownloader.Server/src/main.tcross @@ -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; diff --git a/Tesses.YouTubeDownloader.Server/src/pages/playlist/info.tcross b/Tesses.YouTubeDownloader.Server/src/pages/playlist/info.tcross index 8aec628..61b8408 100644 --- a/Tesses.YouTubeDownloader.Server/src/pages/playlist/info.tcross +++ b/Tesses.YouTubeDownloader.Server/src/pages/playlist/info.tcross @@ -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)
- {page+1} + {page+1}
; diff --git a/Tesses.YouTubeDownloader.Server/src/pages/video/info.tcross b/Tesses.YouTubeDownloader.Server/src/pages/video/info.tcross index 0fba8eb..0561be0 100644 --- a/Tesses.YouTubeDownloader.Server/src/pages/video/info.tcross +++ b/Tesses.YouTubeDownloader.Server/src/pages/video/info.tcross @@ -9,10 +9,11 @@ func Pages.VideoInfo(tytd,ctx) { html =
- +
- +
diff --git a/Tesses.YouTubeDownloader/src/YouTubeDownloader.tcross b/Tesses.YouTubeDownloader/src/YouTubeDownloader.tcross index 26dd6f6..257b6e0 100644 --- a/Tesses.YouTubeDownloader/src/YouTubeDownloader.tcross +++ b/Tesses.YouTubeDownloader/src/YouTubeDownloader.tcross @@ -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 "./"; }