A lightweight Python package and CLI tool that extracts audio from YouTube videos in multiple formats.
Project description
YouTube-to-Audio CLI Tool
A lightweight Python package and command-line interface (CLI) tool that extracts audio from YouTube videos and playlists in multiple formats, such as MP3, WAV, OGG, AAC, and FLAC.
Features
- Extract audio from YouTube videos or playlists in various formats: MP3, WAV, OGG, AAC, FLAC, M4A, and OPUS.
- Customize the output audio file name.
- By default, names the audio files and playlists after the YouTube video or playlist title.
- Automatically cleans up temporary video files after extraction.
Installation
To install the package from PyPI, run the following command:
pip install youtube-to-audio
Usage
1. Download and Extract Audio from a Single Video in the Default Format (MP3)
youtube-to-audio --url "https://www.youtube.com/watch?v=WysanSNOjMc"
This command extracts the audio in MP3 format and saves it with the same name as the YouTube video title (e.g., The Video Title.mp3).
2. Extract Audio from a Playlist in MP3 Format
youtube-to-audio --url "https://www.youtube.com/playlist?list=PLRBp0Fe2GpgnymQGm0yIxcdzkQsPKwnBD"
This command extracts audio from all videos in a playlist and saves each file by default in a folder named after the playlist, using the YouTube video title as the filename (e.g., Video1.mp3, Video2.mp3, etc.).
3. Extract Audio in a Different Format (e.g., WAV)
youtube-to-audio --url "https://www.youtube.com/watch?v=WysanSNOjMc" --format wav
This command extracts the audio in WAV format and saves it with the YouTube video title (e.g., Your Video Title.wav).
4. Specify a Custom Audio File Name
youtube-to-audio --url "https://www.youtube.com/watch?v=WysanSNOjMc" --format wav --output_name "my_custom_name"
This command extracts the audio in WAV format and saves it as my_custom_name.wav.
5. Extract a Playlist into a Custom Folder
youtube-to-audio --url "https://www.youtube.com/playlist?list=PLRBp0Fe2GpgnymQGm0yIxcdzkQsPKwnBD" --playlist_name "MyPlaylist"
This saves all extracted audio files inside a folder named MyPlaylist instead of using the default playlist title.
Command-Line Options
| Option | Description | Required | Usage Scenario |
|---|---|---|---|
--url |
YouTube video or playlist URL | ✅ Yes | Required for all cases |
--format |
Audio format (mp3, wav, flac, aac, ogg, m4a, opus) |
❌ No (default: mp3) | Extracting in a specific format |
--output_name |
Custom output file name (single videos only) | ❌ No | Naming a single file differently |
--playlist_name |
Custom folder name for playlist downloads | ❌ No | Saving a playlist into a specific folder |
Requirements
This tool requires FFmpeg to be installed on your system. If FFmpeg is not found, the tool will not be able to extract audio.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! If you have suggestions or bug fixes, feel free to open a pull request.
Author
Developed by Jack Tol
GitHub Repository
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file youtube_to_audio-0.1.7.tar.gz.
File metadata
- Download URL: youtube_to_audio-0.1.7.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9dcbeaea22111f49937273fe75fd55f49c7045822c3d17b9284b5317d08306c
|
|
| MD5 |
749560f6cee32434225395454ab74780
|
|
| BLAKE2b-256 |
7c1ee70d4cb1de73bcad3262a6990c8175744e69eefa71958c23d7b86314aa79
|
File details
Details for the file youtube_to_audio-0.1.7-py3-none-any.whl.
File metadata
- Download URL: youtube_to_audio-0.1.7-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fde797af7822cd2c22a026fcab705ce4ba4ef9a65cd076b49c17eda062417e01
|
|
| MD5 |
c8f6e7a13250e7a62b18f573eaade499
|
|
| BLAKE2b-256 |
3bd262b0628e5295230f33f2b14dfe98653910ab444f3d704269b399e3d92e41
|