Download Youtube Music Python 3

I’ve been looking for a clean and simple way to download youtube music in my progOverEmail program and stumbled across a module called pafy I wanted to share. You can download pafy here.

It’s super simple to use. All you have to do is drop pafy.py into the same folder as your other python code and import it. To download youtube music you only need the following code:

video = pafy.new(songURL)
audio = video.getbestaudio()
audio.download()

That’s it. It will download it to the current working directory. I just had it download the best quality audio, but you can have it download audio (and video) of varying qualities. View a more extensive description here.

Leave a Reply