This script allows you to download individual YouTube videos or entire playlists and convert them to MP3 format using TypeScript. It utilizes ytdl-core
for downloading videos, ytpl
for handling playlists, and fluent-ffmpeg
for conversion to MP3.
- Node.js installed on your machine or use fnm/nvm.
- pnpm or yarn to manage dependencies.
- TypeScript compiler (
typescript
) installed globally or available as a dev dependency.
-
Clone this repository.
-
Install dependencies using pnpm or yarn:
pnpm install
or
yarn install
Run the script using pnpm
| yarn
:
pnpm download --video <video_id> --output <output_folder>
Replace <video_id> or <playlist_id> with the respective YouTube video ID or playlist ID you want to download. Use --output followed by the desired output folder path where the downloaded files will be saved.
--video <video_id>: Downloads a single video by its ID.
--playlist <playlist_id>: Downloads all videos from a playlist by its ID.
--output <output_folder>: Specifies the output folder to save the downloaded files.
To download a single video:
pnpm download --video <video_id> --output ./downloads
To download a playlist:
pnpm download --playlist <playlist_id> --output ./downloads