This is a command-line tool to download YouTube videos in various formats (MP3, MP4, WEBM) using TypeScript. The tool leverages ytdl-core
for fetching YouTube video data and readline-sync
for interactive command-line input.
- Node.js installed on your system (version 12 or higher).
- npm (Node Package Manager) should be installed.
- TypeScript globally installed (
npm install -g typescript
).
-
Clone the Repository
git clone https://github.com/cptcr/yt-downloader-ts/ cd https://github.com/cptcr/yt-downloader-ts/
-
Install Dependencies
Install the required dependencies using npm:
npm install
-
Compile TypeScript to JavaScript
Compile the TypeScript code to JavaScript:
npx tsc
This will generate the compiled JavaScript files in the same directory.
-
Run the YouTube Downloader
After compiling, you can run the script using Node.js:
node <compiled-file-name>.js
Replace
<compiled-file-name>
with the actual compiled JavaScript file name.
- Enter the YouTube video URL you want to download.
- Confirm if you want to download the video after seeing its title.
- Choose the format you want to download (MP3, MP4, WEBM).
- Select the desired quality for the download.
- Wait for the download to complete. The file will be saved in the same directory.
- Ensure you have a stable internet connection for downloading videos.
- The downloaded files will be saved with a timestamp to avoid overwriting existing files.
- If you encounter issues while downloading, ensure the YouTube URL is valid.
- For permission errors, make sure you have the appropriate write permissions in the directory where you are running the script.
- If you receive "No available formats found," the video might have restricted formats. Try another video.
This project is licensed under the MIT License.
- chalk for coloring terminal output.
- ytdl-core for downloading YouTube videos.
- readline-sync for interactive command-line input.
Enjoy downloading YouTube videos!