From dc270e67852222c6b72d10183125eedeb7b070f7 Mon Sep 17 00:00:00 2001 From: Mike Nolan Date: Thu, 10 Sep 2026 03:15:05 -0500 Subject: [PATCH] Target crosslang v0.0.10, add /api/v1/progress_ex.json --- README.md | 8 ++-- .../src/components/progress.tcross | 8 ++-- .../src/main.tcross | 12 ++--- .../src/YouTubeDownloader.tcross | 44 +++++++++++++++---- changeme.md | 3 ++ nfpm.yaml | 2 +- 6 files changed, 53 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index bf43c2b..2e12c96 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # TYTD 2025 -My web based YouTube downloader that I created in 2025 writen in [CrossLang](https://crosslang.tesseslanguage.com/), my own language +My web based YouTube downloader that I created in 2025 written in [CrossLang](https://crosslang.tesseslanguage.com/), my own language ![The Image](https://crosslang.tesseslanguage.com/images/tytdscreenshot.jpg) @@ -14,8 +14,8 @@ My web based YouTube downloader that I created in 2025 writen in [CrossLang](htt - Search and browse your downloaded videos, playlists, or channels (the search is very basic though) - User accounts - Videos can be tagged based on your downloader's TYTD tag (to determine which instance downloaded it) -- Plugins from [CPKG](https://cpkg.tesseslangauge.com/) or any CPKG compliant server -- Can download YouTube videos either Low quality (but doesn't) require [ffmpeg](https://ffmpeg.org/), you can also download individual streams (also doesn't need [ffmpeg](https://ffmpeg.org/)), or to MP4 (doesn't work on wii due to libx264 having illegal instruction), MKV (so no transcode), MP3 or FLAC (these do need [ffmpeg](https://ffmpeg.org/) in your PATH however) +- Plugins from [CPKG](https://cpkg.tesseslanguage.com/) or any CPKG compliant server +- Can download YouTube videos either Low quality (but doesn't) require [ffmpeg](https://ffmpeg.org/), MP3, FLAC or AMV (these do need [ffmpeg](https://ffmpeg.org/) in your PATH however) - Runs on the Wii using the [Wii Linux Continuation Project](https://wiibrew.org/wiki/Wii-Linux#Wii_Linux_Continuation_Project) (albeit extremely slowly, despite this that's where I run it) # What this project uses (attribution) @@ -37,7 +37,7 @@ Install [crosslang](https://crosslang.tesseslanguage.com/downloads/index.html) from source: ```bash -git clone https://onedev.site.tesses.net/tytd2025 +git clone https://git.tesses.org/tesses50/tytd2025 cd tytd2025/Tesses.YouTubeDownloader.Server crosslang install-webapp ``` diff --git a/Tesses.YouTubeDownloader.Server/src/components/progress.tcross b/Tesses.YouTubeDownloader.Server/src/components/progress.tcross index c4930a1..d7233ed 100644 --- a/Tesses.YouTubeDownloader.Server/src/components/progress.tcross +++ b/Tesses.YouTubeDownloader.Server/src/components/progress.tcross @@ -1,12 +1,12 @@ func Components.Progress(tytd) { - var vid = tytd.CurrentVideo; + var progress = tytd.GetProgress(); var html =
-

{vid.Title}

-

{vid.Channel}

- +

{progress.CurrentVideo.Title}

+

{progress.CurrentVideo.Channel}

