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

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