mirror of
https://github.com/kunkunsh/kunkun-ext-youtube-downloader.git
synced 2025-05-24 13:45:02 +00:00
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
This commit is contained in:
parent
37066b3474
commit
a8eca4392a
@ -125,7 +125,9 @@ export class YouTubeDownloader implements API {
|
|||||||
|
|
||||||
const videoStream = ytdl(url, { format: videoFormat });
|
const videoStream = ytdl(url, { format: videoFormat });
|
||||||
const audioStream = ytdl(url, { format: audioFormat });
|
const audioStream = ytdl(url, { format: audioFormat });
|
||||||
|
videoStream.once("readable", () => {
|
||||||
|
startCallback?.();
|
||||||
|
});
|
||||||
videoStream.on("progress", (_, downloaded, total) => {
|
videoStream.on("progress", (_, downloaded, total) => {
|
||||||
videoDownloaded += downloaded;
|
videoDownloaded += downloaded;
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
|
2
jsr.json
2
jsr.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@kunkun/kunkun-ext-youtube-downloader",
|
"name": "@kunkun/kunkun-ext-youtube-downloader",
|
||||||
"version": "0.1.1",
|
"version": "0.1.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": "./mod.ts",
|
"exports": "./mod.ts",
|
||||||
"imports": {
|
"imports": {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.kunkun.sh",
|
"$schema": "https://schema.kunkun.sh",
|
||||||
"name": "kunkun-ext-youtube-dowloader",
|
"name": "kunkun-ext-youtube-dowloader",
|
||||||
"version": "0.1.1",
|
"version": "0.1.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"kunkun": {
|
"kunkun": {
|
||||||
|
@ -180,7 +180,7 @@ class DownloadYouTubeExtension extends WorkerExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let url = await clipboard.readText();
|
let url = await clipboard.readText();
|
||||||
// url = "https://youtu.be/-b1FogYHTZc"; // for development only
|
url = "https://youtu.be/-b1FogYHTZc"; // for development only
|
||||||
// check if url is a valid youtube url
|
// check if url is a valid youtube url
|
||||||
if (!url.includes("youtube.com") && !url.includes("youtu.be")) {
|
if (!url.includes("youtube.com") && !url.includes("youtu.be")) {
|
||||||
toast.warning("Invalid YouTube URL from clipboard");
|
toast.warning("Invalid YouTube URL from clipboard");
|
||||||
@ -189,8 +189,10 @@ class DownloadYouTubeExtension extends WorkerExtension {
|
|||||||
const formats = await this.rpc.api.getAvailableResolutions(url);
|
const formats = await this.rpc.api.getAvailableResolutions(url);
|
||||||
const form = new Form.Form({
|
const form = new Form.Form({
|
||||||
title: "Download YouTube Video",
|
title: "Download YouTube Video",
|
||||||
description: "Please copy a YouTube URL then enter this extension.",
|
description: `Please copy a YouTube URL then enter this extension.
|
||||||
key: "form1",
|
High Resolution video (e.g. 4K) could take a very long time to download, please be patient.
|
||||||
|
A progress bar with estimated time isn't implemented yet. There is a loading bar on the top.`,
|
||||||
|
key: "download-youtube-video",
|
||||||
showFormDataDebug: true,
|
showFormDataDebug: true,
|
||||||
submitBtnText: "Download",
|
submitBtnText: "Download",
|
||||||
fields: [
|
fields: [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user