+
; return html; } \ No newline at end of file diff --git a/Tesses.YouTubeDownloader.Server/src/main.tcross b/Tesses.YouTubeDownloader.Server/src/main.tcross index 04c0730..8e940df 100644 --- a/Tesses.YouTubeDownloader.Server/src/main.tcross +++ b/Tesses.YouTubeDownloader.Server/src/main.tcross @@ -540,14 +540,14 @@ class TYTDApp { } return false; } + else if(ctx.Path == "/api/v1/progress_ex.json") + { + ctx.WithMimeType("application/json").SendJson(this.TYTD.GetProgressEx()); + return true; + } else if(ctx.Path == "/api/v1/progress.json") { - var jo = { - CurrentVideoProgress = this.TYTD.CurrentVideoProgress, - CurrentVideo = this.TYTD.CurrentVideo - - }; - ctx.WithMimeType("application/json").SendJson(jo); + ctx.WithMimeType("application/json").SendJson(this.TYTD.GetProgress()); return true; } else if(ctx.Path == "/api/v1/add") diff --git a/Tesses.YouTubeDownloader/src/YouTubeDownloader.tcross b/Tesses.YouTubeDownloader/src/YouTubeDownloader.tcross index d0d0f9f..91f90a6 100644 --- a/Tesses.YouTubeDownloader/src/YouTubeDownloader.tcross +++ b/Tesses.YouTubeDownloader/src/YouTubeDownloader.tcross @@ -525,26 +525,21 @@ class TYTD.Downloader { { case Resolution.LowVideo: return dir / "ytmux.mp4"; - break; case Resolution.VideoOnly: return dir / "vo.bin"; - break; case Resolution.AudioOnly: return dir / "ao.bin"; - break; case Resolution.MP4: return dir / "conv.mp4"; - break; case Resolution.MKV: return dir / "conv.mkv"; - break; case Resolution.MP3: return dir / "conv.mp3"; - break; case Resolution.FLAC: return dir / "conv.flac"; - break; + case Resolution.AMV: + return dir / "conv.amv"; } throw $"Could not get file path for format {res}"; } @@ -849,14 +844,14 @@ class TYTD.Downloader { public BeforeQueued = new TYTD.Event(); - public CurrentVideo = { + private CurrentVideo = { Title = "N/A", Channel = "N/A", VideoId = "", ChannelId = "" }; - public CurrentVideoProgress = 0.0; + private CurrentVideoProgress = 0.0; public VideoEnded = new TYTD.Event(); @@ -874,6 +869,30 @@ class TYTD.Downloader { private DownloaderThreadHandle; + public GetProgress() { + this.Mutex.Lock(); + const progress = {CurrentVideoProgress,CurrentVideo }; + this.Mutex.Unlock(); + return progress; + } + + public GetProgressEx() { + this.Mutex.Lock(); + const db = OpenDB(); + const resultVideos = Sqlite.Exec(db, "SELECT COUNT(*) FROM videos;"); + const resultQueue = Sqlite.Exec(db, "SELECT COUNT(*) FROM queue;"); + Sqlite.Close(db); + + const videoCount = TypeIsList(resultVideos) ? (ParseLong(resultVideos.["COUNT(*)"])??0) : 0; + + const queueCount = TypeIsList(resultQueue) ? (ParseLong(resultQueue.["COUNT(*)"])??0) : 0; + + + const progress = {CurrentVideoProgress,CurrentVideo,QueueCount=queueCount, VideoCount=videoCount}; + this.Mutex.Unlock(); + return progress; + } + /^ Get Video Queue count ^/ @@ -1209,20 +1228,27 @@ class TYTD.Downloader { var res = PopQueue(); //Console.WriteLine(res); + + if(TypeOf(res) != "Null") { if(TypeIsDefined(res.TYTD = this)){ res.Progress = (progress)=>{ + this.Mutex.Lock(); this.CurrentVideoProgress = progress; + this.Mutex.Unlock(); this.VideoProgress.Invoke(this, { Video = res.Video, progress }); }; + this.Mutex.Lock(); + this.CurrentVideo = res.Video; + this.Mutex.Unlock(); this.VideoStarted.Invoke(this,{ Video = res.Video diff --git a/changeme.md b/changeme.md index a17d787..3a12799 100644 --- a/changeme.md +++ b/changeme.md @@ -1,4 +1,7 @@ # Changelog +## 1.0.1 +Target crosslang v0.0.10, add /api/v1/progress_ex.json + ## 1.0.0 Make it a little faster, queue is in sqlite now, fix db bug and more diff --git a/nfpm.yaml b/nfpm.yaml index 3bc953c..417bc07 100644 --- a/nfpm.yaml +++ b/nfpm.yaml @@ -9,7 +9,7 @@ name: "tytd2025" arch: "any" platform: "linux" -version: "1.0.0" +version: "1.0.1" section: "default" priority: "extra"