ytdl-exec v0.0.9
Ytdl-Exec
š„š„ Ytdl-Exec - Unleash the Power of YouTube Downloads!
Looking to grab your favorite audio and video files from YouTube? Look no further! With the mighty Ytdl-Exec, you can effortlessly seize those captivating audio and video gems. This versatile tool harnesses the incredible youtube-dl-exec
library to extract all the juicy details, while the unstoppable fluent-ffmpeg
library takes care of downloading the files. Say goodbye to limitations and hello to a world of endless possibilities!
License | |
Latest Version |
Installation
To embark on your YouTube downloading adventure with Ytdl-Exec, you'll need to have Node.js installed on your system. Fear not! The installation process is as easy as a few simple commands:
- Using yarn or npm or pnpm
$ yarn add ytdl-exec (fav)
$ pnpm install ytdl-exec (fav)
$ npm install ytdl-exec (-_-)
Usage
Download Audio š
Dive into the world of mesmerizing audio downloads from YouTube by utilizing the powerful dlAudio function provided by our amazing module. Here's a sneak peek at how to use it:
const { dlAudio } = require("ytdl-exec");
// or
import { dlAudio } from "ytdl-exec";
// Using async/await
try {
await dlAudio({
url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
folder: "folder", // optional
filename: "filename", // optional @default: video-title
quality: "best", // or lowest
});
console.log("Audio downloaded successfully! šµš");
} catch (err) {
console.error("Oh no, an error occurred:", err.message);
}
// Using Promises
dlAudio({
url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
folder: "folder", // optional
filename: "filename", // optional @default: video-title
quality: "best", // or lowest
})
.then(() => {
console.log("Audio downloaded successfully! šµš");
})
.catch((err) => {
console.error("Oh no, an error occurred:", err.message);
});
Ready to immerse yourself in a world of audio wonders? Just replace VIDEO_ID with the actual ID of the YouTube video you desire to download audio from. You can customize the output folder where the audio file will be saved, specify an optional filename for the downloaded audio file, and even choose your preferred audio quality (e.g., "best" or "low").
Download Video with Audio š„š
Craving the complete audiovisual experience? Ytdl-Exec has got you covered! Get ready to download those captivating videos with their accompanying audio effortlessly. Behold the mighty dlVideoWithAudio function provided by our module:
const { dlVideoWithAudio } = require("ytdl-exec");
// or
import { dlVideoWithAudio } from "ytdl-exec";
// Using async/await
try {
await dlVideoWithAudio({
url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
folder: "downloads", // optional
filename: "filename", // optional @default: video-title
resolution: 720, // 144 | 240 | 360 | 480 | 720 | 1080 | 1440 | 2160 | 4320;
});
console.log("Video downloaded successfully! š„š");
} catch (err) {
console.error("Oh no, an error occurred:", err.message);
}
// Using Promises
dlVideoWithAudio({
url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
folder: "downloads", // optional
filename: "filename", // optional @default: video-title
resolution: 720, // 144 | 240 | 360 | 480 | 720 | 1080 | 1440 | 2160 | 4320;
})
.then(() => {
console.log("Video downloaded successfully! š„š");
})
.catch((err) => {
console.error("Oh no, an error occurred:", err.message);
});
Ready to dive into a world of stunning videos? Simply replace VIDEO_ID with the actual ID of the YouTube video you wish to download. You can customize the output folder where the video file will be saved, specify an optional filename for the downloaded video file, and even choose your desired resolution (e.g., 720).
Optional Parameters
Both dlAudio and dlVideoWithAudio functions accept optional parameters:
- filename (optional): You can provide an optional filename for the downloaded file. If not specified, the video or audio title will be used as the filename.
- folder (optional): You can provide an optional folder name for the downloaded file. If not specified, a folder named 'ytdl-exec' will be created and used.
Both functions can be used with await when calling them within an async function or with .then() and .catch() when using Promises to handle the asynchronous nature of the download process.
Features
āØ Fetches video and audio details from a YouTube video using the youtube-dl-exec library. āØ Allows you to choose the desired video format and resolution, as well as audio quality. āØ Downloads the video or audio file using fluent-ffmpeg and saves it to the specified output folder. āØ Provides logging functionality using the winston library.
Logging
The project uses the winston library for logging. It creates a logger with different log levels (info, debug, error) and formats the log messages with colors and timestamps. The logs are displayed in the console.
Customization
You can customize the logging behavior by modifying the logger
object in the code. You can change the log levels, formatting, and transports (e.g., writing logs to a file instead of the console) according to your needs.
License
This project is licensed under the MIT license. Feel free to use, modify, and distribute it as you see fit. See the LICENSE file for more information.