yt-dlp library.
yt-dlp on PyPI: https://pypi.org/project/yt-dlp/Before starting, make sure you have Python installed. You can download it from python.org.
You can refer to the format selection docs for more information about format options.
[youtube] Extracting URL: https://www.youtube.com/watch?v=IViaa3o7BbU
[youtube] IViaa3o7BbU: Downloading webpage
[info] IViaa3o7BbU: Downloading 1 format(s): 251
[download] Sleeping 5.00 seconds as required by the site...
[download] Destination: output\test.webm
[download] 100% of 4.11MiB in 00:00:00 at 23.39MiB/s
[ExtractAudio] Destination: output\test.mp3
Deleting original file output\test.webm (pass -k to keep)
On
preferredquality:'320'— guaranteed 320kbps constant bitrate (CBR)'0'— highest quality variable bitrate (VBR), often 220–260kbps but perceptually equivalent or better