Skip to content

Commit a8eca43

Browse files
committed
feat: improve YouTube download experience and add progress handling
- Add start callback trigger for video stream - Update form description with download guidance - Temporarily hardcode development URL for testing - Bump package version to 0.1.2
1 parent 37066b3 commit a8eca43

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

deno-src/lib.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ export class YouTubeDownloader implements API {
125125

126126
const videoStream = ytdl(url, { format: videoFormat });
127127
const audioStream = ytdl(url, { format: audioFormat });
128-
128+
videoStream.once("readable", () => {
129+
startCallback?.();
130+
});
129131
videoStream.on("progress", (_, downloaded, total) => {
130132
videoDownloaded += downloaded;
131133
const now = Date.now();

jsr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kunkun/kunkun-ext-youtube-downloader",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"license": "MIT",
55
"exports": "./mod.ts",
66
"imports": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://schema.kunkun.sh",
33
"name": "kunkun-ext-youtube-dowloader",
4-
"version": "0.1.1",
4+
"version": "0.1.2",
55
"license": "MIT",
66
"type": "module",
77
"kunkun": {

src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class DownloadYouTubeExtension extends WorkerExtension {
180180
}
181181

182182
let url = await clipboard.readText();
183-
// url = "https://youtu.be/-b1FogYHTZc"; // for development only
183+
url = "https://youtu.be/-b1FogYHTZc"; // for development only
184184
// check if url is a valid youtube url
185185
if (!url.includes("youtube.com") && !url.includes("youtu.be")) {
186186
toast.warning("Invalid YouTube URL from clipboard");
@@ -189,8 +189,10 @@ class DownloadYouTubeExtension extends WorkerExtension {
189189
const formats = await this.rpc.api.getAvailableResolutions(url);
190190
const form = new Form.Form({
191191
title: "Download YouTube Video",
192-
description: "Please copy a YouTube URL then enter this extension.",
193-
key: "form1",
192+
description: `Please copy a YouTube URL then enter this extension.
193+
High Resolution video (e.g. 4K) could take a very long time to download, please be patient.
194+
A progress bar with estimated time isn't implemented yet. There is a loading bar on the top.`,
195+
key: "download-youtube-video",
194196
showFormDataDebug: true,
195197
submitBtnText: "Download",
196198
fields: [

0 commit comments

Comments
 (0)