Target crosslang v0.0.10, add /api/v1/progress_ex.json
All checks were successful
Build and Deploy on Tag / 🔨 Build (push) Successful in 20s

This commit is contained in:
2026-09-10 03:15:05 -05:00
parent 456577f2f7
commit dc270e6785
6 changed files with 53 additions and 24 deletions

View File

@@ -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
```

View File

@@ -1,12 +1,12 @@
func Components.Progress(tytd)
{
var vid = tytd.CurrentVideo;
var progress = tytd.GetProgress();
var html = <div hx-trigger="every 4500ms" hx-indicator="none" hx-get="./progress" hx-swap="outerHTML">
<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>
<h2><a hx-target="body" hx-push-url="true" hx-get={$"./watch?v={Net.Http.UrlEncode(progress.CurrentVideo.VideoId)}"} href={$"./watch?v={Net.Http.UrlEncode(progress.CurrentVideo.VideoId)}"}>{progress.CurrentVideo.Title}</a></h2>
<h4><a hx-target="body" hx-push-url="true" hx-get={$"./channel?id={Net.Http.UrlEncode(progress.CurrentVideo.ChannelId)}"} href={$"./channel?id={Net.Http.UrlEncode(progress.CurrentVideo.ChannelId)}"}>{progress.CurrentVideo.Channel}</a></h4>
<progress class="wavy light-green-text" value={progress.CurrentVideoProgress * 100.0} max="100" min="0"></progress>
</div>;
return html;
}

View File

@@ -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")

View File

@@ -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

View File

@@ -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

View File

@@ -9,7 +9,7 @@
name: "tytd2025"
arch: "any"
platform: "linux"
version: "1.0.0"
version: "1.0.1"
section: "default"
priority: "extra"