Download video in mp3 format using pytube

前端 未结 5 1276
清歌不尽
清歌不尽 2021-02-08 07:26

I have been using pytube to download youtube videos in python. So far I have been able to download in mp4 format.

yt = pytube.YouTube(\"https://www.youtube.com/         


        
5条回答
  •  时光取名叫无心
    2021-02-08 08:07

    I am assuming you are using Python 3 and pytube 9.x, you can use the filter method to "filter", the file extension you are interested in.

    For example, if you would like to download mp4 video file format it would look like the following:

    pytube.Youtube('url here').streams.filter(file_extension='mp4').first()
    

    if you would like to pull audio it would look like the following:

    pytube.Youtube('url here').streams.filter(only_audio=True).all()
    

    Hope that helps anyone landing on this page; rather than converting unnecessarily.

提交回复
热议问题