0

Hello i had this problem wher i run this code.

import pafy
import youtube_dl

DOWNLOAD_FOLDER = 'C:\Muziek'
url = 'https://www.youtube.com/watch?v=NyJRyif6_kk'
video = pafy.new(url)
audiostreams = video.audiostreams
for i in audiostreams:
    print ('bitrate: %s, ext: %s, size: %0.2fMb' % (i.bitrate, i.extension, i.get_filesize()/1024/1024))

bestaudio = video.getbestaudio()

bestaudio.download(filepath = DOWNLOAD_FOLDER)
print('download was a succes')

when i run it it becomes a .m4a file but i want .mp3 can someone help me please?

1 Answers1

0

The documentation states:

Download audio only (no video) in ogg or m4a format

You could first download the file in the m4a format and then convert it to mp3 using another library:

Convert any audio file to mp3 with python

rudolfovic
  • 3,163
  • 2
  • 14
  • 38