gimmeytmp3 v1.0.4
GimmeYTMP3
A Node.js package to download YouTube videos as MP3 files. This package extracts audio from YouTube videos and converts it to MP3 format.
Installation
npm install gimmeytmp3
Requirements
- Node.js 16 or higher
- FFmpeg installed on your system
- Windows PowerShell (for Windows users)
Installing FFmpeg
FFmpeg is required for audio conversion. Follow these instructions to install it on your system:
Windows
Download the FFmpeg build from the official website or use a package manager like Chocolatey:
choco install ffmpeg
Add FFmpeg to your PATH:
- Right-click on "This PC" or "My Computer" and select "Properties"
- Click on "Advanced system settings"
- Click on "Environment Variables"
- In the "System variables" section, find and select the "Path" variable, then click "Edit"
- Click "New" and add the path to the FFmpeg
bin
folder (e.g.,C:\FFmpeg\bin
) - Click "OK" on all dialogs to save the changes
macOS
Using Homebrew:
brew install ffmpeg
Linux (Ubuntu/Debian)
sudo apt update
sudo apt install ffmpeg
Linux (Fedora)
sudo dnf install ffmpeg
Verify Installation
After installing FFmpeg, verify it's working by running:
ffmpeg -version
Note about yt-dlp
This package uses yt-dlp to download YouTube videos. On Windows, the package will automatically download and use yt-dlp if it's not already installed. On other platforms, you may need to install yt-dlp manually:
macOS
brew install yt-dlp
Linux
sudo apt install yt-dlp # Debian/Ubuntu
sudo dnf install yt-dlp # Fedora
Usage
In your Node.js code
import { downloadMP3 } from "gimmeytmp3";
// Basic usage
try {
const mp3Path = await downloadMP3(
"https://www.youtube.com/watch?v=dQw4w9WgXcQ"
);
console.log(`MP3 saved to: ${mp3Path}`);
} catch (error) {
console.error(`Error: ${error.message}`);
}
// With custom output directory
const outputDir = "./downloads";
const mp3Path = await downloadMP3(
"https://www.youtube.com/watch?v=dQw4w9WgXcQ",
outputDir
);
// With no progress output
const options = { showProgress: false };
const mp3Path = await downloadMP3(
"https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"./downloads",
options
);
Command Line
# Install globally
npm install -g gimmeytmp3
# Basic usage
gimmeytmp3 https://www.youtube.com/watch?v=dQw4w9WgXcQ
# Specify output directory
gimmeytmp3 https://www.youtube.com/watch?v=dQw4w9WgXcQ ./downloads
# Using options
gimmeytmp3 --quiet https://www.youtube.com/watch?v=dQw4w9WgXcQ
gimmeytmp3 -q -o ./downloads https://www.youtube.com/watch?v=dQw4w9WgXcQ
Available options:
-q, --quiet
: Suppress progress output-o, --output
: Specify output directory
Web Interface
A simple web interface example is included in the examples/web-interface
directory. To run it:
Install the required dependencies:
cd examples/web-interface npm install express
Start the server:
node index.js
Open
http://localhost:3000
in your browser and use the form to download YouTube videos as MP3 files.
Troubleshooting
FFmpeg Not Found
If you get an error like FFmpeg is not installed
or spawn ffmpeg ENOENT
:
- Make sure FFmpeg is installed (see installation instructions above)
- Verify FFmpeg is in your PATH by running
ffmpeg -version
in your terminal - Restart your terminal or command prompt after installing FFmpeg
PowerShell Issues (Windows)
If you encounter PowerShell execution policy issues:
- Run PowerShell as Administrator
- Execute
Set-ExecutionPolicy RemoteSigned
to allow local scripts to run - Confirm the change when prompted