Package Exports
- @mrlvn/easy-dl
Readme
easy-dl
A simple and flexible library downloader for audio and video using yt-dlp and ffmpeg.
Supports both Node.js and Bun.
📦 Installation
Using NPM
npm install @mrlvn/easy-dlUsing BUN
bun add @mrlvn/easy-dlUsing YARN
yarn add @mrlvn/easy-dlUsing PNPM
pnpm add @mrlvn/easy-dl🚀 Usage
CommonJS
const download = require("@mrlvn/easy-dl");ESModule or TypeScript
import download from "@mrlvn/easy-dl";📚 Examples
import download from "@mrlvn/easy-dl";
(async() => {
// Example 1: Video as Buffer
const videoBuffer = await download("https://youtu.be/dQw4w9WgXcQ", { type: "video" });
// Example 2: Audio to File
await download("https://youtu.be/dQw4w9WgXcQ", {
type: "audio",
output: "rickroll.mp3"
});
// Example 3: With Cookies
await download("https://www.youtube.com/watch?v=dQw4w9WgXcQ", {
type: "video",
output: "video.mp4",
cookies: "./cookies.txt"
});
})();⚙️ Options (DownloadOptions)
| Option | Type | Default | Description |
|---|---|---|---|
mode |
"audio" | "video" |
"audio" |
Choose whether to download audio or video. |
format |
string? |
auto | Output format (mp3, mp4, flac, etc). |
quality |
string? |
best |
Quality setting (e.g. 320k, 1080p, best). |
output |
string? |
undefined |
If provided, saves output to this file. If omitted, returns a Buffer. |
cookies |
string? |
undefined |
Path to cookies file (Netscape/Chrome format) for authenticated downloads. |
📜 License
This project is licensed under the MIT License.
See the LICENSE file for details.