A lightweight Python package and command-line interface (CLI) tool that extracts audio from YouTube videos and playlists 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, and FLAC
- Customize the output audio file name
- By default, names the audio file after the YouTube video title
- Extract audio from YouTube videos using different clients (e.g.,
MWEB
,WEB
,ANDROID
) - Automatically clean 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 "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., Your Video Title.mp3
).
2. Extract Audio from a Playlist in MP3 Format
youtube-to-audio "https://www.youtube.com/playlist?list=PLRBp0Fe2GpgnymQGm0yIxcdzkQsPKwnBD"
This command extracts the audio from all videos in the playlist and saves each file with the same name as the YouTube video title (e.g., Video1.mp3
, Video2.mp3
, etc.).
3. Extract Audio in WAV Format
youtube-to-audio "https://www.youtube.com/watch?v=WysanSNOjMc" 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 "https://www.youtube.com/watch?v=WysanSNOjMc" wav --output my_custom_name
This command extracts the audio in WAV format and saves it as my_custom_name.wav
.
5. Extract Audio Using a Specific YouTube Client (e.g., MWEB or WEB)
You can extract audio from YouTube videos or playlists using different clients (for example, MWEB
, WEB
, or ANDROID
) by specifying the --client
argument:
youtube-to-audio "https://www.youtube.com/watch?v=WysanSNOjMc" flac --client WEB
Note: If audio extraction fails with one client, try switching to a different client (e.g., from
MWEB
toWEB
orANDROID
) to resolve the issue.
6. Enable Verbose Logging
To enable detailed logging (useful for debugging the download or extraction process), use the --verbose
flag:
youtube-to-audio "https://www.youtube.com/watch?v=WysanSNOjMc" aac --verbose
This will display detailed logs during the download and extraction process.
Development
If you'd like to contribute or modify the package locally, clone the repository and install the development dependencies:
pip install -r requirements-dev.txt
Running Tests
To run tests, you can use pytest
(after installing the development dependencies):
pytest
License
This project is licensed under the MIT License. See the LICENSE file for details.
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
File details
Details for the file youtube_to_audio-0.1.3.tar.gz
.
File metadata
- Download URL: youtube_to_audio-0.1.3.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8881796f94d7f065814093715e270d9bc8c541aeb1598b86870c16e134228e19 |
|
MD5 | e6f3a16fa6b0897b2caaf83784ebbd27 |
|
BLAKE2b-256 | 7e065b7bfb5784e68aeecb74083b029e83512d2c9244002ffbb21a9cd4a9161e |
File details
Details for the file youtube_to_audio-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: youtube_to_audio-0.1.3-py3-none-any.whl
- Upload date:
- Size: 6.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 | f0090609a3ce2bb16cdd0d79e4343bb9ffae4b705dff4da23bf58d1e447fb467 |
|
MD5 | 8177a9000875ccdc1e5186a1f53011f7 |
|
BLAKE2b-256 | ac92013c02846c3cdddb344c270b382bad98178dab6ef856fc6a778bd64dbc64 |